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

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

 



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@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]