Date: 04 Jan 2002 22:07:58 +0100 From: Dag-Erling Smorgrav <des@ofug.org> To: "Justin T. Gibbs" <gibbs@scsiguy.com> Cc: Julian Elischer <julian@elischer.org>, Poul-Henning Kamp <phk@critter.freebsd.dk>, Stephen McKay <mckay@thehub.com.au>, John Baldwin <jhb@FreeBSD.org>, 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: <xzpy9jdn7td.fsf@flood.ping.uio.no> In-Reply-To: <200201041552.g04FqWg89682@aslan.scsiguy.com> References: <200201041552.g04FqWg89682@aslan.scsiguy.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--=-=-=
"Justin T. Gibbs" <gibbs@scsiguy.com> writes:
> Any foreach macro must test the termination condition. If we decided
> to define that the element pointer == NULL for a complete traversal, this
> would be at most a single assignment within the the termination
> conditional.
Like the attached patch, you mean?
DES
--
Dag-Erling Smorgrav - des@ofug.org
--=-=-=
Content-Type: text/x-patch
Content-Disposition: attachment; filename=circleq.diff
Index: queue.h
===================================================================
RCS file: /home/ncvs/src/sys/sys/queue.h,v
retrieving revision 1.32.2.6
diff -u -r1.32.2.6 queue.h
--- queue.h 18 Dec 2001 10:09:02 -0000 1.32.2.6
+++ queue.h 4 Jan 2002 21:06:41 -0000
@@ -439,12 +439,12 @@
#define CIRCLEQ_FOREACH(var, head, field) \
for ((var) = CIRCLEQ_FIRST((head)); \
- (var) != (void *)(head); \
+ (var) != (void *)(head) || ((var) = NULL); \
(var) = CIRCLEQ_NEXT((var), field))
#define CIRCLEQ_FOREACH_REVERSE(var, head, field) \
for ((var) = CIRCLEQ_LAST((head)); \
- (var) != (void *)(head); \
+ (var) != (void *)(head) || ((var) = NULL); \
(var) = CIRCLEQ_PREV((var), field))
#define CIRCLEQ_INIT(head) do { \
--=-=-=--
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?xzpy9jdn7td.fsf>
