On 05.08, Michael Tokarev wrote:
> Thomas Glanzmann wrote:
> > [PATCH] Really *do* nothing in while loop
> >
> > Signed-Off-by: Thomas Glanzmann <[email protected]>
> >
> > --- a/sha1_file.c
> > +++ b/sha1_file.c
> > @@ -335,7 +335,7 @@
> > stream.next_in = hdr;
> > stream.avail_in = hdrlen;
> > while (deflate(&stream, 0) == Z_OK)
> > - /* nothing */
> > + /* nothing */;
> >
> > /* Then the data itself.. */
> > stream.next_in = buf;
>
> Well, the lack of semicolon is wrong really (and funny).
>
> But is the whole while loop needed at all? deflate()
> consumes as much input as it can, producing as much output
> as it can. So without the loop, and without updating the
> buffer pointers ({next,avail}_{in,out}) it will do just
> fine without the loop, and will return something != Z_OK
> on next iteration. If this is to mean to flush output,
> it should be deflate(&stream, Z_FLUSH) or something.
>
This changes the code in the corner case when deflate(...) IS NOT Z_OK
in the first iteration.
Old code: next_in is not assigned if deflate(&stream, 0) != Z_OK
New code: next_is is _always_ assigned
Other point is if old code was wrong...hidden bug ?
--
J.A. Magallon <jamagallon()able!es> \ Software is like sex:
werewolf!able!es \ It's better when it's free
Mandriva Linux release 2006.0 (Cooker) for i586
Linux 2.6.11-jam16 (gcc 4.0.0 (4.0.0-3mdk for Mandriva Linux release 2006.0))
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[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]