Date: Wed, 10 Jan 2018 10:47:37 +0000 From: "Poul-Henning Kamp" <phk@phk.freebsd.dk> To: Stefan Esser <se@freebsd.org> Cc: "Rodney W. Grimes" <freebsd-rwg@pdx.rh.CN85.dnsmgr.net>, Eric van Gyzen <eric@vangyzen.net>, Brooks Davis <brooks@freebsd.org>, Ian Lepore <ian@freebsd.org>, Alan Somers <asomers@freebsd.org>, Freebsd hackers list <freebsd-hackers@freebsd.org>, Yuri <yuri@rawbw.com>, Eugene Grosbein <eugen@grosbein.net> Subject: Re: Is it considered to be ok to not check the return code of close(2) in base? Message-ID: <21075.1515581257@critter.freebsd.dk> In-Reply-To: <b7d5cc97-2042-42ff-914c-35a28560932b@freebsd.org> References: <201801081800.w08I0D0q022877@pdx.rh.CN85.dnsmgr.net> <b7d5cc97-2042-42ff-914c-35a28560932b@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
-------- In message <b7d5cc97-2042-42ff-914c-35a28560932b@freebsd.org>, Stefan Esse= r wri tes: >> Ok, so lets get a bit more clever, >> #ifdef DEBUG_CLOSE >> #define close(f) assert(close(f) && errno !=3D 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@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= .
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?21075.1515581257>