Date: Sun, 8 Jan 2012 21:15:16 +1100 (EST) From: Bruce Evans <brde@optusnet.com.au> To: Bruce Evans <brde@optusnet.com.au> Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org, Eitan Adler <eadler@FreeBSD.org> Subject: Re: svn commit: r229794 - head/usr.bin/hexdump Message-ID: <20120108210842.U14348@besplex.bde.org> In-Reply-To: <20120108203419.S14348@besplex.bde.org> References: <201201072315.q07NFM3v060477@svn.freebsd.org> <20120108203419.S14348@besplex.bde.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120108210842.U14348>