From owner-freebsd-hackers@freebsd.org Mon Jan 1 16:15:01 2018 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 27842EB09E9 for ; Mon, 1 Jan 2018 16:15:01 +0000 (UTC) (envelope-from phk@critter.freebsd.dk) Received: from phk.freebsd.dk (phk.freebsd.dk [130.225.244.222]) by mx1.freebsd.org (Postfix) with ESMTP id DDD8C71E9A for ; Mon, 1 Jan 2018 16:15:00 +0000 (UTC) (envelope-from phk@critter.freebsd.dk) Received: from critter.freebsd.dk (unknown [192.168.55.3]) by phk.freebsd.dk (Postfix) with ESMTP id 6F4A6273A3; Mon, 1 Jan 2018 16:14:50 +0000 (UTC) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.15.2/8.15.2) with ESMTPS id w01GEYmV078984 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Mon, 1 Jan 2018 16:14:34 GMT (envelope-from phk@critter.freebsd.dk) Received: (from phk@localhost) by critter.freebsd.dk (8.15.2/8.15.2/Submit) id w01GEXfv078983; Mon, 1 Jan 2018 16:14:33 GMT (envelope-from phk) To: Mark Millard cc: FreeBSD Hackers , "Rodney W. Grimes" Subject: Re: Is it considered to be ok to not check the return code of close(2) in base? In-reply-to: <510305A9-460C-407F-B2FC-3521A6E1D78B@dsl-only.net> From: "Poul-Henning Kamp" 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> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <78981.1514823273.1@critter.freebsd.dk> Content-Transfer-Encoding: quoted-printable Date: Mon, 01 Jan 2018 16:14:33 +0000 Message-ID: <78982.1514823273@critter.freebsd.dk> X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Jan 2018 16:15:01 -0000 -------- 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 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= .