Re: [PATCH] dir: do all size checks before seeking back and fix file closing

From: Jakub Narebski <jnareb@gmail.com>
Date: 2006-08-27 08:35:34
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


-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Received on Sun Aug 27 08:36:29 2006

This archive was generated by hypermail 2.1.8 : 2006-08-27 08:37:08 EST