Date: Fri, 27 Dec 2002 12:06:05 -0800 From: Alfred Perlstein <bright@mu.org> To: Jeffrey Hsu <hsu@FreeBSD.org> Cc: Matthew Dillon <dillon@apollo.backplane.com>, cvs-committers@FreeBSD.ORG, cvs-all@FreeBSD.ORG Subject: Re: cvs commit: src/sys/kern uipc_usrreq.c Message-ID: <20021227200605.GS23663@elvis.mu.org> In-Reply-To: <0H7S0085YN2VDE@mta6.snfc21.pbi.net> References: <200212271855.gBRItiIC057945@apollo.backplane.com> <0H7S0085YN2VDE@mta6.snfc21.pbi.net>
next in thread | previous in thread | raw e-mail | index | archive | help
* Jeffrey Hsu <hsu@FreeBSD.org> [021227 11:49] wrote:
> > It will work
>
> Yes, let's not forget this. The old code didn't work. And, the
> question that was initially asked a basic C sequence point question
> on whether the ternary operator worked with the pre-increment operator.
>
> > there really is no reason
> > to collapse the mess onto a single line
>
> I can think of three reasons:
>
> 1. Precedent
> 2. Readability
>
> Compare the committed version
>
> if (unp->unp_ino == 0)
> unp->unp_ino = (++unp_ino == 0) ? ++unp_ino : unp_ino;
> sb->st_ino = unp->unp_ino;
>
> with the broken out version
>
> if (unp->unp_ino == 0)
> if (++unp_ino == 0)
> unp->unp_ino = ++unp_ino;
> else
> unp->unp_ino = unp_ino;
> sb->st_ino = unp->unp_ino;
Well..
if (unp->unp_ino == 0) {
if (++unp_ino == 0)
++unp_ino;
unp->unp_ino = unp_ino;
}
sb->st_ino = unp->unp_ino;
>
> 3. Brevity
>
> The committed version is shorter.
True, true and true. Also, I'd just got back from vacation and my
sense of code hadn't really kicked in yet so i'd as soon leave it
as Hsu did it, it just sort of made my eyes bug out when i saw it
first because i kept thinking about the common example of the
pre/post increment screwup when passing arguments to functions like
printf.
--
-Alfred Perlstein [alfred@freebsd.org]
'Instead of asking why a piece of software is using "1970s technology,"
start asking why software is ignoring 30 years of accumulated wisdom.'
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021227200605.GS23663>
