Re: [RFC] CryptoAPI & Compression

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> Are you sure that 12 bytes is enough for all cases? It would seem
> to be safer to use the formula in deflateBound/compressBound from
> later versions (> 1.2) of zlib to calculate the reserve.
>
I'm not sure. David Woodhouse (the author) said that this is probably 
enough in any case but a lot of time has gone since the code was written 
and he doesn't remember for sure. I have also seen some magic number "12" 
somewhere in zlib, but I'm not sure.

At least my practice shows that 12 is Ok for JFFS2 where we compress fewer 
then 4K a a time. I'll explore this.

> We normally put the operator on the preceding line, i.e.,
>
> while (foo &&
>        bar) {
If this is the the common practice for Linux, then OK. My argument is the 
GNU Coding style which recommends:

----------------------------------------------------------------------
When you split an expression into multiple lines, split it before an 
operator, not after one. Here is the right way:

     if (foo_this_is_long && bar > win (x, y, z)
         && remaining_condition)
----------------------------------------------------------------------

while the Linux coding style doesn't mention this AFAIR. And of course, 
Linux doesn't have to obey that rule. 

Ok. This is not the final patch but more like RFC and I can re-format and 
re-send it. :-) Please, feel free to re-format it as you would like 
yourself.

And one more thing I wanted to offer. In the 
deflate_[compress|uncompress|pcompress] functions we call the 
zlib_[in|de]flateReset function at the beginning. This is OK. But when we 
unload the deflate module we don't call zlib_[in|de]flateEnd to free all 
the zlib internal data. It looks like a bug for me. Please, consider the 
attached patch.

--
Best Regards,
Artem B. Bityuckiy,
St.-Petersburg, Russia.
diff -auNrp linux-2.6.11.5/crypto/deflate.c linux-2.6.11.5_changed/crypto/deflate.c
--- linux-2.6.11.5/crypto/deflate.c	2005-03-29 15:37:44.000000000 +0400
+++ linux-2.6.11.5_changed/crypto/deflate.c	2005-03-29 15:37:38.000000000 +0400
@@ -93,11 +93,13 @@ out_free:
 
 static void deflate_comp_exit(struct deflate_ctx *ctx)
 {
+	zlib_deflateEnd(&ctx->comp_stream);
 	vfree(ctx->comp_stream.workspace);
 }
 
 static void deflate_decomp_exit(struct deflate_ctx *ctx)
 {
+	zlib_inflateEnd(&ctx->decomp_stream);
 	kfree(ctx->decomp_stream.workspace);
 }
 

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux