From owner-cvs-all Wed Jan 2 9:40:25 2002 Delivered-To: cvs-all@freebsd.org Received: from rwcrmhc52.attbi.com (rwcrmhc52.attbi.com [216.148.227.88]) by hub.freebsd.org (Postfix) with ESMTP id DFC9037B439; Wed, 2 Jan 2002 09:40:08 -0800 (PST) Received: from InterJet.elischer.org ([12.232.206.8]) by rwcrmhc52.attbi.com (InterMail vM.4.01.03.27 201-229-121-127-20010626) with ESMTP id <20020102174008.HILR6450.rwcrmhc52.attbi.com@InterJet.elischer.org>; Wed, 2 Jan 2002 17:40:08 +0000 Received: from localhost (localhost.elischer.org [127.0.0.1]) by InterJet.elischer.org (8.9.1a/8.9.1) with ESMTP id JAA19233; Wed, 2 Jan 2002 09:34:06 -0800 (PST) Date: Wed, 2 Jan 2002 09:34:05 -0800 (PST) From: Julian Elischer To: Stephen McKay Cc: John Baldwin , Poul-Henning Kamp , cvs-all@FreeBSD.org, cvs-committers@FreeBSD.org, Julian Elischer , Greg Lehey Subject: Re: cvs commit: src/share/man/man3 queue.3 In-Reply-To: <200201021440.g02Eess11512@dungeon.home> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII 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 how about explicitly detailing that it's NULL at the end? Doesn't that also work? On Thu, 3 Jan 2002, Stephen McKay wrote: > 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