From owner-svn-src-head@FreeBSD.ORG Tue Oct 29 15:29:22 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id B3F8DFFB; Tue, 29 Oct 2013 15:29:22 +0000 (UTC) (envelope-from markjdb@gmail.com) Received: from mail-qa0-x230.google.com (mail-qa0-x230.google.com [IPv6:2607:f8b0:400d:c00::230]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4D2302EAA; Tue, 29 Oct 2013 15:29:22 +0000 (UTC) Received: by mail-qa0-f48.google.com with SMTP id k4so112448qaq.7 for ; Tue, 29 Oct 2013 08:29:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=7rBP0pH97g/TqPN4Ro+9t5fSoVjPInMZO5ip+tDPmBw=; b=jIx8En9Fui0/ZlLLe4OQB03ZQ4sT8mtQanQbfX/lTOL6NWAA/JvLLluM6Y42Izhoi7 cqe4xZKW160B8T2JIMHA7bwDXZq4EQ6JqBhWnP1TzGdbwTQqS0qJIpc9oTPbIlHUNenx 7bHW4rG8efjY1tECQq7D4Bq0rJHMVB/FYPLACvMA5rKC13MKKJqcjAJo83gCdSYTpZQ1 nJwdCDZkX6xiZHaaOR4wqbxqoDzYkGCZX+jgDJR4/zaTqhdWf7uRcZjhEKDWzzwu+3KG hNdVf6J4/4IZVkJIDF9k3Qtld1vFANOwy7yXHhJc4fnqHckjErTtp7AbpO6Q20GtJfY7 KxlA== X-Received: by 10.224.87.198 with SMTP id x6mr1404333qal.61.1383060560536; Tue, 29 Oct 2013 08:29:20 -0700 (PDT) Received: from charmander.sandvine.com ([64.7.137.182]) by mx.google.com with ESMTPSA id b10sm55056387qeg.7.2013.10.29.08.29.19 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 29 Oct 2013 08:29:19 -0700 (PDT) Sender: Mark Johnston Date: Tue, 29 Oct 2013 11:29:05 -0400 From: Mark Johnston To: Bruce Evans Subject: Re: svn commit: r257298 - head/lib/libproc Message-ID: <20131029152905.GA2652@charmander.sandvine.com> References: <201310290312.r9T3CVx4064237@svn.freebsd.org> <20131029235717.M905@besplex.bde.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20131029235717.M905@besplex.bde.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Oct 2013 15:29:22 -0000 On Wed, Oct 30, 2013 at 12:21:28AM +1100, Bruce Evans wrote: > 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? It looks like this is because of the use of -W, which is apparently an alias for -Wextra; according to the gcc man page, this will trigger a warning when "an empty body occurs in an if or else statement." > > > 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