From: "J.A. Magallon" <jamagallon@able.es>
To: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Really *do* nothing in while loop
Date: Sun, 08 May 2005 21:43:05 +0000 [thread overview]
Message-ID: <1115588585l.7394l.0l@werewolf.able.es> (raw)
In-Reply-To: <427DE086.40307@tls.msk.ru> (from mjt@tls.msk.ru on Sun May 8 11:48:54 2005)
On 05.08, Michael Tokarev wrote:
> Thomas Glanzmann wrote:
> > [PATCH] Really *do* nothing in while loop
> >
> > Signed-Off-by: Thomas Glanzmann <sithglan@stud.uni-erlangen.de>
> >
> > --- 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))
next prev parent reply other threads:[~2005-05-08 21:43 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-05-08 9:34 Thomas Glanzmann
2005-05-08 9:48 ` Michael Tokarev
2005-05-08 11:18 ` Thomas Glanzmann
2005-05-08 11:20 ` James Purser
2005-05-08 11:33 ` jdow
2005-05-08 11:40 ` Michael Tokarev
2005-05-08 21:08 ` Junio C Hamano
2005-05-08 21:43 ` J.A. Magallon [this message]
2005-05-08 13:18 ` [PATCH] Really *do* nothing in while loop [OT - style] Eyal Lebedinsky
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1115588585l.7394l.0l@werewolf.able.es \
--to=jamagallon@able.es \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome