From owner-cvs-all Fri Dec 27 12: 6:10 2002 Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5189E37B401; Fri, 27 Dec 2002 12:06:08 -0800 (PST) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7898C43EDC; Fri, 27 Dec 2002 12:06:05 -0800 (PST) (envelope-from bright@elvis.mu.org) Received: by elvis.mu.org (Postfix, from userid 1192) id 4ADEEAE28D; Fri, 27 Dec 2002 12:06:05 -0800 (PST) Date: Fri, 27 Dec 2002 12:06:05 -0800 From: Alfred Perlstein To: Jeffrey Hsu Cc: Matthew Dillon , 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> References: <200212271855.gBRItiIC057945@apollo.backplane.com> <0H7S0085YN2VDE@mta6.snfc21.pbi.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <0H7S0085YN2VDE@mta6.snfc21.pbi.net> User-Agent: Mutt/1.4i Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG * Jeffrey Hsu [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