Date: Thu, 03 Jan 2002 00:40:54 +1000 From: Stephen McKay <mckay@thehub.com.au> To: Julian Elischer <julian@elischer.org> Cc: John Baldwin <jhb@FreeBSD.org>, Poul-Henning Kamp <phk@critter.freebsd.dk>, cvs-all@FreeBSD.org, cvs-committers@FreeBSD.org, Julian Elischer <julian@FreeBSD.org>, Greg Lehey <grog@FreeBSD.org>, mckay@thehub.com.au Subject: Re: cvs commit: src/share/man/man3 queue.3 Message-ID: <200201021440.g02Eess11512@dungeon.home> In-Reply-To: <Pine.BSF.4.21.0112311706450.10883-100000@InterJet.elischer.org> from Julian Elischer at "Tue, 01 Jan 2002 01:14:08 %2B0000" References: <20011231165233.A408@dhcp01.pn.xcllnt.net> <Pine.BSF.4.21.0112311706450.10883-100000@InterJet.elischer.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tuesday, 1st January 2002, Julian Elischer wrote: >> > TAILQ_FOREACH(p, &list, p_next) > >So you think that the final value of p should be undefined, >and there is no built in way to see if there were any elements in the >list at all or whether we completed the list? I'd have to say, "Yes". I expect p to be undefined when the TAILQ_FOREACH completes. It's an internal implementation detail. Similarly, I wouldn't depend on p == head for CIRCLEQ_FOREACH. You can roll your own loop if you want special behaviour. >I'm just documenting what the code does, and how people have used it. >if you think that phk is correct we should add an example to the man page >showing: Perhaps Marcel's good example instead: > TAILQ_FOREACH(p, &list, p_next) { > if (some_test_on(p)) { > /* Do something */ > break; /* optional */ > } > } The man page should explicitly state that p is undefined after the loop completes unless the user breaks out. Oh, and explicitly stating that it is OK to break out at all might be nice too. :-) Stephen. 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?200201021440.g02Eess11512>