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
Mon Jan 1 16:15:01 UTC 2018


--------
In message <510305A9-460C-407F-B2FC-3521A6E1D78B at dsl-only.net>, Mark Millard wr
ites:

>None of us invented assert as it was
>first historically created or as it is
>in the standards.

Asserts are way older than UNIX.

>If one wants to use assert, then
>instead of:

Just do:

	#undef NDEBUG
	#include <assert.h>

But this is bikeshedding at this point anyway.

The important thing is this:

  Yes, you should check the return value of close(2) (except possibly
  for the special cases of stdin/-out/-err) and if you are sure they
  will never fail, doing so with an assert makes sense.

Over&Out


-- 
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