Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 01 Jan 2018 16:14:33 +0000
From:      "Poul-Henning Kamp" <phk@phk.freebsd.dk>
To:        Mark Millard <markmi@dsl-only.net>
Cc:        FreeBSD Hackers <freebsd-hackers@freebsd.org>, "Rodney W. Grimes" <freebsd-rwg@pdx.rh.CN85.dnsmgr.net>
Subject:   Re: Is it considered to be ok to not check the return code of close(2) in base?
Message-ID:  <78982.1514823273@critter.freebsd.dk>
In-Reply-To: <510305A9-460C-407F-B2FC-3521A6E1D78B@dsl-only.net>
References:  <201801010305.w0135luG084158@pdx.rh.CN85.dnsmgr.net> <559541DD-3287-4473-B7DE-B4DDC6860DF7@dsl-only.net> <69781.1514800992@critter.freebsd.dk> <510305A9-460C-407F-B2FC-3521A6E1D78B@dsl-only.net>

next in thread | previous in thread | raw e-mail | index | archive | help
--------
In message <510305A9-460C-407F-B2FC-3521A6E1D78B@dsl-only.net>, Mark Milla=
rd 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@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?78982.1514823273>