[ovs-dev] [PATCH] hmap: Add comment warning about pitfall in HMAP_FOR_EACH_* usage.
Ben Pfaff
blp at nicira.com
Mon Apr 6 21:39:06 UTC 2015
CC: Russell Bryant <rbryant at redhat.com>
Signed-off-by: Ben Pfaff <blp at nicira.com>
---
lib/hmap.h | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/lib/hmap.h b/lib/hmap.h
index 85241f0..6215be6 100644
--- a/lib/hmap.h
+++ b/lib/hmap.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2009, 2010, 2012, 2013 Nicira, Inc.
+ * Copyright (c) 2008, 2009, 2010, 2012, 2013, 2015 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -124,6 +124,16 @@ struct hmap_node *hmap_random_node(const struct hmap *);
* iteration).
*
* HASH is only evaluated once.
+ *
+ *
+ * Warning
+ * -------
+ *
+ * When the loop terminates, &NODE->MEMBER will equal NULL. Unless MEMBER is
+ * the first member in its struct, this means that NODE itself will not be
+ * NULL.
+ *
+ * (This is true for all of the HMAP_FOR_EACH_*() macros.)
*/
#define HMAP_FOR_EACH_WITH_HASH(NODE, MEMBER, HASH, HMAP) \
for (INIT_CONTAINER(NODE, hmap_first_with_hash(HMAP, HASH), MEMBER); \
--
1.7.10.4
More information about the dev
mailing list