From owner-svn-src-all@FreeBSD.ORG Wed Jun 20 16:37:36 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3604A106566B for ; Wed, 20 Jun 2012 16:37:36 +0000 (UTC) (envelope-from bounces+73574-8822-svn-src-all=freebsd.org@sendgrid.me) Received: from o3.shared.sendgrid.net (o3.shared.sendgrid.net [208.117.48.85]) by mx1.freebsd.org (Postfix) with SMTP id B6ADB8FC22 for ; Wed, 20 Jun 2012 16:37:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sendgrid.info; h= message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type:content-transfer-encoding; s=smtpapi; bh=TftGBz3F3lVqpXVib75fwLxiFi4=; b=fO0aiA6Vas2DTqjyy5MypgybGrzr Cx15fN/qVffYztON2VZSiq4yaV+rAG8YqvZa7cdNuYcXS+h0xT1W5y8NHBFymIKC Y/3W3s+QLEUO028rYaApiU6Ni+QL2rl4ArjyHUMCMGUrc9prG1ISyIylAzjh6Vl8 kThAubkP75ZdsSg= Received: by 10.8.40.34 with SMTP id mf27.22848.4FE1FC4E5 Wed, 20 Jun 2012 11:37:34 -0500 (CDT) Received: from mail.tarsnap.com (unknown [10.9.180.5]) by mi13 (SG) with ESMTP id 4fe1fc4e.64c9.13f9e2c for ; Wed, 20 Jun 2012 11:37:34 -0500 (CST) Received: (qmail 84858 invoked from network); 20 Jun 2012 16:37:10 -0000 Received: from unknown (HELO clamshell.daemonology.net) (127.0.0.1) by ec2-107-20-205-189.compute-1.amazonaws.com with ESMTP; 20 Jun 2012 16:37:10 -0000 Received: (qmail 90108 invoked from network); 20 Jun 2012 16:36:52 -0000 Received: from unknown (HELO clamshell.daemonology.net) (127.0.0.1) by clamshell.daemonology.net with SMTP; 20 Jun 2012 16:36:52 -0000 Message-ID: <4FE1FC23.9000904@freebsd.org> Date: Wed, 20 Jun 2012 09:36:51 -0700 From: Colin Percival User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:12.0) Gecko/20120509 Thunderbird/12.0.1 MIME-Version: 1.0 To: Bruce Evans References: <201206200638.q5K6cg7u024024@svn.freebsd.org> <20120621015220.J2636@besplex.bde.org> In-Reply-To: <20120621015220.J2636@besplex.bde.org> X-Enigmail-Version: 1.5pre Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Sendgrid-EID: A6W2xSVPHetogaU8rnzccWwgBYtN+QvIzXyjfe/10PGJ/U/8j1yE/RbsrcYMg7DYavaqb8pvAziIOu0BhK/yk45KoCEXoVPLrDSumY2btvZzFuDCSyTa5Om0hrb2QYfgBiWnmT+f2N3zBhmBjkhA/kR3jNiYwelf5xcSNs/OMj0= Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Eitan Adler Subject: Re: svn commit: r237286 - head/lib/libc/gen X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jun 2012 16:37:36 -0000 On 06/20/12 09:27, Bruce Evans wrote: > On Wed, 20 Jun 2012, Eitan Adler wrote: >> Log: >> Don't close an uninitialized descriptor. [1] >> Add a sanity check for the validity of the passed fd. > > Library functions shouldn't use assert() or abort(). Why not? > The fd is not passed, but is a static variable under syslog()'s control. I understood "passed fd" to mean "fd we're passing to _close". >> closelog(void) >> { >> THREAD_LOCK(); >> - (void)_close(LogFile); >> - LogFile = -1; >> + assert(LogFile >= -1); > > Since this assert() can't fail (unless the CPU has a parity error or > or the memory behind Logfile has a parity error or another memory error > or was clobbered by a buffer overrun), this assert() doesn't break the > library but just wastes space. I asked eadler to include that on the basis that it made the code easier to understand. -- Colin Percival Security Officer Emeritus, FreeBSD | The power to serve Founder, Tarsnap | www.tarsnap.com | Online backups for the truly paranoid