Date: Mon, 31 Dec 2001 12:39:12 -0800 (PST) From: John Baldwin <jhb@FreeBSD.org> To: Poul-Henning Kamp <phk@critter.freebsd.dk> Cc: cvs-all@FreeBSD.org, cvs-committers@FreeBSD.org, Julian Elischer <julian@FreeBSD.org>, Greg Lehey <grog@FreeBSD.org> Subject: Re: cvs commit: src/share/man/man3 queue.3 Message-ID: <XFMail.011231123912.jhb@FreeBSD.org> In-Reply-To: <21051.1009706416@critter.freebsd.dk>
next in thread | previous in thread | raw e-mail | index | archive | help
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 <jhb@FreeBSD.org> <>< 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?XFMail.011231123912.jhb>