From owner-svn-src-head@FreeBSD.ORG Sun Jan 8 10:15:21 2012 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E774B106564A; Sun, 8 Jan 2012 10:15:21 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail07.syd.optusnet.com.au (mail07.syd.optusnet.com.au [211.29.132.188]) by mx1.freebsd.org (Postfix) with ESMTP id 034BE8FC0C; Sun, 8 Jan 2012 10:15:20 +0000 (UTC) Received: from c211-30-171-136.carlnfd1.nsw.optusnet.com.au (c211-30-171-136.carlnfd1.nsw.optusnet.com.au [211.30.171.136]) by mail07.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id q08AFGRp030552 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 8 Jan 2012 21:15:17 +1100 Date: Sun, 8 Jan 2012 21:15:16 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Bruce Evans In-Reply-To: <20120108203419.S14348@besplex.bde.org> Message-ID: <20120108210842.U14348@besplex.bde.org> References: <201201072315.q07NFM3v060477@svn.freebsd.org> <20120108203419.S14348@besplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, Eitan Adler Subject: Re: svn commit: r229794 - head/usr.bin/hexdump X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 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: Sun, 08 Jan 2012 10:15:22 -0000 On Sun, 8 Jan 2012, Bruce Evans wrote: > ... > Fixing these style bugs gives something like: > > %%% > /* > * Set end pointer. First make sure that p1 is not > * the empty string.. > */ > p2 = *p1 == '\0' ? p1 + p1 + 1; Grr, typo. One of the `+'s should be `:'. I hope I inverted the logic of this expression correctly. > > /* Set conversion string. */ > cs[0] = *p1; > cs[1] = '\0'; > > %%% > Possible furthe improvements: > - some programmers can't would add unnecessary parentheses for the ?: > operator. Even I might add them. Since I changed `*p1' to `*p1 == `\0'' and inverted the logic, it has an extra operator so it needs the parentheses more than before: p2 = (*p1 == '\0' ? p1 : p1 + 1); Not: p2 = (*p1 == '\0') ? p1 : p1 + 1; (since this adds parentheses where they are least needed), or p2 = ((*p1 == '\0') ? p1 : p1 + 1); (since this adds layers of parentheses which must be parsed to see where they actually are). Bruce