From owner-cvs-all Mon Dec 31 12:40:18 2001 Delivered-To: cvs-all@freebsd.org Received: from mail11.speakeasy.net (mail11.speakeasy.net [216.254.0.211]) by hub.freebsd.org (Postfix) with ESMTP id 6D09C37B416 for ; Mon, 31 Dec 2001 12:39:25 -0800 (PST) Received: (qmail 2073 invoked from network); 31 Dec 2001 20:39:23 -0000 Received: from unknown (HELO laptop.baldwin.cx) ([64.81.54.73]) (envelope-sender ) by mail11.speakeasy.net (qmail-ldap-1.03) with SMTP for ; 31 Dec 2001 20:39:23 -0000 Message-ID: X-Mailer: XFMail 1.4.0 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 In-Reply-To: <21051.1009706416@critter.freebsd.dk> Date: Mon, 31 Dec 2001 12:39:12 -0800 (PST) From: John Baldwin To: Poul-Henning Kamp Subject: Re: cvs commit: src/share/man/man3 queue.3 Cc: cvs-all@FreeBSD.org, cvs-committers@FreeBSD.org, Julian Elischer , Greg Lehey 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 On 30-Dec-01 Poul-Henning Kamp wrote: > In message <20011230094936.K90696@monorchid.lemis.com>, Greg Lehey writes: >>On Saturday, 29 December 2001 at 8:55:05 +0100, Poul-Henning Kamp wrote: >>> In message <200112282200.fBSM0Rw61760@freefall.freebsd.org>, Julian >>> Elischer wr >>> ites: >>>> julian 2001/12/28 14:00:27 PST >>>> >>>> Modified files: >>>> share/man/man3 queue.3 >>>> Log: >>>> Document some behaviour I'm depending on. >>>> (TAILQ_FOREACH leaves the variable NULL if there were no more to do) >>> >>> I don't like this. >> >>Do you have a reason for not liking it? > > Yes, I don't like statements with weird sideeffects. If julian > wants the sideeffect, he should not use a _FOREACH() macro to hide > the internals of the loop. > > _FOREACH() is for the plain & simple traversal of a queue(3) stucture, > anything more should explicitly state intent. I would agree except for code like this: TAILQ_FOREACH(p, &list, p_next) if (some_test_on(p)) break; if (p != NULL) { /* Found one, now do something. */ } You could work around this via a goto instead I suppose: TAILQ_FOREACH(p, &list, p_next) if (some_test_on(p)) goto found; goto not_found found: /* Do something */ not_found: But that's uglier IMO. -- John Baldwin <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve!" - http://www.FreeBSD.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message