2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 22:35:15 +00:00

lib/flow: Use C99 declaration in for statement.

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>
This commit is contained in:
Jarno Rajahalme
2014-05-28 16:56:29 -07:00
parent 7c96151e33
commit 08feeb7572

View 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))