git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Narebski <jnareb@gmail.com>
To: git@vger.kernel.org
Subject: Re: [PATCH] dir: do all size checks before seeking back and fix file closing
Date: Sun, 27 Aug 2006 00:35:34 +0200	[thread overview]
Message-ID: <ecqibj$51v$1@sea.gmane.org> (raw)
In-Reply-To: Pine.LNX.4.64.0608261509290.11811@g5.osdl.org

Linus Torvalds wrote:

> Now, admittedly it's wrong because another bad habit Junio picked up 
> (doing comparisons with constants in the wrong order), so please write it 
> as
> 
>         if (fd >= 0)
>                 close(fd);
> 
> instead.
> 
> Junio: I realize that you claim that you learnt that syntax from an 
> authorative source, but he was _wrong_. Doing the constant first is more 
> likely to cause bugs, rather than less. Compilers will warn about the
> 
>         if (x = 0)
>                 ..
> 
> kind of bug, and putting the constant first just confuses humans.

Well, perhaps except checking if variable is in given range, e.g.

        if (0 <= x && x <= 5)
 
> It's more important to _not_ confuse humans than it is to try to avoid an 
> uncommon error that compilers can and do warn about anyway.
 

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

  reply	other threads:[~2006-08-26 22:36 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-26 14:17 [PATCH] dir: do all size checks before seeking back and fix file closing Jonas Fonseca
2006-08-26 18:43 ` Mitchell Blank Jr
2006-08-26 20:44   ` Jonas Fonseca
2006-08-26 22:13 ` Linus Torvalds
2006-08-26 22:35   ` Jakub Narebski [this message]
2006-08-27  0:07   ` Junio C Hamano
2006-08-27  2:15     ` Junio C Hamano
2006-08-27  2:37     ` Linus Torvalds
2006-08-27  3:04       ` Junio C Hamano
2006-08-27 23:55     ` [PATCH] Use fstat instead of fseek Jonas Fonseca

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='ecqibj$51v$1@sea.gmane.org' \
    --to=jnareb@gmail.com \
    --cc=git@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;
as well as URLs for NNTP newsgroup(s).