[ovs-dev] [hmap 7/7] Switch many macros from using CONTAINER_OF to using OBJECT_CONTAINING.

Ben Pfaff blp at nicira.com
Mon Jul 19 21:05:39 UTC 2010


These macros require one fewer argument by switching, which makes code
that uses them shorter and more readable.
---
 lib/classifier.c           |   41 +++++++++++++--------------------
 lib/dpif-netdev.c          |   20 +++++++---------
 lib/hmap.h                 |   49 ++++++++++++++++++++--------------------
 lib/list.h                 |   24 ++++++++++----------
 lib/lockfile.c             |    4 +-
 lib/mac-learning.c         |    2 +-
 lib/netdev-linux.c         |   11 +++-----
 lib/netdev-vport.c         |    3 +-
 lib/netdev.c               |    2 +-
 lib/ovsdb-idl.c            |   38 +++++++++++--------------------
 lib/poll-loop.c            |    4 +-
 lib/process.c              |    2 +-
 lib/rtnetlink.c            |    8 ++----
 lib/shash.c                |    2 +-
 lib/shash.h                |    9 +++----
 lib/unixctl.c              |    8 ++----
 ofproto/ofproto-sflow.c    |    7 ++---
 ofproto/ofproto.c          |   53 ++++++++++++++++++++------------------------
 ofproto/status.c           |    5 +--
 ovsdb/file.c               |    2 +-
 ovsdb/jsonrpc-server.c     |   26 +++++++--------------
 ovsdb/ovsdb-server.c       |    4 +-
 ovsdb/query.c              |    8 ++----
 ovsdb/row.c                |   14 ++++-------
 ovsdb/table.c              |    6 +---
 ovsdb/transaction.c        |   20 ++++++----------
 ovsdb/trigger.c            |    4 +-
 tests/test-classifier.c    |    2 +-
 tests/test-hmap.c          |    9 +++----
 tests/test-list.c          |   10 ++++----
 tests/test-ovsdb.c         |    3 +-
 vswitchd/bridge.c          |   39 +++++++++++++++----------------
 vswitchd/proc-net-compat.c |    5 +--
 33 files changed, 191 insertions(+), 253 deletions(-)

diff --git a/lib/classifier.c b/lib/classifier.c
index 4bd8942..f5fc6b9 100644
--- a/lib/classifier.c
+++ b/lib/classifier.c
@@ -177,8 +177,7 @@ classifier_destroy(struct classifier *cls)
         struct hmap *tbl;
 
         for (tbl = &cls->tables[0]; tbl < &cls->tables[CLS_N_FIELDS]; tbl++) {
-            HMAP_FOR_EACH_SAFE (bucket, next_bucket,
-                                struct cls_bucket, hmap_node, tbl) {
+            HMAP_FOR_EACH_SAFE (bucket, next_bucket, hmap_node, tbl) {
                 free(bucket);
             }
             hmap_destroy(tbl);
@@ -335,11 +334,11 @@ classifier_find_rule_exactly(const struct classifier *cls,
     assert(wildcards == (wildcards & OVSFW_ALL));
     table_idx = table_idx_from_wildcards(wildcards);
     hash = hash_fields(target, table_idx);
-    HMAP_FOR_EACH_WITH_HASH (bucket, struct cls_bucket, hmap_node, hash,
+    HMAP_FOR_EACH_WITH_HASH (bucket, hmap_node, hash,
                              &cls->tables[table_idx]) {
         if (equal_fields(&bucket->fixed, target, table_idx)) {
             struct cls_rule *pos;
-            LIST_FOR_EACH (pos, struct cls_rule, node.list, &bucket->rules) {
+            LIST_FOR_EACH (pos, node.list, &bucket->rules) {
                 if (pos->priority < priority) {
                     return NULL;
                 } else if (pos->priority == priority &&
@@ -374,11 +373,10 @@ classifier_rule_overlaps(const struct classifier *cls,
     for (tbl = &cls->tables[0]; tbl < &cls->tables[CLS_N_FIELDS]; tbl++) {
         struct cls_bucket *bucket;
 
-        HMAP_FOR_EACH (bucket, struct cls_bucket, hmap_node, tbl) {
+        HMAP_FOR_EACH (bucket, hmap_node, tbl) {
             struct cls_rule *rule;
 
-            LIST_FOR_EACH (rule, struct cls_rule, node.list,
-                           &bucket->rules) {
+            LIST_FOR_EACH (rule, node.list, &bucket->rules) {
                 if (rule->priority == priority 
                         && rules_match_2wild(rule, &target_rule, 0)) {
                     return true;
@@ -409,8 +407,7 @@ classifier_for_each_match(const struct classifier *cls,
              table++) {
             struct cls_bucket *bucket, *next_bucket;
 
-            HMAP_FOR_EACH_SAFE (bucket, next_bucket,
-                                struct cls_bucket, hmap_node, table) {
+            HMAP_FOR_EACH_SAFE (bucket, next_bucket, hmap_node, table) {
                 /* XXX there is a bit of room for optimization here based on
                  * rejecting entire buckets on their fixed fields, but it will
                  * only be worthwhile for big buckets (which we hope we won't
@@ -422,8 +419,7 @@ classifier_for_each_match(const struct classifier *cls,
                  * bucket itself will be destroyed.  The bucket contains the
                  * list head so that's a use-after-free error. */
                 prev_rule = NULL;
-                LIST_FOR_EACH (rule, struct cls_rule, node.list,
-                               &bucket->rules) {
+                LIST_FOR_EACH (rule, node.list, &bucket->rules) {
                     if (rules_match_1wild(rule, target, 0)) {
                         if (prev_rule) {
                             callback(prev_rule, aux);
@@ -442,7 +438,7 @@ classifier_for_each_match(const struct classifier *cls,
         if (target->wc.wildcards) {
             struct cls_rule *rule, *next_rule;
 
-            HMAP_FOR_EACH_SAFE (rule, next_rule, struct cls_rule, node.hmap,
+            HMAP_FOR_EACH_SAFE (rule, next_rule, node.hmap,
                                 &cls->exact_table) {
                 if (rules_match_1wild(rule, target, 0)) {
                     callback(rule, aux);
@@ -477,8 +473,7 @@ classifier_for_each(const struct classifier *cls, int include,
         for (tbl = &cls->tables[0]; tbl < &cls->tables[CLS_N_FIELDS]; tbl++) {
             struct cls_bucket *bucket, *next_bucket;
 
-            HMAP_FOR_EACH_SAFE (bucket, next_bucket,
-                                struct cls_bucket, hmap_node, tbl) {
+            HMAP_FOR_EACH_SAFE (bucket, next_bucket, hmap_node, tbl) {
                 struct cls_rule *prev_rule, *rule;
 
                 /* We can't just use LIST_FOR_EACH_SAFE here because, if the
@@ -486,8 +481,7 @@ classifier_for_each(const struct classifier *cls, int include,
                  * bucket itself will be destroyed.  The bucket contains the
                  * list head so that's a use-after-free error. */
                 prev_rule = NULL;
-                LIST_FOR_EACH (rule, struct cls_rule, node.list,
-                               &bucket->rules) {
+                LIST_FOR_EACH (rule, node.list, &bucket->rules) {
                     if (prev_rule) {
                         callback(prev_rule, aux);
                     }
@@ -503,8 +497,7 @@ classifier_for_each(const struct classifier *cls, int include,
     if (include & CLS_INC_EXACT) {
         struct cls_rule *rule, *next_rule;
 
-        HMAP_FOR_EACH_SAFE (rule, next_rule,
-                            struct cls_rule, node.hmap, &cls->exact_table) {
+        HMAP_FOR_EACH_SAFE (rule, next_rule, node.hmap, &cls->exact_table) {
             callback(rule, aux);
         }
     }
@@ -641,7 +634,7 @@ static struct cls_rule *
 bucket_insert(struct cls_bucket *bucket, struct cls_rule *rule)
 {
     struct cls_rule *pos;
-    LIST_FOR_EACH (pos, struct cls_rule, node.list, &bucket->rules) {
+    LIST_FOR_EACH (pos, node.list, &bucket->rules) {
         if (pos->priority == rule->priority) {
             if (pos->wc.wildcards == rule->wc.wildcards
                 && rules_match_1wild(pos, rule, rule->table_idx))
@@ -679,8 +672,7 @@ static struct cls_bucket *
 find_bucket(struct hmap *table, size_t hash, const struct cls_rule *rule)
 {
     struct cls_bucket *bucket;
-    HMAP_FOR_EACH_WITH_HASH (bucket, struct cls_bucket, hmap_node, hash,
-                             table) {
+    HMAP_FOR_EACH_WITH_HASH (bucket, hmap_node, hash, table) {
         if (equal_fields(&bucket->fixed, &rule->flow, rule->table_idx)) {
             return bucket;
         }
@@ -850,7 +842,7 @@ search_bucket(struct cls_bucket *bucket, int field_idx,
         return NULL;
     }
 
-    LIST_FOR_EACH (pos, struct cls_rule, node.list, &bucket->rules) {
+    LIST_FOR_EACH (pos, node.list, &bucket->rules) {
         if (rules_match_1wild(target, pos, field_idx)) {
             return pos;
         }
@@ -878,7 +870,7 @@ search_table(const struct hmap *table, int field_idx,
         return search_bucket(bucket, field_idx, target);
     }
 
-    HMAP_FOR_EACH_WITH_HASH (bucket, struct cls_bucket, hmap_node,
+    HMAP_FOR_EACH_WITH_HASH (bucket, hmap_node,
                              hash_fields(&target->flow, field_idx), table) {
         struct cls_rule *rule = search_bucket(bucket, field_idx, target);
         if (rule) {
@@ -894,8 +886,7 @@ search_exact_table(const struct classifier *cls, size_t hash,
 {
     struct cls_rule *rule;
 
-    HMAP_FOR_EACH_WITH_HASH (rule, struct cls_rule, node.hmap,
-                             hash, &cls->exact_table) {
+    HMAP_FOR_EACH_WITH_HASH (rule, node.hmap, hash, &cls->exact_table) {
         if (flow_equal(&rule->flow, target)) {
             return rule;
         }
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index fa47d39..650b067 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -458,7 +458,7 @@ get_port_by_name(struct dp_netdev *dp,
 {
     struct dp_netdev_port *port;
 
-    LIST_FOR_EACH (port, struct dp_netdev_port, node, &dp->port_list) {
+    LIST_FOR_EACH (port, node, &dp->port_list) {
         if (!strcmp(netdev_get_name(port->netdev), devname)) {
             *portp = port;
             return 0;
@@ -546,8 +546,7 @@ dp_netdev_flow_flush(struct dp_netdev *dp)
 {
     struct dp_netdev_flow *flow, *next;
 
-    HMAP_FOR_EACH_SAFE (flow, next, struct dp_netdev_flow, node,
-                        &dp->flow_table) {
+    HMAP_FOR_EACH_SAFE (flow, next, node, &dp->flow_table) {
         dp_netdev_free_flow(dp, flow);
     }
 }
@@ -568,7 +567,7 @@ dpif_netdev_port_list(const struct dpif *dpif, struct odp_port *ports, int n)
     int i;
 
     i = 0;
-    LIST_FOR_EACH (port, struct dp_netdev_port, node, &dp->port_list) {
+    LIST_FOR_EACH (port, node, &dp->port_list) {
         struct odp_port *odp_port = &ports[i];
         if (i >= n) {
             break;
@@ -662,8 +661,7 @@ dp_netdev_lookup_flow(const struct dp_netdev *dp, const flow_t *key)
     struct dp_netdev_flow *flow;
 
     assert(!key->reserved[0] && !key->reserved[1] && !key->reserved[2]);
-    HMAP_FOR_EACH_WITH_HASH (flow, struct dp_netdev_flow, node,
-                             flow_hash(key, 0), &dp->flow_table) {
+    HMAP_FOR_EACH_WITH_HASH (flow, node, flow_hash(key, 0), &dp->flow_table) {
         if (flow_equal(&flow->key, key)) {
             return flow;
         }
@@ -888,7 +886,7 @@ dpif_netdev_flow_list(const struct dpif *dpif, struct odp_flow flows[], int n)
     int i;
 
     i = 0;
-    HMAP_FOR_EACH (flow, struct dp_netdev_flow, node, &dp->flow_table) {
+    HMAP_FOR_EACH (flow, node, &dp->flow_table) {
         if (i >= n) {
             break;
         }
@@ -1048,10 +1046,10 @@ dp_netdev_run(void)
     struct dp_netdev *dp;
 
     ofpbuf_init(&packet, DP_NETDEV_HEADROOM + max_mtu);
-    LIST_FOR_EACH (dp, struct dp_netdev, node, &dp_netdev_list) {
+    LIST_FOR_EACH (dp, node, &dp_netdev_list) {
         struct dp_netdev_port *port;
 
-        LIST_FOR_EACH (port, struct dp_netdev_port, node, &dp->port_list) {
+        LIST_FOR_EACH (port, node, &dp->port_list) {
             int error;
 
             /* Reset packet contents. */
@@ -1076,9 +1074,9 @@ dp_netdev_wait(void)
 {
     struct dp_netdev *dp;
 
-    LIST_FOR_EACH (dp, struct dp_netdev, node, &dp_netdev_list) {
+    LIST_FOR_EACH (dp, node, &dp_netdev_list) {
         struct dp_netdev_port *port;
-        LIST_FOR_EACH (port, struct dp_netdev_port, node, &dp->port_list) {
+        LIST_FOR_EACH (port, node, &dp->port_list) {
             netdev_recv_wait(port->netdev);
         }
     }
diff --git a/lib/hmap.h b/lib/hmap.h
index eb9df7d..7a95413 100644
--- a/lib/hmap.h
+++ b/lib/hmap.h
@@ -94,9 +94,8 @@ static inline void hmap_replace(struct hmap *, const struct hmap_node *old,
  *
  * HMAP_FOR_EACH_WITH_HASH iterates NODE over all of the nodes in HMAP that
  * have hash value equal to HASH.  HMAP_FOR_EACH_IN_BUCKET iterates NODE over
- * all of the nodes in HMAP that would fall in the same bucket as HASH.  STRUCT
- * and MEMBER must be the name of the struct that contains the 'struct
- * hmap_node' and the name of the 'struct hmap_node' member, respectively.
+ * all of the nodes in HMAP that would fall in the same bucket as HASH.  MEMBER
+ * must be the name of the 'struct hmap_node' member within NODE.
  *
  * These macros may be used interchangeably to search for a particular value in
  * an hmap, see, e.g. shash_find() for an example.  Usually, using
@@ -111,18 +110,18 @@ static inline void hmap_replace(struct hmap *, const struct hmap_node *old,
  *
  * HASH is only evaluated once.
  */
-#define HMAP_FOR_EACH_WITH_HASH(NODE, STRUCT, MEMBER, HASH, HMAP)       \
-    for ((NODE) = CONTAINER_OF(hmap_first_with_hash(HMAP, HASH),        \
-                               STRUCT, MEMBER);                         \
+#define HMAP_FOR_EACH_WITH_HASH(NODE, MEMBER, HASH, HMAP)               \
+    for ((NODE) = OBJECT_CONTAINING(hmap_first_with_hash(HMAP, HASH),   \
+                                  NODE, MEMBER);                        \
          &(NODE)->MEMBER != NULL;                                       \
-         (NODE) = CONTAINER_OF(hmap_next_with_hash(&(NODE)->MEMBER),    \
-                               STRUCT, MEMBER))
-#define HMAP_FOR_EACH_IN_BUCKET(NODE, STRUCT, MEMBER, HASH, HMAP)       \
-    for ((NODE) = CONTAINER_OF(hmap_first_in_bucket(HMAP, HASH),        \
-                               STRUCT, MEMBER);                         \
+         (NODE) = OBJECT_CONTAINING(hmap_next_with_hash(&(NODE)->MEMBER), \
+                                  NODE, MEMBER))
+#define HMAP_FOR_EACH_IN_BUCKET(NODE, MEMBER, HASH, HMAP)               \
+    for ((NODE) = OBJECT_CONTAINING(hmap_first_in_bucket(HMAP, HASH),   \
+                                  NODE, MEMBER);                        \
          &(NODE)->MEMBER != NULL;                                       \
-         (NODE) = CONTAINER_OF(hmap_next_in_bucket(&(NODE)->MEMBER),    \
-                               STRUCT, MEMBER))
+         (NODE) = OBJECT_CONTAINING(hmap_next_in_bucket(&(NODE)->MEMBER), \
+                               NODE, MEMBER))
 
 static inline struct hmap_node *hmap_first_with_hash(const struct hmap *,
                                                      size_t hash);
@@ -136,18 +135,18 @@ static inline struct hmap_node *hmap_next_in_bucket(const struct hmap_node *);
  * The _SAFE version is needed when NODE may be freed.  It is not needed when
  * NODE may be removed from the hash map but its members remain accessible and
  * intact. */
-#define HMAP_FOR_EACH(NODE, STRUCT, MEMBER, HMAP)                   \
-    for ((NODE) = CONTAINER_OF(hmap_first(HMAP), STRUCT, MEMBER);   \
-         &(NODE)->MEMBER != NULL;                                   \
-         (NODE) = CONTAINER_OF(hmap_next(HMAP, &(NODE)->MEMBER),    \
-                               STRUCT, MEMBER))
-
-#define HMAP_FOR_EACH_SAFE(NODE, NEXT, STRUCT, MEMBER, HMAP)        \
-    for ((NODE) = CONTAINER_OF(hmap_first(HMAP), STRUCT, MEMBER);   \
-         (&(NODE)->MEMBER != NULL                                   \
-          ? (NEXT) = CONTAINER_OF(hmap_next(HMAP, &(NODE)->MEMBER), \
-                                  STRUCT, MEMBER), 1                \
-          : 0);                                                     \
+#define HMAP_FOR_EACH(NODE, MEMBER, HMAP)                               \
+    for ((NODE) = OBJECT_CONTAINING(hmap_first(HMAP), NODE, MEMBER);    \
+         &(NODE)->MEMBER != NULL;                                       \
+         (NODE) = OBJECT_CONTAINING(hmap_next(HMAP, &(NODE)->MEMBER),   \
+                                    NODE, MEMBER))
+
+#define HMAP_FOR_EACH_SAFE(NODE, NEXT, MEMBER, HMAP)                    \
+    for ((NODE) = OBJECT_CONTAINING(hmap_first(HMAP), NODE, MEMBER);    \
+         (&(NODE)->MEMBER != NULL                                       \
+          ? (NEXT) = OBJECT_CONTAINING(hmap_next(HMAP, &(NODE)->MEMBER), \
+                                       NODE, MEMBER), 1                 \
+          : 0);                                                         \
          (NODE) = (NEXT))
 
 static inline struct hmap_node *hmap_first(const struct hmap *);
diff --git a/lib/list.h b/lib/list.h
index 845aab2..0481477 100644
--- a/lib/list.h
+++ b/lib/list.h
@@ -53,18 +53,18 @@ struct list *list_back(struct list *);
 size_t list_size(const struct list *);
 bool list_is_empty(const struct list *);
 
-#define LIST_FOR_EACH(ITER, STRUCT, MEMBER, LIST)                   \
-    for (ITER = CONTAINER_OF((LIST)->next, STRUCT, MEMBER);         \
-         &(ITER)->MEMBER != (LIST);                                 \
-         ITER = CONTAINER_OF((ITER)->MEMBER.next, STRUCT, MEMBER))
-#define LIST_FOR_EACH_REVERSE(ITER, STRUCT, MEMBER, LIST)           \
-    for (ITER = CONTAINER_OF((LIST)->prev, STRUCT, MEMBER);         \
-         &(ITER)->MEMBER != (LIST);                                 \
-         ITER = CONTAINER_OF((ITER)->MEMBER.prev, STRUCT, MEMBER))
-#define LIST_FOR_EACH_SAFE(ITER, NEXT, STRUCT, MEMBER, LIST)        \
-    for (ITER = CONTAINER_OF((LIST)->next, STRUCT, MEMBER);         \
-         (NEXT = CONTAINER_OF((ITER)->MEMBER.next, STRUCT, MEMBER), \
-          &(ITER)->MEMBER != (LIST));                               \
+#define LIST_FOR_EACH(ITER, MEMBER, LIST)                               \
+    for (ITER = OBJECT_CONTAINING((LIST)->next, ITER, MEMBER);          \
+         &(ITER)->MEMBER != (LIST);                                     \
+         ITER = OBJECT_CONTAINING((ITER)->MEMBER.next, ITER, MEMBER))
+#define LIST_FOR_EACH_REVERSE(ITER, MEMBER, LIST)                       \
+    for (ITER = OBJECT_CONTAINING((LIST)->prev, ITER, MEMBER);          \
+         &(ITER)->MEMBER != (LIST);                                     \
+         ITER = OBJECT_CONTAINING((ITER)->MEMBER.prev, ITER, MEMBER))
+#define LIST_FOR_EACH_SAFE(ITER, NEXT, MEMBER, LIST)                    \
+    for (ITER = OBJECT_CONTAINING((LIST)->next, ITER, MEMBER);          \
+         (NEXT = OBJECT_CONTAINING((ITER)->MEMBER.next, ITER, MEMBER),  \
+          &(ITER)->MEMBER != (LIST));                                   \
          ITER = NEXT)
 
 #endif /* list.h */
diff --git a/lib/lockfile.c b/lib/lockfile.c
index 100440e..40ecabd 100644
--- a/lib/lockfile.c
+++ b/lib/lockfile.c
@@ -151,7 +151,7 @@ lockfile_postfork(void)
 {
     struct lockfile *lockfile;
 
-    HMAP_FOR_EACH (lockfile, struct lockfile, hmap_node, &lock_table) {
+    HMAP_FOR_EACH (lockfile, hmap_node, &lock_table) {
         if (lockfile->fd >= 0) {
             VLOG_WARN("%s: child does not inherit lock", lockfile->name);
             lockfile_unhash(lockfile);
@@ -171,7 +171,7 @@ lockfile_find(dev_t device, ino_t inode)
 {
     struct lockfile *lockfile;
 
-    HMAP_FOR_EACH_WITH_HASH (lockfile, struct lockfile, hmap_node,
+    HMAP_FOR_EACH_WITH_HASH (lockfile, hmap_node,
                              lockfile_hash(device, inode), &lock_table) {
         if (lockfile->device == device && lockfile->inode == inode) {
             return lockfile;
diff --git a/lib/mac-learning.c b/lib/mac-learning.c
index 5d64f54..b8cfc3d 100644
--- a/lib/mac-learning.c
+++ b/lib/mac-learning.c
@@ -79,7 +79,7 @@ search_bucket(struct list *bucket, const uint8_t mac[ETH_ADDR_LEN],
               uint16_t vlan)
 {
     struct mac_entry *e;
-    LIST_FOR_EACH (e, struct mac_entry, hash_node, bucket) {
+    LIST_FOR_EACH (e, hash_node, bucket) {
         if (eth_addr_equals(e->mac, mac) && e->vlan == vlan) {
             return e;
         }
diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c
index dc3858c..e344f4d 100644
--- a/lib/netdev-linux.c
+++ b/lib/netdev-linux.c
@@ -1484,8 +1484,7 @@ tc_find_queue__(const struct netdev *netdev, unsigned int queue_id,
                                 netdev_dev_linux_cast(netdev_get_dev(netdev));
     struct tc_queue *queue;
 
-    HMAP_FOR_EACH_IN_BUCKET (queue, struct tc_queue, hmap_node,
-                             hash, &netdev_dev->tc->queues) {
+    HMAP_FOR_EACH_IN_BUCKET (queue, hmap_node, hash, &netdev_dev->tc->queues) {
         if (queue->queue_id == queue_id) {
             return queue;
         }
@@ -1680,8 +1679,7 @@ netdev_linux_dump_queues(const struct netdev *netdev,
 
     last_error = 0;
     shash_init(&details);
-    HMAP_FOR_EACH (queue, struct tc_queue, hmap_node,
-                   &netdev_dev->tc->queues) {
+    HMAP_FOR_EACH (queue, hmap_node, &netdev_dev->tc->queues) {
         shash_clear(&details);
 
         error = netdev_dev->tc->ops->class_get(netdev, queue, &details);
@@ -2013,7 +2011,7 @@ static void
 poll_notify(struct list *list)
 {
     struct netdev_linux_notifier *notifier;
-    LIST_FOR_EACH (notifier, struct netdev_linux_notifier, node, list) {
+    LIST_FOR_EACH (notifier, node, list) {
         struct netdev_notifier *n = &notifier->notifier;
         n->cb(n);
     }
@@ -2550,8 +2548,7 @@ htb_tc_destroy(struct tc *tc)
     struct htb *htb = CONTAINER_OF(tc, struct htb, tc);
     struct htb_class *hc, *next;
 
-    HMAP_FOR_EACH_SAFE (hc, next, struct htb_class, tc_queue.hmap_node,
-                        &htb->tc.queues) {
+    HMAP_FOR_EACH_SAFE (hc, next, tc_queue.hmap_node, &htb->tc.queues) {
         hmap_remove(&htb->tc.queues, &hc->tc_queue.hmap_node);
         free(hc);
     }
diff --git a/lib/netdev-vport.c b/lib/netdev-vport.c
index 58858f9..7916ea5 100644
--- a/lib/netdev-vport.c
+++ b/lib/netdev-vport.c
@@ -269,8 +269,7 @@ netdev_vport_poll_notify(const struct netdev *netdev)
     if (list) {
         struct netdev_vport_notifier *notifier;
 
-        LIST_FOR_EACH (notifier, struct netdev_vport_notifier,
-                       list_node, list) {
+        LIST_FOR_EACH (notifier, list_node, list) {
             struct netdev_notifier *n = &notifier->notifier;
             n->cb(n);
         }
diff --git a/lib/netdev.c b/lib/netdev.c
index 38f4dd5..dda1aa5 100644
--- a/lib/netdev.c
+++ b/lib/netdev.c
@@ -1594,7 +1594,7 @@ static void
 close_all_netdevs(void *aux OVS_UNUSED)
 {
     struct netdev *netdev, *next;
-    LIST_FOR_EACH_SAFE(netdev, next, struct netdev, node, &netdev_list) {
+    LIST_FOR_EACH_SAFE(netdev, next, node, &netdev_list) {
         netdev_close(netdev);
     }
 }
diff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c
index f32fe0e..19d351b 100644
--- a/lib/ovsdb-idl.c
+++ b/lib/ovsdb-idl.c
@@ -212,15 +212,13 @@ ovsdb_idl_clear(struct ovsdb_idl *idl)
         }
 
         changed = true;
-        HMAP_FOR_EACH_SAFE (row, next_row, struct ovsdb_idl_row, hmap_node,
-                            &table->rows) {
+        HMAP_FOR_EACH_SAFE (row, next_row, hmap_node, &table->rows) {
             struct ovsdb_idl_arc *arc, *next_arc;
 
             if (!ovsdb_idl_row_is_orphan(row)) {
                 ovsdb_idl_row_unparse(row);
             }
-            LIST_FOR_EACH_SAFE (arc, next_arc, struct ovsdb_idl_arc, src_node,
-                                &row->src_arcs) {
+            LIST_FOR_EACH_SAFE (arc, next_arc, src_node, &row->src_arcs) {
                 free(arc);
             }
             /* No need to do anything with dst_arcs: some node has those arcs
@@ -490,8 +488,7 @@ ovsdb_idl_get_row(struct ovsdb_idl_table *table, const struct uuid *uuid)
 {
     struct ovsdb_idl_row *row;
 
-    HMAP_FOR_EACH_WITH_HASH (row, struct ovsdb_idl_row, hmap_node,
-                             uuid_hash(uuid), &table->rows) {
+    HMAP_FOR_EACH_WITH_HASH (row, hmap_node, uuid_hash(uuid), &table->rows) {
         if (uuid_equals(&row->uuid, uuid)) {
             return row;
         }
@@ -688,8 +685,7 @@ ovsdb_idl_row_clear_arcs(struct ovsdb_idl_row *row, bool destroy_dsts)
 
     /* Delete all forward arcs.  If 'destroy_dsts', destroy any orphaned rows
      * that this causes to be unreferenced. */
-    LIST_FOR_EACH_SAFE (arc, next, struct ovsdb_idl_arc, src_node,
-                        &row->src_arcs) {
+    LIST_FOR_EACH_SAFE (arc, next, src_node, &row->src_arcs) {
         list_remove(&arc->dst_node);
         if (destroy_dsts
             && ovsdb_idl_row_is_orphan(arc->dst)
@@ -717,8 +713,7 @@ ovsdb_idl_row_reparse_backrefs(struct ovsdb_idl_row *row)
      * (If duplicate arcs were possible then we would need to make sure that
      * 'next' didn't also point into 'arc''s destination, but we forbid
      * duplicate arcs.) */
-    LIST_FOR_EACH_SAFE (arc, next, struct ovsdb_idl_arc, dst_node,
-                        &row->dst_arcs) {
+    LIST_FOR_EACH_SAFE (arc, next, dst_node, &row->dst_arcs) {
         struct ovsdb_idl_row *ref = arc->src;
 
         ovsdb_idl_row_unparse(ref);
@@ -1056,8 +1051,7 @@ ovsdb_idl_txn_destroy(struct ovsdb_idl_txn *txn)
     free(txn->inc_table);
     free(txn->inc_column);
     json_destroy(txn->inc_where);
-    HMAP_FOR_EACH_SAFE (insert, next, struct ovsdb_idl_txn_insert, hmap_node,
-                        &txn->inserted_rows) {
+    HMAP_FOR_EACH_SAFE (insert, next, hmap_node, &txn->inserted_rows) {
         free(insert);
     }
     hmap_destroy(&txn->inserted_rows);
@@ -1107,8 +1101,7 @@ ovsdb_idl_txn_get_row(const struct ovsdb_idl_txn *txn, const struct uuid *uuid)
 {
     const struct ovsdb_idl_row *row;
 
-    HMAP_FOR_EACH_WITH_HASH (row, struct ovsdb_idl_row, txn_node,
-                             uuid_hash(uuid), &txn->txn_rows) {
+    HMAP_FOR_EACH_WITH_HASH (row, txn_node, uuid_hash(uuid), &txn->txn_rows) {
         if (uuid_equals(&row->uuid, uuid)) {
             return row;
         }
@@ -1166,8 +1159,7 @@ ovsdb_idl_txn_disassemble(struct ovsdb_idl_txn *txn)
      * transaction and fail to update the graph.  */
     txn->idl->txn = NULL;
 
-    HMAP_FOR_EACH_SAFE (row, next, struct ovsdb_idl_row, txn_node,
-                        &txn->txn_rows) {
+    HMAP_FOR_EACH_SAFE (row, next, txn_node, &txn->txn_rows) {
         if (row->old) {
             if (row->written) {
                 ovsdb_idl_row_unparse(row);
@@ -1211,7 +1203,7 @@ ovsdb_idl_txn_commit(struct ovsdb_idl_txn *txn)
         json_string_create(txn->idl->class->database));
 
     /* Add prerequisites and declarations of new rows. */
-    HMAP_FOR_EACH (row, struct ovsdb_idl_row, txn_node, &txn->txn_rows) {
+    HMAP_FOR_EACH (row, txn_node, &txn->txn_rows) {
         /* XXX check that deleted rows exist even if no prereqs? */
         if (row->prereqs) {
             const struct ovsdb_idl_table_class *class = row->table->class;
@@ -1243,7 +1235,7 @@ ovsdb_idl_txn_commit(struct ovsdb_idl_txn *txn)
 
     /* Add updates. */
     any_updates = false;
-    HMAP_FOR_EACH (row, struct ovsdb_idl_row, txn_node, &txn->txn_rows) {
+    HMAP_FOR_EACH (row, txn_node, &txn->txn_rows) {
         const struct ovsdb_idl_table_class *class = row->table->class;
 
         if (row->old == row->new) {
@@ -1441,7 +1433,7 @@ ovsdb_idl_txn_get_insert_uuid(const struct ovsdb_idl_txn *txn,
     const struct ovsdb_idl_txn_insert *insert;
 
     assert(txn->status == TXN_SUCCESS || txn->status == TXN_UNCHANGED);
-    HMAP_FOR_EACH_IN_BUCKET (insert, struct ovsdb_idl_txn_insert, hmap_node,
+    HMAP_FOR_EACH_IN_BUCKET (insert, hmap_node,
                              uuid_hash(uuid), &txn->inserted_rows) {
         if (uuid_equals(uuid, &insert->dummy)) {
             return &insert->real;
@@ -1562,8 +1554,7 @@ ovsdb_idl_txn_abort_all(struct ovsdb_idl *idl)
 {
     struct ovsdb_idl_txn *txn;
 
-    HMAP_FOR_EACH (txn, struct ovsdb_idl_txn, hmap_node,
-                   &idl->outstanding_txns) {
+    HMAP_FOR_EACH (txn, hmap_node, &idl->outstanding_txns) {
         ovsdb_idl_txn_complete(txn, TXN_TRY_AGAIN);
     }
 }
@@ -1573,7 +1564,7 @@ ovsdb_idl_txn_find(struct ovsdb_idl *idl, const struct json *id)
 {
     struct ovsdb_idl_txn *txn;
 
-    HMAP_FOR_EACH_WITH_HASH (txn, struct ovsdb_idl_txn, hmap_node,
+    HMAP_FOR_EACH_WITH_HASH (txn, hmap_node,
                              json_hash(id, 0), &idl->outstanding_txns) {
         if (json_equal(id, txn->request_id)) {
             return txn;
@@ -1753,8 +1744,7 @@ ovsdb_idl_txn_process_reply(struct ovsdb_idl *idl,
                 hard_errors++;
             }
 
-            HMAP_FOR_EACH (insert, struct ovsdb_idl_txn_insert, hmap_node,
-                           &txn->inserted_rows) {
+            HMAP_FOR_EACH (insert, hmap_node, &txn->inserted_rows) {
                 if (!ovsdb_idl_txn_process_insert_reply(insert, ops)) {
                     hard_errors++;
                 }
diff --git a/lib/poll-loop.c b/lib/poll-loop.c
index 91034b0..6b485e8 100644
--- a/lib/poll-loop.c
+++ b/lib/poll-loop.c
@@ -171,7 +171,7 @@ poll_block(void)
     }
 
     n_pollfds = 0;
-    LIST_FOR_EACH (pw, struct poll_waiter, node, &waiters) {
+    LIST_FOR_EACH (pw, node, &waiters) {
         pw->pollfd = &pollfds[n_pollfds];
         pollfds[n_pollfds].fd = pw->fd;
         pollfds[n_pollfds].events = pw->events;
@@ -190,7 +190,7 @@ poll_block(void)
         log_wakeup(&timeout_backtrace, "%d-ms timeout", timeout);
     }
 
-    LIST_FOR_EACH_SAFE (pw, next, struct poll_waiter, node, &waiters) {
+    LIST_FOR_EACH_SAFE (pw, next, node, &waiters) {
         if (pw->pollfd->revents && VLOG_IS_DBG_ENABLED()) {
             log_wakeup(pw->backtrace, "%s%s%s%s%s on fd %d",
                        pw->pollfd->revents & POLLIN ? "[POLLIN]" : "",
diff --git a/lib/process.c b/lib/process.c
index af867ef..0636502 100644
--- a/lib/process.c
+++ b/lib/process.c
@@ -590,7 +590,7 @@ sigchld_handler(int signr OVS_UNUSED)
     struct process *p;
 
     COVERAGE_INC(process_sigchld);
-    LIST_FOR_EACH (p, struct process, node, &all_processes) {
+    LIST_FOR_EACH (p, node, &all_processes) {
         if (!p->exited) {
             int retval, status;
             do {
diff --git a/lib/rtnetlink.c b/lib/rtnetlink.c
index 1d302ea..b4e2a8c 100644
--- a/lib/rtnetlink.c
+++ b/lib/rtnetlink.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009 Nicira Networks.
+ * Copyright (c) 2009, 2010 Nicira Networks.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -166,8 +166,7 @@ rtnetlink_report_change(const struct nlmsghdr *nlmsg,
     change.master_ifindex = (attrs[IFLA_MASTER]
                              ? nl_attr_get_u32(attrs[IFLA_MASTER]) : 0);
 
-    LIST_FOR_EACH (notifier, struct rtnetlink_notifier, node,
-                   &all_notifiers) {
+    LIST_FOR_EACH (notifier, node, &all_notifiers) {
         notifier->cb(&change, notifier->aux);
     }
 }
@@ -177,8 +176,7 @@ rtnetlink_report_notify_error(void)
 {
     struct rtnetlink_notifier *notifier;
 
-    LIST_FOR_EACH (notifier, struct rtnetlink_notifier, node,
-                   &all_notifiers) {
+    LIST_FOR_EACH (notifier, node, &all_notifiers) {
         notifier->cb(NULL, notifier->aux);
     }
 }
diff --git a/lib/shash.c b/lib/shash.c
index 1664baf..ef8d33c 100644
--- a/lib/shash.c
+++ b/lib/shash.c
@@ -180,7 +180,7 @@ shash_find__(const struct shash *sh, const char *name, size_t hash)
 {
     struct shash_node *node;
 
-    HMAP_FOR_EACH_WITH_HASH (node, struct shash_node, node, hash, &sh->map) {
+    HMAP_FOR_EACH_WITH_HASH (node, node, hash, &sh->map) {
         if (!strcmp(node->name, name)) {
             return node;
         }
diff --git a/lib/shash.h b/lib/shash.h
index 19e4c5d..2f8dcfd 100644
--- a/lib/shash.h
+++ b/lib/shash.h
@@ -35,12 +35,11 @@ struct shash {
 
 #define SHASH_INITIALIZER(SHASH) { HMAP_INITIALIZER(&(SHASH)->map) }
 
-#define SHASH_FOR_EACH(SHASH_NODE, SHASH)                               \
-    HMAP_FOR_EACH (SHASH_NODE, struct shash_node, node, &(SHASH)->map)
+#define SHASH_FOR_EACH(SHASH_NODE, SHASH) \
+    HMAP_FOR_EACH (SHASH_NODE, node, &(SHASH)->map)
 
-#define SHASH_FOR_EACH_SAFE(SHASH_NODE, NEXT, SHASH)                \
-    HMAP_FOR_EACH_SAFE (SHASH_NODE, NEXT, struct shash_node, node,  \
-                        &(SHASH)->map)
+#define SHASH_FOR_EACH_SAFE(SHASH_NODE, NEXT, SHASH) \
+    HMAP_FOR_EACH_SAFE (SHASH_NODE, NEXT, node, &(SHASH)->map)
 
 void shash_init(struct shash *);
 void shash_destroy(struct shash *);
diff --git a/lib/unixctl.c b/lib/unixctl.c
index 7078568..cc5f88c 100644
--- a/lib/unixctl.c
+++ b/lib/unixctl.c
@@ -411,8 +411,7 @@ unixctl_server_run(struct unixctl_server *server)
         new_connection(server, fd);
     }
 
-    LIST_FOR_EACH_SAFE (conn, next,
-                        struct unixctl_conn, node, &server->conns) {
+    LIST_FOR_EACH_SAFE (conn, next, node, &server->conns) {
         int error = run_connection(conn);
         if (error && error != EAGAIN) {
             kill_connection(conn);
@@ -426,7 +425,7 @@ unixctl_server_wait(struct unixctl_server *server)
     struct unixctl_conn *conn;
 
     poll_fd_wait(server->fd, POLLIN);
-    LIST_FOR_EACH (conn, struct unixctl_conn, node, &server->conns) {
+    LIST_FOR_EACH (conn, node, &server->conns) {
         if (conn->state == S_RECV) {
             poll_fd_wait(conn->fd, POLLIN);
         } else if (conn->state == S_SEND) {
@@ -442,8 +441,7 @@ unixctl_server_destroy(struct unixctl_server *server)
     if (server) {
         struct unixctl_conn *conn, *next;
 
-        LIST_FOR_EACH_SAFE (conn, next,
-                            struct unixctl_conn, node, &server->conns) {
+        LIST_FOR_EACH_SAFE (conn, next, node, &server->conns) {
             kill_connection(conn);
         }
 
diff --git a/ofproto/ofproto-sflow.c b/ofproto/ofproto-sflow.c
index 8d16370..ce93a55 100644
--- a/ofproto/ofproto-sflow.c
+++ b/ofproto/ofproto-sflow.c
@@ -140,7 +140,7 @@ ofproto_sflow_find_port(const struct ofproto_sflow *os, uint16_t odp_port)
 {
     struct ofproto_sflow_port *osp;
 
-    HMAP_FOR_EACH_IN_BUCKET (osp, struct ofproto_sflow_port, hmap_node,
+    HMAP_FOR_EACH_IN_BUCKET (osp, hmap_node,
                              hash_int(odp_port, 0), &os->ports) {
         if (osp->odp_port == odp_port) {
             return osp;
@@ -297,8 +297,7 @@ ofproto_sflow_destroy(struct ofproto_sflow *os)
         struct ofproto_sflow_port *osp, *next;
 
         ofproto_sflow_clear(os);
-        HMAP_FOR_EACH_SAFE (osp, next, struct ofproto_sflow_port, hmap_node,
-                            &os->ports) {
+        HMAP_FOR_EACH_SAFE (osp, next, hmap_node, &os->ports) {
             ofproto_sflow_del_port__(os, osp);
         }
         hmap_destroy(&os->ports);
@@ -463,7 +462,7 @@ ofproto_sflow_set_options(struct ofproto_sflow *os,
                                MAX(1, UINT32_MAX / options->sampling_rate));
 
     /* Add samplers and pollers for the currently known ports. */
-    HMAP_FOR_EACH (osp, struct ofproto_sflow_port, hmap_node, &os->ports) {
+    HMAP_FOR_EACH (osp, hmap_node, &os->ports) {
         ofproto_sflow_add_poller(os, osp, osp->odp_port);
         ofproto_sflow_add_sampler(os, osp);
     }
diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index 48eeb1c..2a00fa2 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -525,7 +525,7 @@ find_controller_by_target(struct ofproto *ofproto, const char *target)
 {
     struct ofconn *ofconn;
 
-    HMAP_FOR_EACH_WITH_HASH (ofconn, struct ofconn, hmap_node,
+    HMAP_FOR_EACH_WITH_HASH (ofconn, hmap_node,
                              hash_string(target, 0), &ofproto->controllers) {
         if (!strcmp(ofconn_get_target(ofconn), target)) {
             return ofconn;
@@ -550,7 +550,7 @@ update_in_band_remotes(struct ofproto *ofproto)
 
     /* Add all the remotes. */
     discovery = false;
-    HMAP_FOR_EACH (ofconn, struct ofconn, hmap_node, &ofproto->controllers) {
+    HMAP_FOR_EACH (ofconn, hmap_node, &ofproto->controllers) {
         struct sockaddr_in *sin = &addrs[n_addrs];
 
         if (ofconn->band == OFPROTO_OUT_OF_BAND) {
@@ -616,8 +616,7 @@ ofproto_set_controllers(struct ofproto *p,
 
     fail_mode = OFPROTO_FAIL_STANDALONE;
     ss_exists = false;
-    HMAP_FOR_EACH_SAFE (ofconn, next, struct ofconn, hmap_node,
-                        &p->controllers) {
+    HMAP_FOR_EACH_SAFE (ofconn, next, hmap_node, &p->controllers) {
         struct ofproto_controller *c;
 
         c = shash_find_data(&new_controllers, ofconn_get_target(ofconn));
@@ -648,7 +647,7 @@ ofproto_set_controllers(struct ofproto *p,
 
         n = 0;
         rconns = xmalloc(hmap_count(&p->controllers) * sizeof *rconns);
-        HMAP_FOR_EACH (ofconn, struct ofconn, hmap_node, &p->controllers) {
+        HMAP_FOR_EACH (ofconn, hmap_node, &p->controllers) {
             rconns[n++] = ofconn->rconn;
         }
 
@@ -674,7 +673,7 @@ ofproto_reconnect_controllers(struct ofproto *ofproto)
 {
     struct ofconn *ofconn;
 
-    LIST_FOR_EACH (ofconn, struct ofconn, node, &ofproto->all_conns) {
+    LIST_FOR_EACH (ofconn, node, &ofproto->all_conns) {
         rconn_reconnect(ofconn->rconn);
     }
 }
@@ -848,7 +847,7 @@ ofproto_set_sflow(struct ofproto *ofproto,
 
             os = ofproto->sflow = ofproto_sflow_create(ofproto->dpif);
             refresh_port_groups(ofproto);
-            HMAP_FOR_EACH (ofport, struct ofport, hmap_node, &ofproto->ports) {
+            HMAP_FOR_EACH (ofport, hmap_node, &ofproto->ports) {
                 ofproto_sflow_add_port(os, ofport->odp_port,
                                        netdev_get_name(ofport->netdev));
             }
@@ -926,16 +925,14 @@ ofproto_destroy(struct ofproto *p)
     ofproto_flush_flows(p);
     classifier_destroy(&p->cls);
 
-    LIST_FOR_EACH_SAFE (ofconn, next_ofconn, struct ofconn, node,
-                        &p->all_conns) {
+    LIST_FOR_EACH_SAFE (ofconn, next_ofconn, node, &p->all_conns) {
         ofconn_destroy(ofconn);
     }
     hmap_destroy(&p->controllers);
 
     dpif_close(p->dpif);
     netdev_monitor_destroy(p->netdev_monitor);
-    HMAP_FOR_EACH_SAFE (ofport, next_ofport, struct ofport, hmap_node,
-                        &p->ports) {
+    HMAP_FOR_EACH_SAFE (ofport, next_ofport, hmap_node, &p->ports) {
         hmap_remove(&p->ports, &ofport->hmap_node);
         ofport_free(ofport);
     }
@@ -1017,7 +1014,7 @@ add_snooper(struct ofproto *ofproto, struct vconn *vconn)
 
     /* Pick a controller for monitoring. */
     best = NULL;
-    LIST_FOR_EACH (ofconn, struct ofconn, node, &ofproto->all_conns) {
+    LIST_FOR_EACH (ofconn, node, &ofproto->all_conns) {
         if (ofconn->type == OFCONN_CONTROLLER
             && (!best || snoop_preference(ofconn) > snoop_preference(best))) {
             best = ofconn;
@@ -1080,8 +1077,7 @@ ofproto_run1(struct ofproto *p)
         in_band_run(p->in_band);
     }
 
-    LIST_FOR_EACH_SAFE (ofconn, next_ofconn, struct ofconn, node,
-                        &p->all_conns) {
+    LIST_FOR_EACH_SAFE (ofconn, next_ofconn, node, &p->all_conns) {
         ofconn_run(ofconn, p);
     }
 
@@ -1184,7 +1180,7 @@ ofproto_wait(struct ofproto *p)
     dpif_recv_wait(p->dpif);
     dpif_port_poll_wait(p->dpif);
     netdev_monitor_poll_wait(p->netdev_monitor);
-    LIST_FOR_EACH (ofconn, struct ofconn, node, &p->all_conns) {
+    LIST_FOR_EACH (ofconn, node, &p->all_conns) {
         ofconn_wait(ofconn);
     }
     if (p->in_band) {
@@ -1321,7 +1317,7 @@ reinit_ports(struct ofproto *p)
     size_t i;
 
     svec_init(&devnames);
-    HMAP_FOR_EACH (ofport, struct ofport, hmap_node, &p->ports) {
+    HMAP_FOR_EACH (ofport, hmap_node, &p->ports) {
         svec_add (&devnames, (char *) ofport->opp.name);
     }
     dpif_port_list(p->dpif, &odp_ports, &n_odp_ports);
@@ -1348,7 +1344,7 @@ refresh_port_group(struct ofproto *p, unsigned int group)
 
     ports = xmalloc(hmap_count(&p->ports) * sizeof *ports);
     n_ports = 0;
-    HMAP_FOR_EACH (port, struct ofport, hmap_node, &p->ports) {
+    HMAP_FOR_EACH (port, hmap_node, &p->ports) {
         if (group == DP_GROUP_ALL || !(port->opp.config & OFPPC_NO_FLOOD)) {
             ports[n_ports++] = port->odp_port;
         }
@@ -1453,7 +1449,7 @@ send_port_status(struct ofproto *p, const struct ofport *ofport,
 {
     /* XXX Should limit the number of queued port status change messages. */
     struct ofconn *ofconn;
-    LIST_FOR_EACH (ofconn, struct ofconn, node, &p->all_conns) {
+    LIST_FOR_EACH (ofconn, node, &p->all_conns) {
         struct ofp_port_status *ops;
         struct ofpbuf *b;
 
@@ -1511,7 +1507,7 @@ get_port(const struct ofproto *ofproto, uint16_t odp_port)
 {
     struct ofport *port;
 
-    HMAP_FOR_EACH_IN_BUCKET (port, struct ofport, hmap_node,
+    HMAP_FOR_EACH_IN_BUCKET (port, hmap_node,
                              hash_int(odp_port, 0), &ofproto->ports) {
         if (port->odp_port == odp_port) {
             return port;
@@ -1803,7 +1799,7 @@ rule_destroy(struct ofproto *ofproto, struct rule *rule)
 {
     if (!rule->super) {
         struct rule *subrule, *next;
-        LIST_FOR_EACH_SAFE (subrule, next, struct rule, list, &rule->list) {
+        LIST_FOR_EACH_SAFE (subrule, next, list, &rule->list) {
             revalidate_rule(ofproto, subrule);
         }
     } else {
@@ -2218,7 +2214,7 @@ handle_features_request(struct ofproto *p, struct ofconn *ofconn,
                          (1u << OFPAT_SET_TP_DST) |
                          (1u << OFPAT_ENQUEUE));
 
-    HMAP_FOR_EACH (port, struct ofport, hmap_node, &p->ports) {
+    HMAP_FOR_EACH (port, hmap_node, &p->ports) {
         hton_ofp_phy_port(ofpbuf_put(buf, &port->opp, sizeof port->opp));
     }
 
@@ -2948,7 +2944,7 @@ handle_port_stats_request(struct ofproto *p, struct ofconn *ofconn,
             append_port_stat(port, ofconn, &msg);
         }
     } else {
-        HMAP_FOR_EACH (port, struct ofport, hmap_node, &p->ports) {
+        HMAP_FOR_EACH (port, hmap_node, &p->ports) {
             append_port_stat(port, ofconn, &msg);
         }
     }
@@ -2993,7 +2989,7 @@ query_stats(struct ofproto *p, struct rule *rule,
     odp_flows = xzalloc(n_odp_flows * sizeof *odp_flows);
     if (rule->cr.wc.wildcards) {
         size_t i = 0;
-        LIST_FOR_EACH (subrule, struct rule, list, &rule->list) {
+        LIST_FOR_EACH (subrule, list, &rule->list) {
             odp_flows[i++].key = subrule->cr.flow;
             packet_count += subrule->packet_count;
             byte_count += subrule->byte_count;
@@ -3280,7 +3276,7 @@ handle_queue_stats_request(struct ofproto *ofproto, struct ofconn *ofconn,
     port_no = ntohs(qsr->port_no);
     queue_id = ntohl(qsr->queue_id);
     if (port_no == OFPP_ALL) {
-        HMAP_FOR_EACH (port, struct ofport, hmap_node, &ofproto->ports) {
+        HMAP_FOR_EACH (port, hmap_node, &ofproto->ports) {
             handle_queue_stats_for_port(port, queue_id, &cbdata);
         }
     } else if (port_no < ofproto->max_ports) {
@@ -3770,8 +3766,7 @@ handle_role_request(struct ofproto *ofproto,
     if (role == NX_ROLE_MASTER) {
         struct ofconn *other;
 
-        HMAP_FOR_EACH (other, struct ofconn, hmap_node,
-                       &ofproto->controllers) {
+        HMAP_FOR_EACH (other, hmap_node, &ofproto->controllers) {
             if (other->role == NX_ROLE_MASTER) {
                 other->role = NX_ROLE_SLAVE;
             }
@@ -4108,7 +4103,7 @@ send_flow_removed(struct ofproto *p, struct rule *rule,
      * requests that would not add new flows, so it is imperfect.) */
 
     prev = NULL;
-    LIST_FOR_EACH (ofconn, struct ofconn, node, &p->all_conns) {
+    LIST_FOR_EACH (ofconn, node, &p->all_conns) {
         if (rule->send_flow_removed && rconn_is_connected(ofconn->rconn)
             && ofconn_receives_async_msgs(ofconn)) {
             if (prev) {
@@ -4158,7 +4153,7 @@ expire_rule(struct cls_rule *cls_rule, void *p_)
      * due to an idle timeout. */
     if (rule->cr.wc.wildcards) {
         struct rule *subrule, *next;
-        LIST_FOR_EACH_SAFE (subrule, next, struct rule, list, &rule->list) {
+        LIST_FOR_EACH_SAFE (subrule, next, list, &rule->list) {
             rule_remove(p, subrule);
         }
     } else {
@@ -4371,7 +4366,7 @@ send_packet_in(struct ofproto *ofproto, struct ofpbuf *packet)
     max_len = do_convert_to_packet_in(packet);
 
     prev = NULL;
-    LIST_FOR_EACH (ofconn, struct ofconn, node, &ofproto->all_conns) {
+    LIST_FOR_EACH (ofconn, node, &ofproto->all_conns) {
         if (ofconn_receives_async_msgs(ofconn)) {
             if (prev) {
                 schedule_packet_in(prev, packet, max_len, true);
diff --git a/ofproto/status.c b/ofproto/status.c
index 27dc86c..2b6398f 100644
--- a/ofproto/status.c
+++ b/ofproto/status.c
@@ -70,7 +70,7 @@ switch_status_handle_request(struct switch_status *ss, struct rconn *rconn,
     sr.request.string = (void *) (request + 1);
     sr.request.length = ntohs(request->header.length) - sizeof *request;
     ds_init(&sr.output);
-    LIST_FOR_EACH (c, struct status_category, node, &ss->categories) {
+    LIST_FOR_EACH (c, node, &ss->categories) {
         if (!memcmp(c->name, sr.request.string,
                     MIN(strlen(c->name), sr.request.length))) {
             sr.category = c;
@@ -179,8 +179,7 @@ switch_status_destroy(struct switch_status *ss)
         /* Orphan any remaining categories, so that unregistering them later
          * won't write to bad memory. */
         struct status_category *c, *next;
-        LIST_FOR_EACH_SAFE (c, next,
-                            struct status_category, node, &ss->categories) {
+        LIST_FOR_EACH_SAFE (c, next, node, &ss->categories) {
             list_init(&c->node);
         }
         switch_status_unregister(ss->config_cat);
diff --git a/ovsdb/file.c b/ovsdb/file.c
index f0913e9..12cd1a6 100644
--- a/ovsdb/file.c
+++ b/ovsdb/file.c
@@ -427,7 +427,7 @@ ovsdb_file_save_copy__(const char *file_name, int locking,
         const struct ovsdb_table *table = node->data;
         const struct ovsdb_row *row;
 
-        HMAP_FOR_EACH (row, struct ovsdb_row, hmap_node, &table->rows) {
+        HMAP_FOR_EACH (row, hmap_node, &table->rows) {
             ovsdb_file_txn_add_row(&ftxn, NULL, row, NULL);
         }
     }
diff --git a/ovsdb/jsonrpc-server.c b/ovsdb/jsonrpc-server.c
index bc717e4..9a7194f 100644
--- a/ovsdb/jsonrpc-server.c
+++ b/ovsdb/jsonrpc-server.c
@@ -323,8 +323,7 @@ ovsdb_jsonrpc_session_run_all(struct ovsdb_jsonrpc_remote *remote)
 {
     struct ovsdb_jsonrpc_session *s, *next;
 
-    LIST_FOR_EACH_SAFE (s, next, struct ovsdb_jsonrpc_session, node,
-                        &remote->sessions) {
+    LIST_FOR_EACH_SAFE (s, next, node, &remote->sessions) {
         int error = ovsdb_jsonrpc_session_run(s);
         if (error) {
             ovsdb_jsonrpc_session_close(s);
@@ -346,7 +345,7 @@ ovsdb_jsonrpc_session_wait_all(struct ovsdb_jsonrpc_remote *remote)
 {
     struct ovsdb_jsonrpc_session *s;
 
-    LIST_FOR_EACH (s, struct ovsdb_jsonrpc_session, node, &remote->sessions) {
+    LIST_FOR_EACH (s, node, &remote->sessions) {
         ovsdb_jsonrpc_session_wait(s);
     }
 }
@@ -356,8 +355,7 @@ ovsdb_jsonrpc_session_close_all(struct ovsdb_jsonrpc_remote *remote)
 {
     struct ovsdb_jsonrpc_session *s, *next;
 
-    LIST_FOR_EACH_SAFE (s, next, struct ovsdb_jsonrpc_session, node,
-                        &remote->sessions) {
+    LIST_FOR_EACH_SAFE (s, next, node, &remote->sessions) {
         ovsdb_jsonrpc_session_close(s);
     }
 }
@@ -369,8 +367,7 @@ ovsdb_jsonrpc_session_reconnect_all(struct ovsdb_jsonrpc_remote *remote)
 {
     struct ovsdb_jsonrpc_session *s, *next;
 
-    LIST_FOR_EACH_SAFE (s, next, struct ovsdb_jsonrpc_session, node,
-                        &remote->sessions) {
+    LIST_FOR_EACH_SAFE (s, next, node, &remote->sessions) {
         jsonrpc_session_force_reconnect(s->js);
         if (!jsonrpc_session_is_alive(s->js)) {
             ovsdb_jsonrpc_session_close(s);
@@ -554,8 +551,7 @@ ovsdb_jsonrpc_trigger_find(struct ovsdb_jsonrpc_session *s,
 {
     struct ovsdb_jsonrpc_trigger *t;
 
-    HMAP_FOR_EACH_WITH_HASH (t, struct ovsdb_jsonrpc_trigger, hmap_node, hash,
-                             &s->triggers) {
+    HMAP_FOR_EACH_WITH_HASH (t, hmap_node, hash, &s->triggers) {
         if (json_equal(t->id, id)) {
             return t;
         }
@@ -593,8 +589,7 @@ static void
 ovsdb_jsonrpc_trigger_complete_all(struct ovsdb_jsonrpc_session *s)
 {
     struct ovsdb_jsonrpc_trigger *t, *next;
-    HMAP_FOR_EACH_SAFE (t, next, struct ovsdb_jsonrpc_trigger, hmap_node,
-                        &s->triggers) {
+    HMAP_FOR_EACH_SAFE (t, next, hmap_node, &s->triggers) {
         ovsdb_jsonrpc_trigger_complete(t);
     }
 }
@@ -671,8 +666,7 @@ ovsdb_jsonrpc_monitor_find(struct ovsdb_jsonrpc_session *s,
 {
     struct ovsdb_jsonrpc_monitor *m;
 
-    HMAP_FOR_EACH_WITH_HASH (m, struct ovsdb_jsonrpc_monitor, node,
-                             json_hash(monitor_id, 0), &s->monitors) {
+    HMAP_FOR_EACH_WITH_HASH (m, node, json_hash(monitor_id, 0), &s->monitors) {
         if (json_equal(m->monitor_id, monitor_id)) {
             return m;
         }
@@ -919,8 +913,7 @@ ovsdb_jsonrpc_monitor_remove_all(struct ovsdb_jsonrpc_session *s)
 {
     struct ovsdb_jsonrpc_monitor *m, *next;
 
-    HMAP_FOR_EACH_SAFE (m, next,
-                        struct ovsdb_jsonrpc_monitor, node, &s->monitors) {
+    HMAP_FOR_EACH_SAFE (m, next, node, &s->monitors) {
         ovsdb_remove_replica(s->remote->server->db, &m->replica);
     }
 }
@@ -1097,8 +1090,7 @@ ovsdb_jsonrpc_monitor_get_initial(const struct ovsdb_jsonrpc_monitor *m)
         if (mt->select & OJMS_INITIAL) {
             struct ovsdb_row *row;
 
-            HMAP_FOR_EACH (row, struct ovsdb_row, hmap_node,
-                           &mt->table->rows) {
+            HMAP_FOR_EACH (row, hmap_node, &mt->table->rows) {
                 ovsdb_jsonrpc_monitor_change_cb(NULL, row, NULL, &aux);
             }
         }
diff --git a/ovsdb/ovsdb-server.c b/ovsdb/ovsdb-server.c
index 3b71442..b1c8a10 100644
--- a/ovsdb/ovsdb-server.c
+++ b/ovsdb/ovsdb-server.c
@@ -224,7 +224,7 @@ query_db_string(const struct ovsdb *db, const char *name)
 
         parse_db_string_column(db, name, &table, &column);
 
-        HMAP_FOR_EACH (row, struct ovsdb_row, hmap_node, &table->rows) {
+        HMAP_FOR_EACH (row, hmap_node, &table->rows) {
             const struct ovsdb_datum *datum;
             size_t i;
 
@@ -250,7 +250,7 @@ query_db_remotes(const char *name, const struct ovsdb *db,
 
     parse_db_string_column(db, name, &table, &column);
 
-    HMAP_FOR_EACH (row, struct ovsdb_row, hmap_node, &table->rows) {
+    HMAP_FOR_EACH (row, hmap_node, &table->rows) {
         const struct ovsdb_datum *datum;
         size_t i;
 
diff --git a/ovsdb/query.c b/ovsdb/query.c
index 878ac5b..52eda0a 100644
--- a/ovsdb/query.c
+++ b/ovsdb/query.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009 Nicira Networks
+/* Copyright (c) 2009, 2010 Nicira Networks
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -41,8 +41,7 @@ ovsdb_query(struct ovsdb_table *table, const struct ovsdb_condition *cnd,
         /* Linear scan. */
         const struct ovsdb_row *row, *next;
 
-        HMAP_FOR_EACH_SAFE (row, next, struct ovsdb_row, hmap_node,
-                            &table->rows) {
+        HMAP_FOR_EACH_SAFE (row, next, hmap_node, &table->rows) {
             if (ovsdb_condition_evaluate(row, cnd) && !output_row(row, aux)) {
                 break;
             }
@@ -90,8 +89,7 @@ ovsdb_query_distinct(struct ovsdb_table *table,
 
         ovsdb_row_hash_init(&hash, columns);
         ovsdb_query(table, condition, query_distinct_cb, &hash);
-        HMAP_FOR_EACH (node, struct ovsdb_row_hash_node, hmap_node,
-                       &hash.rows) {
+        HMAP_FOR_EACH (node, hmap_node, &hash.rows) {
             ovsdb_row_set_add_row(results, node->row);
         }
         ovsdb_row_hash_destroy(&hash, false);
diff --git a/ovsdb/row.c b/ovsdb/row.c
index 5043cbc..ba00bb9 100644
--- a/ovsdb/row.c
+++ b/ovsdb/row.c
@@ -82,15 +82,13 @@ ovsdb_row_destroy(struct ovsdb_row *row)
         struct ovsdb_weak_ref *weak, *next;
         const struct shash_node *node;
 
-        LIST_FOR_EACH_SAFE (weak, next, struct ovsdb_weak_ref, dst_node,
-                            &row->dst_refs) {
+        LIST_FOR_EACH_SAFE (weak, next, dst_node, &row->dst_refs) {
             list_remove(&weak->src_node);
             list_remove(&weak->dst_node);
             free(weak);
         }
 
-        LIST_FOR_EACH_SAFE (weak, next, struct ovsdb_weak_ref, src_node,
-                            &row->src_refs) {
+        LIST_FOR_EACH_SAFE (weak, next, src_node, &row->src_refs) {
             list_remove(&weak->src_node);
             list_remove(&weak->dst_node);
             free(weak);
@@ -326,8 +324,7 @@ ovsdb_row_hash_destroy(struct ovsdb_row_hash *rh, bool destroy_rows)
 {
     struct ovsdb_row_hash_node *node, *next;
 
-    HMAP_FOR_EACH_SAFE (node, next, struct ovsdb_row_hash_node, hmap_node,
-                        &rh->rows) {
+    HMAP_FOR_EACH_SAFE (node, next, hmap_node, &rh->rows) {
         hmap_remove(&rh->rows, &node->hmap_node);
         if (destroy_rows) {
             ovsdb_row_destroy((struct ovsdb_row *) node->row);
@@ -360,7 +357,7 @@ ovsdb_row_hash_contains_all(const struct ovsdb_row_hash *a,
     struct ovsdb_row_hash_node *node;
 
     assert(ovsdb_column_set_equals(&a->columns, &b->columns));
-    HMAP_FOR_EACH (node, struct ovsdb_row_hash_node, hmap_node, &b->rows) {
+    HMAP_FOR_EACH (node, hmap_node, &b->rows) {
         if (!ovsdb_row_hash_contains__(a, node->row, node->hmap_node.hash)) {
             return false;
         }
@@ -380,8 +377,7 @@ ovsdb_row_hash_contains__(const struct ovsdb_row_hash *rh,
                           const struct ovsdb_row *row, size_t hash)
 {
     struct ovsdb_row_hash_node *node;
-    HMAP_FOR_EACH_WITH_HASH (node, struct ovsdb_row_hash_node, hmap_node,
-                             hash, &rh->rows) {
+    HMAP_FOR_EACH_WITH_HASH (node, hmap_node, hash, &rh->rows) {
         if (ovsdb_row_equal_columns(row, node->row, &rh->columns)) {
             return true;
         }
diff --git a/ovsdb/table.c b/ovsdb/table.c
index 6a4e7ae..5e83683 100644
--- a/ovsdb/table.c
+++ b/ovsdb/table.c
@@ -210,8 +210,7 @@ ovsdb_table_destroy(struct ovsdb_table *table)
     if (table) {
         struct ovsdb_row *row, *next;
 
-        HMAP_FOR_EACH_SAFE (row, next, struct ovsdb_row, hmap_node,
-                            &table->rows) {
+        HMAP_FOR_EACH_SAFE (row, next, hmap_node, &table->rows) {
             ovsdb_row_destroy(row);
         }
         hmap_destroy(&table->rows);
@@ -226,8 +225,7 @@ ovsdb_table_get_row(const struct ovsdb_table *table, const struct uuid *uuid)
 {
     struct ovsdb_row *row;
 
-    HMAP_FOR_EACH_WITH_HASH (row, struct ovsdb_row, hmap_node, uuid_hash(uuid),
-                             &table->rows) {
+    HMAP_FOR_EACH_WITH_HASH (row, hmap_node, uuid_hash(uuid), &table->rows) {
         if (uuid_equals(ovsdb_row_get_uuid(row), uuid)) {
             return row;
         }
diff --git a/ovsdb/transaction.c b/ovsdb/transaction.c
index bfa2fcb..b26705a 100644
--- a/ovsdb/transaction.c
+++ b/ovsdb/transaction.c
@@ -138,7 +138,7 @@ find_txn_row(const struct ovsdb_table *table, const struct uuid *uuid)
         return NULL;
     }
 
-    HMAP_FOR_EACH_WITH_HASH (txn_row, struct ovsdb_txn_row, hmap_node,
+    HMAP_FOR_EACH_WITH_HASH (txn_row, hmap_node,
                              uuid_hash(uuid), &table->txn_table->txn_rows) {
         const struct ovsdb_row *row;
 
@@ -315,8 +315,7 @@ assess_weak_refs(struct ovsdb_txn *txn, struct ovsdb_txn_row *txn_row)
          * that their weak references will get reassessed. */
         struct ovsdb_weak_ref *weak, *next;
 
-        LIST_FOR_EACH_SAFE (weak, next, struct ovsdb_weak_ref, dst_node,
-                            &txn_row->old->dst_refs) {
+        LIST_FOR_EACH_SAFE (weak, next, dst_node, &txn_row->old->dst_refs) {
             if (!weak->src->txn_row) {
                 ovsdb_txn_row_modify(txn, weak->src);
             }
@@ -451,7 +450,7 @@ check_max_rows(struct ovsdb_txn *txn)
 {
     struct ovsdb_txn_table *t;
 
-    LIST_FOR_EACH (t, struct ovsdb_txn_table, node, &txn->txn_tables) {
+    LIST_FOR_EACH (t, node, &txn->txn_tables) {
         size_t n_rows = hmap_count(&t->table->rows);
         unsigned int max_rows = t->table->schema->max_rows;
 
@@ -508,7 +507,7 @@ ovsdb_txn_commit(struct ovsdb_txn *txn, bool durable)
     }
 
     /* Send the commit to each replica. */
-    LIST_FOR_EACH (replica, struct ovsdb_replica, node, &txn->db->replicas) {
+    LIST_FOR_EACH (replica, node, &txn->db->replicas) {
         error = (replica->class->commit)(replica, txn, durable);
         if (error) {
             /* We don't support two-phase commit so only the first replica is
@@ -535,8 +534,8 @@ ovsdb_txn_for_each_change(const struct ovsdb_txn *txn,
     struct ovsdb_txn_table *t;
     struct ovsdb_txn_row *r;
 
-    LIST_FOR_EACH (t, struct ovsdb_txn_table, node, &txn->txn_tables) {
-        HMAP_FOR_EACH (r, struct ovsdb_txn_row, hmap_node, &t->txn_rows) {
+    LIST_FOR_EACH (t, node, &txn->txn_tables) {
+        HMAP_FOR_EACH (r, hmap_node, &t->txn_rows) {
             if (!cb(r->old, r->new, r->changed, aux)) {
                 break;
             }
@@ -714,8 +713,7 @@ for_each_txn_row(struct ovsdb_txn *txn,
         struct ovsdb_txn_table *t, *next_txn_table;
 
         any_work = false;
-        LIST_FOR_EACH_SAFE (t, next_txn_table, struct ovsdb_txn_table, node,
-                            &txn->txn_tables) {
+        LIST_FOR_EACH_SAFE (t, next_txn_table, node, &txn->txn_tables) {
             if (t->serial != serial) {
                 t->serial = serial;
                 t->n_processed = 0;
@@ -724,9 +722,7 @@ for_each_txn_row(struct ovsdb_txn *txn,
             while (t->n_processed < hmap_count(&t->txn_rows)) {
                 struct ovsdb_txn_row *r, *next_txn_row;
 
-                HMAP_FOR_EACH_SAFE (r, next_txn_row,
-                                    struct ovsdb_txn_row, hmap_node,
-                                    &t->txn_rows) {
+                HMAP_FOR_EACH_SAFE (r, next_txn_row, hmap_node, &t->txn_rows) {
                     if (r->serial != serial) {
                         struct ovsdb_error *error;
 
diff --git a/ovsdb/trigger.c b/ovsdb/trigger.c
index 4771969..c222d89 100644
--- a/ovsdb/trigger.c
+++ b/ovsdb/trigger.c
@@ -73,7 +73,7 @@ ovsdb_trigger_run(struct ovsdb *db, long long int now)
 
     run_triggers = db->run_triggers;
     db->run_triggers = false;
-    LIST_FOR_EACH_SAFE (t, next, struct ovsdb_trigger, node, &db->triggers) {
+    LIST_FOR_EACH_SAFE (t, next, node, &db->triggers) {
         if (run_triggers || now - t->created >= t->timeout_msec) {
             ovsdb_trigger_try(db, t, now);
         }
@@ -89,7 +89,7 @@ ovsdb_trigger_wait(struct ovsdb *db, long long int now)
         long long int deadline = LLONG_MAX;
         struct ovsdb_trigger *t;
 
-        LIST_FOR_EACH (t, struct ovsdb_trigger, node, &db->triggers) {
+        LIST_FOR_EACH (t, node, &db->triggers) {
             if (t->created < LLONG_MAX - t->timeout_msec) {
                 long long int t_deadline = t->created + t->timeout_msec;
                 if (deadline > t_deadline) {
diff --git a/tests/test-classifier.c b/tests/test-classifier.c
index 57a1e2c..4227c18 100644
--- a/tests/test-classifier.c
+++ b/tests/test-classifier.c
@@ -430,7 +430,7 @@ check_tables(const struct classifier *cls,
         if (!hmap_is_empty(&cls->tables[i])) {
             found_tables++;
         }
-        HMAP_FOR_EACH (bucket, struct cls_bucket, hmap_node, &cls->tables[i]) {
+        HMAP_FOR_EACH (bucket, hmap_node, &cls->tables[i]) {
             found_buckets++;
             assert(!list_is_empty(&bucket->rules));
             found_rules += list_size(&bucket->rules);
diff --git a/tests/test-hmap.c b/tests/test-hmap.c
index 18d8f46..be6bcf4 100644
--- a/tests/test-hmap.c
+++ b/tests/test-hmap.c
@@ -56,7 +56,7 @@ check_hmap(struct hmap *hmap, const int values[], size_t n,
     hmap_values = xmalloc(sizeof *sort_values * n);
 
     i = 0;
-    HMAP_FOR_EACH (e, struct element, node, hmap) {
+    HMAP_FOR_EACH (e, node, hmap) {
         assert(i < n);
         hmap_values[i++] = e->value;
     }
@@ -77,8 +77,7 @@ check_hmap(struct hmap *hmap, const int values[], size_t n,
     for (i = 0; i < n; i++) {
         size_t count = 0;
 
-        HMAP_FOR_EACH_WITH_HASH (e, struct element, node,
-                                 hash(values[i]), hmap) {
+        HMAP_FOR_EACH_WITH_HASH (e, node, hash(values[i]), hmap) {
             count += e->value == values[i];
         }
         assert(count == 1);
@@ -124,7 +123,7 @@ print_hmap(const char *name, struct hmap *hmap)
     struct element *e;
 
     printf("%s:", name);
-    HMAP_FOR_EACH (e, struct element, node, hmap) {
+    HMAP_FOR_EACH (e, node, hmap) {
         printf(" %d(%zu)", e->value, e->node.hash & hmap->mask);
     }
     printf("\n");
@@ -242,7 +241,7 @@ test_hmap_for_each_safe(hash_func *hash)
 
             i = 0;
             n_remaining = n;
-            HMAP_FOR_EACH_SAFE (e, next, struct element, node, &hmap) {
+            HMAP_FOR_EACH_SAFE (e, next, node, &hmap) {
                 assert(i < n);
                 if (pattern & (1ul << e->value)) {
                     size_t j;
diff --git a/tests/test-list.c b/tests/test-list.c
index 0aa0f8b..43143a3 100644
--- a/tests/test-list.c
+++ b/tests/test-list.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2009 Nicira Networks.
+ * Copyright (c) 2008, 2009, 2010 Nicira Networks.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -55,7 +55,7 @@ check_list(struct list *list, const int values[], size_t n)
     size_t i;
     
     i = 0;
-    LIST_FOR_EACH (e, struct element, node, list) {
+    LIST_FOR_EACH (e, node, list) {
         assert(i < n);
         assert(e->value == values[i]);
         i++;
@@ -64,7 +64,7 @@ check_list(struct list *list, const int values[], size_t n)
     assert(i == n);
 
     i = 0;
-    LIST_FOR_EACH_REVERSE (e, struct element, node, list) {
+    LIST_FOR_EACH_REVERSE (e, node, list) {
         assert(i < n);
         assert(e->value == values[n - i - 1]);
         i++;
@@ -84,7 +84,7 @@ print_list(const char *name, struct list *list)
     struct element *e;
     
     printf("%s:", name);
-    LIST_FOR_EACH (e, struct element, node, list) {
+    LIST_FOR_EACH (e, node, list) {
         printf(" %d", e->value);
     }
     printf("\n");
@@ -131,7 +131,7 @@ test_list_for_each_safe(void)
             i = 0;
             values_idx = 0;
             n_remaining = n;
-            LIST_FOR_EACH_SAFE (e, next, struct element, node, &list) {
+            LIST_FOR_EACH_SAFE (e, next, node, &list) {
                 assert(i < n);
                 if (pattern & (1ul << i)) {
                     list_remove(&e->node);
diff --git a/tests/test-ovsdb.c b/tests/test-ovsdb.c
index 0d7e8c5..08201e5 100644
--- a/tests/test-ovsdb.c
+++ b/tests/test-ovsdb.c
@@ -1476,8 +1476,7 @@ do_transact_print(int argc OVS_UNUSED, char *argv[] OVS_UNUSED)
     n_rows = hmap_count(&do_transact_table->rows);
     rows = xmalloc(n_rows * sizeof *rows);
     i = 0;
-    HMAP_FOR_EACH (row, struct ovsdb_row, hmap_node,
-                   &do_transact_table->rows) {
+    HMAP_FOR_EACH (row, hmap_node, &do_transact_table->rows) {
         rows[i++] = row;
     }
     assert(i == n_rows);
diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index 4e17696..a9b86a6 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -563,7 +563,7 @@ bridge_reconfigure(const struct ovsrec_open_vswitch *ovs_cfg)
     /* Collect old and new bridges. */
     shash_init(&old_br);
     shash_init(&new_br);
-    LIST_FOR_EACH (br, struct bridge, node, &all_bridges) {
+    LIST_FOR_EACH (br, node, &all_bridges) {
         shash_add(&old_br, br->name, br);
     }
     for (i = 0; i < ovs_cfg->n_bridges; i++) {
@@ -574,7 +574,7 @@ bridge_reconfigure(const struct ovsrec_open_vswitch *ovs_cfg)
     }
 
     /* Get rid of deleted bridges and add new bridges. */
-    LIST_FOR_EACH_SAFE (br, next, struct bridge, node, &all_bridges) {
+    LIST_FOR_EACH_SAFE (br, next, node, &all_bridges) {
         struct ovsrec_bridge *br_cfg = shash_find_data(&new_br, br->name);
         if (br_cfg) {
             br->cfg = br_cfg;
@@ -606,7 +606,7 @@ bridge_reconfigure(const struct ovsrec_open_vswitch *ovs_cfg)
 #endif
 
     /* Reconfigure all bridges. */
-    LIST_FOR_EACH (br, struct bridge, node, &all_bridges) {
+    LIST_FOR_EACH (br, node, &all_bridges) {
         bridge_reconfigure_one(ovs_cfg, br);
     }
 
@@ -615,7 +615,7 @@ bridge_reconfigure(const struct ovsrec_open_vswitch *ovs_cfg)
      * The kernel will reject any attempt to add a given port to a datapath if
      * that port already belongs to a different datapath, so we must do all
      * port deletions before any port additions. */
-    LIST_FOR_EACH (br, struct bridge, node, &all_bridges) {
+    LIST_FOR_EACH (br, node, &all_bridges) {
         struct odp_port *dpif_ports;
         size_t n_dpif_ports;
         struct shash want_ifaces;
@@ -637,7 +637,7 @@ bridge_reconfigure(const struct ovsrec_open_vswitch *ovs_cfg)
         shash_destroy(&want_ifaces);
         free(dpif_ports);
     }
-    LIST_FOR_EACH (br, struct bridge, node, &all_bridges) {
+    LIST_FOR_EACH (br, node, &all_bridges) {
         struct odp_port *dpif_ports;
         size_t n_dpif_ports;
         struct shash cur_ifaces, want_ifaces;
@@ -687,7 +687,7 @@ bridge_reconfigure(const struct ovsrec_open_vswitch *ovs_cfg)
         shash_destroy(&want_ifaces);
     }
     sflow_bridge_number = 0;
-    LIST_FOR_EACH (br, struct bridge, node, &all_bridges) {
+    LIST_FOR_EACH (br, node, &all_bridges) {
         uint8_t ea[8];
         uint64_t dpid;
         struct iface *local_iface;
@@ -825,7 +825,7 @@ bridge_reconfigure(const struct ovsrec_open_vswitch *ovs_cfg)
          * the datapath ID before the controller. */
         bridge_reconfigure_remotes(ovs_cfg, br, managers, n_managers);
     }
-    LIST_FOR_EACH (br, struct bridge, node, &all_bridges) {
+    LIST_FOR_EACH (br, node, &all_bridges) {
         for (i = 0; i < br->n_ports; i++) {
             struct port *port = br->ports[i];
             int j;
@@ -838,7 +838,7 @@ bridge_reconfigure(const struct ovsrec_open_vswitch *ovs_cfg)
             }
         }
     }
-    LIST_FOR_EACH (br, struct bridge, node, &all_bridges) {
+    LIST_FOR_EACH (br, node, &all_bridges) {
         iterate_and_prune_ifaces(br, set_iface_properties, NULL);
     }
 
@@ -1115,7 +1115,7 @@ bridge_run(void)
 
     /* Let each bridge do the work that it needs to do. */
     datapath_destroyed = false;
-    LIST_FOR_EACH (br, struct bridge, node, &all_bridges) {
+    LIST_FOR_EACH (br, node, &all_bridges) {
         int error = bridge_run_one(br);
         if (error) {
             static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
@@ -1151,7 +1151,7 @@ bridge_run(void)
         struct ovsdb_idl_txn *txn;
 
         txn = ovsdb_idl_txn_create(idl);
-        LIST_FOR_EACH (br, struct bridge, node, &all_bridges) {
+        LIST_FOR_EACH (br, node, &all_bridges) {
             size_t i;
 
             for (i = 0; i < br->n_ports; i++) {
@@ -1176,7 +1176,7 @@ bridge_wait(void)
 {
     struct bridge *br;
 
-    LIST_FOR_EACH (br, struct bridge, node, &all_bridges) {
+    LIST_FOR_EACH (br, node, &all_bridges) {
         ofproto_wait(br->ofproto);
         if (ofproto_has_controller(br->ofproto)) {
             continue;
@@ -1235,7 +1235,7 @@ bridge_unixctl_fdb_show(struct unixctl_conn *conn,
     }
 
     ds_put_cstr(&ds, " port  VLAN  MAC                Age\n");
-    LIST_FOR_EACH (e, struct mac_entry, lru_node, &br->ml->lrus) {
+    LIST_FOR_EACH (e, lru_node, &br->ml->lrus) {
         if (e->port < 0 || e->port >= br->n_ports) {
             continue;
         }
@@ -1327,7 +1327,7 @@ bridge_lookup(const char *name)
 {
     struct bridge *br;
 
-    LIST_FOR_EACH (br, struct bridge, node, &all_bridges) {
+    LIST_FOR_EACH (br, node, &all_bridges) {
         if (!strcmp(br->name, name)) {
             return br;
         }
@@ -1373,7 +1373,7 @@ bridge_unixctl_reconnect(struct unixctl_conn *conn,
         }
         ofproto_reconnect_controllers(br->ofproto);
     } else {
-        LIST_FOR_EACH (br, struct bridge, node, &all_bridges) {
+        LIST_FOR_EACH (br, node, &all_bridges) {
             ofproto_reconnect_controllers(br->ofproto);
         }
     }
@@ -2852,7 +2852,7 @@ bond_send_learning_packets(struct port *port)
 
     ofpbuf_init(&packet, 128);
     error = n_packets = n_errors = 0;
-    LIST_FOR_EACH (e, struct mac_entry, lru_node, &br->ml->lrus) {
+    LIST_FOR_EACH (e, lru_node, &br->ml->lrus) {
         union ofp_action actions[2], *a;
         uint16_t dp_ifidx;
         tag_type tags = 0;
@@ -2914,7 +2914,7 @@ bond_unixctl_list(struct unixctl_conn *conn,
 
     ds_put_cstr(&ds, "bridge\tbond\tslaves\n");
 
-    LIST_FOR_EACH (br, struct bridge, node, &all_bridges) {
+    LIST_FOR_EACH (br, node, &all_bridges) {
         size_t i;
 
         for (i = 0; i < br->n_ports; i++) {
@@ -2943,7 +2943,7 @@ bond_find(const char *name)
 {
     const struct bridge *br;
 
-    LIST_FOR_EACH (br, struct bridge, node, &all_bridges) {
+    LIST_FOR_EACH (br, node, &all_bridges) {
         size_t i;
 
         for (i = 0; i < br->n_ports; i++) {
@@ -3003,8 +3003,7 @@ bond_unixctl_show(struct unixctl_conn *conn,
                           hash, be->tx_bytes / 1024);
 
             /* MACs. */
-            LIST_FOR_EACH (me, struct mac_entry, lru_node,
-                           &port->bridge->ml->lrus) {
+            LIST_FOR_EACH (me, lru_node, &port->bridge->ml->lrus) {
                 uint16_t dp_ifidx;
                 tag_type tags = 0;
                 if (bond_hash(me->mac) == hash
@@ -3687,7 +3686,7 @@ iface_from_dp_ifidx(const struct bridge *br, uint16_t dp_ifidx)
 {
     struct iface *iface;
 
-    HMAP_FOR_EACH_IN_BUCKET (iface, struct iface, dp_ifidx_node,
+    HMAP_FOR_EACH_IN_BUCKET (iface, dp_ifidx_node,
                              hash_int(dp_ifidx, 0), &br->ifaces) {
         if (iface->dp_ifidx == dp_ifidx) {
             return iface;
diff --git a/vswitchd/proc-net-compat.c b/vswitchd/proc-net-compat.c
index 106a7c3..4839113 100644
--- a/vswitchd/proc-net-compat.c
+++ b/vswitchd/proc-net-compat.c
@@ -248,8 +248,7 @@ proc_net_compat_update_vlan(const char *tagged_dev, const char *trunk_dev,
         /* 'tagged_dev' is not attached to any compat_vlan.  Find the
          * compat_vlan corresponding to (trunk_dev,vid) to attach it to, or
          * create a new compat_vlan if none exists for (trunk_dev,vid). */
-        HMAP_FOR_EACH_WITH_HASH (vlan, struct compat_vlan, trunk_node,
-                                 hash_vlan(trunk_dev, vid),
+        HMAP_FOR_EACH_WITH_HASH (vlan, trunk_node, hash_vlan(trunk_dev, vid),
                                  &vlans_by_trunk) {
             if (!strcmp(trunk_dev, vlan->trunk_dev) && vid == vlan->vid) {
                 break;
@@ -340,7 +339,7 @@ update_vlan_config(void)
     ds_init(&ds);
     ds_put_cstr(&ds, "VLAN Dev name     | VLAN ID\n"
                 "Name-Type: VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD\n");
-    HMAP_FOR_EACH (vlan, struct compat_vlan, trunk_node, &vlans_by_trunk) {
+    HMAP_FOR_EACH (vlan, trunk_node, &vlans_by_trunk) {
         ds_put_format(&ds, "%-15s| %d  | %s\n",
                       vlan->vlan_dev, vlan->vid, vlan->trunk_dev);
     }
-- 
1.7.1





More information about the dev mailing list