In glibc reference we find such words:
...sloppy code like
{ int c; ... while ((c = getc (fp)) < 0) ... }
has to be rewritten...
Why testing for the sign of the int is called "sloppy code" in glibc reference?
In glibc reference we find such words:
...sloppy code like
{ int c; ... while ((c = getc (fp)) < 0) ... }
has to be rewritten...
Why testing for the sign of the int is called "sloppy code" in glibc reference?
This is related to the use of WEOF
macro. As already mentioned in the reference, (emphasis mine)
WEOF
need not be the same value asEOF
and unlikeEOF
it also need not be negative. [...]
So, checking for < 0
might be a wrong decision, strictly speaking, it should be checked against the return value of WEOF
itself.