Re: [PATCH] dir: do all size checks before seeking back and fix file closing
Show 17 quoted lines
> 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