From owner-cvs-all Wed Jan 2 7:53: 7 2002 Delivered-To: cvs-all@freebsd.org Received: from mail.rpi.edu (mail.rpi.edu [128.113.22.40]) by hub.freebsd.org (Postfix) with ESMTP id A767437B416; Wed, 2 Jan 2002 07:53:02 -0800 (PST) Received: from [128.113.24.47] (gilead.acs.rpi.edu [128.113.24.47]) by mail.rpi.edu (8.11.3/8.11.3) with ESMTP id g02Fqju32932; Wed, 2 Jan 2002 10:52:45 -0500 Mime-Version: 1.0 X-Sender: drosih@mail.rpi.edu Message-Id: In-Reply-To: <200201021440.g02Eess11512@dungeon.home> References: <20011231165233.A408@dhcp01.pn.xcllnt.net> <200201021440.g02Eess11512@dungeon.home> Date: Wed, 2 Jan 2002 10:52:44 -0500 To: Stephen McKay , Julian Elischer From: Garance A Drosihn Subject: Re: cvs commit: src/share/man/man3 queue.3 Cc: John Baldwin , Poul-Henning Kamp , cvs-all@FreeBSD.org, cvs-committers@FreeBSD.org, Julian Elischer , Greg Lehey , mckay@thehub.com.au Content-Type: text/plain; charset="us-ascii" ; format="flowed" X-Scanned-By: MIMEDefang 2.1 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 At 12:40 AM +1000 1/3/02, Stephen McKay wrote: >On Tuesday, 1st January 2002, Julian Elischer wrote: > > 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. :-) Perhaps I am missing something, but this issue seems pretty simple to me. What's wrong with: keyp = NULL; TAILQ_FOREACH(p, &list, p_next) { if (some_test_on(p)) { keyp = p; break; /* optional */ } } and then using 'keyp' outside the loop? -- Garance Alistair Drosehn = gad@eclipse.acs.rpi.edu Senior Systems Programmer or gad@freebsd.org Rensselaer Polytechnic Institute or drosih@rpi.edu To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message