From owner-freebsd-hackers@freebsd.org Wed Jan 10 10:48:00 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 09F19E786D3 for ; Wed, 10 Jan 2018 10:48:00 +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 AFC306DAC3; Wed, 10 Jan 2018 10:47:59 +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 D187D27374; Wed, 10 Jan 2018 10:47:55 +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 w0AAlehg021077 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Wed, 10 Jan 2018 10:47:40 GMT (envelope-from phk@critter.freebsd.dk) Received: (from phk@localhost) by critter.freebsd.dk (8.15.2/8.15.2/Submit) id w0AAlbkk021076; Wed, 10 Jan 2018 10:47:37 GMT (envelope-from phk) To: Stefan Esser cc: "Rodney W. Grimes" , Eric van Gyzen , Brooks Davis , Ian Lepore , Alan Somers , Freebsd hackers list , Yuri , Eugene Grosbein Subject: Re: Is it considered to be ok to not check the return code of close(2) in base? In-reply-to: From: "Poul-Henning Kamp" References: <201801081800.w08I0D0q022877@pdx.rh.CN85.dnsmgr.net> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <21074.1515581257.1@critter.freebsd.dk> Content-Transfer-Encoding: quoted-printable Date: Wed, 10 Jan 2018 10:47:37 +0000 Message-ID: <21075.1515581257@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: Wed, 10 Jan 2018 10:48:00 -0000 -------- In message , 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 -- = 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= .