]> git.proxmox.com Git - ovs.git/commitdiff
lib/flow: Use C99 declaration in for statement.
authorJarno Rajahalme <jrajahalme@nicira.com>
Wed, 28 May 2014 23:56:29 +0000 (16:56 -0700)
committerJarno Rajahalme <jrajahalme@nicira.com>
Wed, 28 May 2014 23:56:29 +0000 (16:56 -0700)
C99 declarations within code are allowed now.  Change the
FLOW_FOR_EACH_IN_MAP to use loop variable within the for statement.
This makes this macro more generally useful.

The loop variable name is suffixed with two underscores with the
intention that there would be a low likelihood of collision with any
of the macro parameters.

Also fix the return type of flow_get_next_in_map().

Signed-off-by: Jarno Rajahalme <jrajahalme@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
lib/flow.h

index 0f3ffde15cc641e7a56a45957e984a172b5a19fb..139e7f68b55d1c93d2b4ed623788dd3c9d532be9 100644 (file)
@@ -411,7 +411,7 @@ void miniflow_destroy(struct miniflow *);
 
 void miniflow_expand(const struct miniflow *, struct flow *);
 
-static inline uint32_t
+static inline bool
 flow_get_next_in_map(const struct flow *flow, uint64_t map, uint32_t *value)
 {
     if (map) {
@@ -421,13 +421,11 @@ flow_get_next_in_map(const struct flow *flow, uint64_t map, uint32_t *value)
     return false;
 }
 
-/* Iterate through all flow u32 values specified by 'MAP'.
- * This works as the first statement in a block.*/
-#define FLOW_FOR_EACH_IN_MAP(VALUE, FLOW, MAP)                          \
-    uint64_t map_;                                                      \
-    for (map_ = (MAP);                                                  \
-         flow_get_next_in_map(FLOW, map_, &(VALUE));                    \
-         map_ = zero_rightmost_1bit(map_))
+/* Iterate through all flow u32 values specified by 'MAP'. */
+#define FLOW_FOR_EACH_IN_MAP(VALUE, FLOW, MAP)         \
+    for (uint64_t map__ = (MAP);                       \
+         flow_get_next_in_map(FLOW, map__, &(VALUE));  \
+         map__ = zero_rightmost_1bit(map__))
 
 #define FLOW_U32_SIZE(FIELD)                                            \
     DIV_ROUND_UP(sizeof(((struct flow *)0)->FIELD), sizeof(uint32_t))