Is it considered to be ok to not check the return code of close(2) in base?
Poul-Henning Kamp
phk at phk.freebsd.dk
Wed Jan 10 10:48:00 UTC 2018
--------
In message <b7d5cc97-2042-42ff-914c-35a28560932b at freebsd.org>, Stefan Esser wri
tes:
>> Ok, so lets get a bit more clever,
>> #ifdef DEBUG_CLOSE
>> #define close(f) assert(close(f) && errno != EBADF)
>> #endif
>
>This will lead to close() being removed from the program,
>if NDEBUG is defined ...
>
>So, at least test for NDEBUG in addition to DEBUG_CLOSE,
>to enable this macro.
More importantly, it will lead to the assert failing if close(2)
succeeds...
The NDEBUG details is easiest solved by:
#undef NDEBUG // assert()'s not to be removed
#include <assert.h>
--
Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG | TCP/IP since RFC 956
FreeBSD committer | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.
More information about the freebsd-hackers
mailing list