From owner-svn-src-all@FreeBSD.ORG Tue Oct 29 13:21:39 2013 Return-Path: Delivered-To: svn-src-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 64466FB3; Tue, 29 Oct 2013 13:21:39 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail110.syd.optusnet.com.au (mail110.syd.optusnet.com.au [211.29.132.97]) by mx1.freebsd.org (Postfix) with ESMTP id 27AAC26C0; Tue, 29 Oct 2013 13:21:38 +0000 (UTC) Received: from c122-106-156-23.carlnfd1.nsw.optusnet.com.au (c122-106-156-23.carlnfd1.nsw.optusnet.com.au [122.106.156.23]) by mail110.syd.optusnet.com.au (Postfix) with ESMTPS id 5D517780AD2; Wed, 30 Oct 2013 00:21:30 +1100 (EST) Date: Wed, 30 Oct 2013 00:21:28 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Mark Johnston Subject: Re: svn commit: r257298 - head/lib/libproc In-Reply-To: <201310290312.r9T3CVx4064237@svn.freebsd.org> Message-ID: <20131029235717.M905@besplex.bde.org> References: <201310290312.r9T3CVx4064237@svn.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=DstvpgP+ c=1 sm=1 tr=0 a=ebeQFi2P/qHVC0Yw9JDJ4g==:117 a=PO7r1zJSAAAA:8 a=OlY6O5FfQTkA:10 a=kj9zAlcOel0A:10 a=JzwRw_2MAAAA:8 a=c1kkC1SkZDMA:10 a=dCe2TcBUkNIx_7PF2fMA:9 a=CjuIK1q_8ugA:10 Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 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: Tue, 29 Oct 2013 13:21:39 -0000 On Tue, 29 Oct 2013, Mark Johnston wrote: > Log: > Revert r257248 and fix the problem in a way that doesn't violate style(9). Why did gcc complain about the original version? > Modified: head/lib/libproc/_libproc.h > ============================================================================== > --- head/lib/libproc/_libproc.h Tue Oct 29 02:25:18 2013 (r257297) > +++ head/lib/libproc/_libproc.h Tue Oct 29 03:12:31 2013 (r257298) > @@ -52,6 +52,6 @@ struct proc_handle { > #define DPRINTF(...) warn(__VA_ARGS__) > #define DPRINTFX(...) warnx(__VA_ARGS__) > #else > -#define DPRINTF(...) > -#define DPRINTFX(...) > +#define DPRINTF(...) do { } while (0) > +#define DPRINTFX(...) do { } while (0) > #endif > > Modified: head/lib/libproc/proc_util.c > ============================================================================== > --- head/lib/libproc/proc_util.c Tue Oct 29 02:25:18 2013 (r257297) > +++ head/lib/libproc/proc_util.c Tue Oct 29 03:12:31 2013 (r257298) > @@ -145,9 +145,8 @@ proc_wstatus(struct proc_handle *phdl) > if (phdl == NULL) > return (-1); > if (waitpid(phdl->pid, &status, WUNTRACED) < 0) { > - if (errno != EINTR) { > + if (errno != EINTR) > DPRINTF("waitpid"); > - } > return (-1); > } > if (WIFSTOPPED(status)) Unlike some buggy macros, the null macro expanded to syntactically correct code: if (errno != EINTR) ; so it doesn't need the do-while hack. Empty statements are common in some contexts, so compilers shouldn't warn about them. In all versions, the macro isn't completely function-like and the if statement is dead code, so if compilers warn about too many things then the do-while hack wouldn't work here or in most places that it is used. Nearby style bugs: - the error check is for "< 0" instead of for "== -1" - the error message is not as loud as old ones. All old ones begin with "ERROR: ". The new style is better. "ERROR" is not even redundant. It is wrong, since the errors are just warnings. Bruce