summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2020-12-13 23:26:56 +0100
committerDave Barach <openvpp@barachs.net>2020-12-14 12:14:21 +0000
commitf0ca1e8d92114582ec9142bd15a40f1eb0102793 (patch)
treeaba56d88d909387605ba7fdaf7fc0fd5d3ff565c /src
parentb2c31b685fd2cf28436ca32bc93e23eb24c74878 (diff)
misc: refactor clib_bitmap_foreach macro
Type: refactor Change-Id: I077110e1a422722e20aa546a6f3224c06ab0cde5 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/acl/acl.c4
-rw-r--r--src/plugins/cnat/cnat_snat.c6
-rw-r--r--src/plugins/dpdk/device/device.c4
-rw-r--r--src/plugins/dpdk/device/init.c8
-rw-r--r--src/plugins/lisp/lisp-cp/gid_dictionary.c12
-rw-r--r--src/plugins/map/lpm.c6
-rw-r--r--src/plugins/nat/nat.c14
-rw-r--r--src/plugins/nat/nat64/nat64.c6
-rw-r--r--src/vcl/ldp.c11
-rw-r--r--src/vcl/vcl_locked.c4
-rw-r--r--src/vcl/vppcom.c8
-rw-r--r--src/vlib/buffer.c8
-rw-r--r--src/vlib/cli.c4
-rw-r--r--src/vlib/node.c8
-rw-r--r--src/vlib/node_cli.c4
-rw-r--r--src/vlib/node_format.c4
-rw-r--r--src/vlib/threads.c12
-rw-r--r--src/vnet/crypto/node.c4
-rw-r--r--src/vnet/fib/ip6_fib.c6
-rw-r--r--src/vnet/handoff.c6
-rw-r--r--src/vnet/interface_api.c6
-rw-r--r--src/vnet/interface_cli.c12
-rw-r--r--src/vnet/interface_format.c8
-rw-r--r--src/vnet/l2/l2_rw.c4
-rw-r--r--src/vnet/mfib/ip6_mfib.c6
-rw-r--r--src/vnet/pg/input.c4
-rw-r--r--src/vnet/span/node.c4
-rw-r--r--src/vnet/span/span.c4
-rw-r--r--src/vnet/span/span_api.c4
-rw-r--r--src/vpp/api/gmon.c6
-rw-r--r--src/vppinfra/bitmap.h8
-rw-r--r--src/vppinfra/elf.c4
-rw-r--r--src/vppinfra/timing_wheel.c12
33 files changed, 113 insertions, 108 deletions
diff --git a/src/plugins/acl/acl.c b/src/plugins/acl/acl.c
index 05251c6fcd8..35f8b8cb82d 100644
--- a/src/plugins/acl/acl.c
+++ b/src/plugins/acl/acl.c
@@ -679,7 +679,7 @@ acl_interface_set_inout_acl_list (acl_main_t * am, u32 sw_if_index,
seen_acl_bitmap, format_bitmap_hex, change_acl_bitmap);
/* *INDENT-OFF* */
- clib_bitmap_foreach(acln, change_acl_bitmap, ({
+ clib_bitmap_foreach (acln, change_acl_bitmap) {
if (clib_bitmap_get(old_seen_acl_bitmap, acln)) {
/* ACL is being removed. */
if (acln < vec_len((*pinout_sw_if_index_vec_by_acl))) {
@@ -691,7 +691,7 @@ acl_interface_set_inout_acl_list (acl_main_t * am, u32 sw_if_index,
vec_validate((*pinout_sw_if_index_vec_by_acl), acln);
vec_add1((*pinout_sw_if_index_vec_by_acl)[acln], sw_if_index);
}
- }));
+ }
/* *INDENT-ON* */
vec_free ((*pinout_acl_vec_by_sw_if_index)[sw_if_index]);
diff --git a/src/plugins/cnat/cnat_snat.c b/src/plugins/cnat/cnat_snat.c
index cc83dce4b20..7c799065b57 100644
--- a/src/plugins/cnat/cnat_snat.c
+++ b/src/plugins/cnat/cnat_snat.c
@@ -25,11 +25,11 @@ cnat_compute_prefix_lengths_in_search_order (cnat_snat_pfx_table_t *
vec_reset_length (table->meta[af].prefix_lengths_in_search_order);
/* Note: bitmap reversed so this is in fact a longest prefix match */
/* *INDENT-OFF* */
- clib_bitmap_foreach (i, table->meta[af].non_empty_dst_address_length_bitmap,
- ({
+ clib_bitmap_foreach (i, table->meta[af].non_empty_dst_address_length_bitmap)
+ {
int dst_address_length = 128 - i;
vec_add1 (table->meta[af].prefix_lengths_in_search_order, dst_address_length);
- }));
+ }
/* *INDENT-ON* */
}
diff --git a/src/plugins/dpdk/device/device.c b/src/plugins/dpdk/device/device.c
index 7a86ee0fe6b..4d26abde214 100644
--- a/src/plugins/dpdk/device/device.c
+++ b/src/plugins/dpdk/device/device.c
@@ -629,14 +629,14 @@ dpdk_interface_set_rss_queues (struct vnet_main_t *vnm,
valid_queue_count = 0;
/* *INDENT-OFF* */
- clib_bitmap_foreach (i, bitmap, ({
+ clib_bitmap_foreach (i, bitmap) {
if (i >= dev_info.nb_rx_queues)
{
err = clib_error_return (0, "illegal queue number");
goto done;
}
reta[valid_queue_count++] = i;
- }));
+ }
/* *INDENT-ON* */
/* check valid_queue_count not zero, make coverity happy */
diff --git a/src/plugins/dpdk/device/init.c b/src/plugins/dpdk/device/init.c
index bd8d435975c..19898b186fe 100644
--- a/src/plugins/dpdk/device/init.c
+++ b/src/plugins/dpdk/device/init.c
@@ -707,10 +707,10 @@ dpdk_lib_init (dpdk_main_t * dm)
{
int i;
q = 0;
- clib_bitmap_foreach (i, devconf->workers, ({
+ clib_bitmap_foreach (i, devconf->workers) {
vnet_hw_interface_assign_rx_thread (dm->vnet_main, xd->hw_if_index, q++,
vdm->first_worker_thread_index + i);
- }));
+ }
}
else
for (q = 0; q < xd->rx_q_used; q++)
@@ -1354,7 +1354,7 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input)
default_hugepage_sz = clib_mem_get_default_hugepage_size ();
/* *INDENT-OFF* */
- clib_bitmap_foreach (x, tm->cpu_socket_bitmap, (
+ clib_bitmap_foreach (x, tm->cpu_socket_bitmap)
{
clib_error_t *e;
uword n_pages;
@@ -1365,7 +1365,7 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input)
if ((e = clib_sysfs_prealloc_hugepages(x, 0, n_pages)))
clib_error_report (e);
- }));
+ }
/* *INDENT-ON* */
}
diff --git a/src/plugins/lisp/lisp-cp/gid_dictionary.c b/src/plugins/lisp/lisp-cp/gid_dictionary.c
index 9b0af3f5c6d..a0cc9c09e3c 100644
--- a/src/plugins/lisp/lisp-cp/gid_dictionary.c
+++ b/src/plugins/lisp/lisp-cp/gid_dictionary.c
@@ -489,11 +489,11 @@ ip4_compute_prefix_lengths_in_search_order (gid_ip4_table_t * db)
/* Note: bitmap reversed so this is in fact a longest prefix match */
/* *INDENT-OFF* */
- clib_bitmap_foreach (i, db->ip4_non_empty_dst_address_length_bitmap,
- ({
+ clib_bitmap_foreach (i, db->ip4_non_empty_dst_address_length_bitmap)
+ {
int dst_address_length = 32 - i;
vec_add1 (db->ip4_prefix_lengths_in_search_order, dst_address_length);
- }));
+ }
/* *INDENT-ON* */
}
@@ -672,11 +672,11 @@ ip6_compute_prefix_lengths_in_search_order (gid_ip6_table_t * db)
/* Note: bitmap reversed so this is in fact a longest prefix match */
/* *INDENT-OFF* */
- clib_bitmap_foreach (i, db->ip6_non_empty_dst_address_length_bitmap,
- ({
+ clib_bitmap_foreach (i, db->ip6_non_empty_dst_address_length_bitmap)
+ {
int dst_address_length = 128 - i;
vec_add1 (db->ip6_prefix_lengths_in_search_order, dst_address_length);
- }));
+ }
/* *INDENT-ON* */
}
diff --git a/src/plugins/map/lpm.c b/src/plugins/map/lpm.c
index 4abeefca06d..c0e5bad1417 100644
--- a/src/plugins/map/lpm.c
+++ b/src/plugins/map/lpm.c
@@ -111,12 +111,12 @@ lpm_128_lookup (lpm_t *lpm, void *addr_v, u8 pfxlen)
ip6_address_t *addr = addr_v;
int i = 0, rv;
u32 value;
- clib_bitmap_foreach (i, lpm->prefix_lengths_bitmap,
- ({
+ clib_bitmap_foreach (i, lpm->prefix_lengths_bitmap)
+ {
rv = lpm_128_lookup_core(lpm, addr, i, &value);
if (rv == 0)
return value;
- }));
+ }
return ~0;
}
diff --git a/src/plugins/nat/nat.c b/src/plugins/nat/nat.c
index 0694c348c12..05c7afc2b16 100644
--- a/src/plugins/nat/nat.c
+++ b/src/plugins/nat/nat.c
@@ -1491,10 +1491,10 @@ nat44_add_del_lb_static_mapping (ip4_address_t e_addr, u16 e_port,
if (sm->num_workers > 1)
{
/* *INDENT-OFF* */
- clib_bitmap_foreach (i, bitmap,
- ({
+ clib_bitmap_foreach (i, bitmap)
+ {
vec_add1(m->workers, i);
- }));
+ }
/* *INDENT-ON* */
}
}
@@ -1739,7 +1739,7 @@ nat44_lb_static_mapping_add_del_local (ip4_address_t e_addr, u16 e_port,
if (sm->num_workers > 1)
{
/* *INDENT-OFF* */
- clib_bitmap_foreach (i, bitmap, ({ vec_add1(m->workers, i); }));
+ clib_bitmap_foreach (i, bitmap) { vec_add1(m->workers, i); }
/* *INDENT-ON* */
}
@@ -2467,13 +2467,13 @@ snat_set_workers (uword * bitmap)
vec_free (sm->workers);
/* *INDENT-OFF* */
- clib_bitmap_foreach (i, bitmap,
- ({
+ clib_bitmap_foreach (i, bitmap)
+ {
vec_add1(sm->workers, i);
sm->per_thread_data[sm->first_worker_index + i].snat_thread_index = j;
sm->per_thread_data[sm->first_worker_index + i].thread_index = i;
j++;
- }));
+ }
/* *INDENT-ON* */
sm->port_per_thread = (0xffff - 1024) / _vec_len (sm->workers);
diff --git a/src/plugins/nat/nat64/nat64.c b/src/plugins/nat/nat64/nat64.c
index ae7bb350436..6e5ceecb76f 100644
--- a/src/plugins/nat/nat64/nat64.c
+++ b/src/plugins/nat/nat64/nat64.c
@@ -283,10 +283,10 @@ nat64_init (vlib_main_t * vm)
bitmap = clib_bitmap_set (bitmap, i, 1);
/* *INDENT-OFF* */
- clib_bitmap_foreach (i, bitmap,
- ({
+ clib_bitmap_foreach (i, bitmap)
+ {
vec_add1(nm->workers, i);
- }));
+ }
/* *INDENT-ON* */
clib_bitmap_free (bitmap);
diff --git a/src/vcl/ldp.c b/src/vcl/ldp.c
index 0f2412bc70a..98ed4a9b1ab 100644
--- a/src/vcl/ldp.c
+++ b/src/vcl/ldp.c
@@ -632,7 +632,7 @@ ldp_select_init_maps (fd_set * __restrict original,
memset (original, 0, n_bytes);
/* *INDENT-OFF* */
- clib_bitmap_foreach (fd, *resultb, ({
+ clib_bitmap_foreach (fd, *resultb) {
if (fd > nfds)
break;
vlsh = ldp_fd_to_vlsh (fd);
@@ -640,7 +640,7 @@ ldp_select_init_maps (fd_set * __restrict original,
clib_bitmap_set_no_check (*libcb, fd, 1);
else
*vclb = clib_bitmap_set (*vclb, vlsh_to_session_index (vlsh), 1);
- }));
+ }
/* *INDENT-ON* */
si_bits_set = clib_bitmap_last_set (*vclb) + 1;
@@ -662,7 +662,7 @@ ldp_select_vcl_map_to_libc (clib_bitmap_t * vclb, fd_set * __restrict libcb)
return 0;
/* *INDENT-OFF* */
- clib_bitmap_foreach (si, vclb, ({
+ clib_bitmap_foreach (si, vclb) {
vlsh = vls_session_index_to_vlsh (si);
ASSERT (vlsh != VLS_INVALID_HANDLE);
fd = ldp_vlsh_to_fd (vlsh);
@@ -672,7 +672,7 @@ ldp_select_vcl_map_to_libc (clib_bitmap_t * vclb, fd_set * __restrict libcb)
return -1;
}
FD_SET (fd, libcb);
- }));
+ }
/* *INDENT-ON* */
return 0;
@@ -687,9 +687,8 @@ ldp_select_libc_map_merge (clib_bitmap_t * result, fd_set * __restrict libcb)
return;
/* *INDENT-OFF* */
- clib_bitmap_foreach (fd, result, ({
+ clib_bitmap_foreach (fd, result)
FD_SET ((int)fd, libcb);
- }));
/* *INDENT-ON* */
}
diff --git a/src/vcl/vcl_locked.c b/src/vcl/vcl_locked.c
index 5beaecdfa4b..f3136f9d2ae 100644
--- a/src/vcl/vcl_locked.c
+++ b/src/vcl/vcl_locked.c
@@ -1340,14 +1340,14 @@ vls_select_mp_checks (vcl_si_set * read_map)
wrk = vcl_worker_get_current ();
/* *INDENT-OFF* */
- clib_bitmap_foreach (si, read_map, ({
+ clib_bitmap_foreach (si, read_map) {
s = vcl_session_get (wrk, si);
if (s->session_state == VCL_STATE_LISTEN)
{
vls = vls_get (vls_session_index_to_vlsh (si));
vls_mp_checks (vls, 1 /* is_add */);
}
- }));
+ }
/* *INDENT-ON* */
}
diff --git a/src/vcl/vppcom.c b/src/vcl/vppcom.c
index abad979f566..58c13c28763 100644
--- a/src/vcl/vppcom.c
+++ b/src/vcl/vppcom.c
@@ -2454,7 +2454,7 @@ vppcom_select (int n_bits, vcl_si_set * read_map, vcl_si_set * write_map,
goto check_rd;
/* *INDENT-OFF* */
- clib_bitmap_foreach (sid, wrk->wr_bitmap, ({
+ clib_bitmap_foreach (sid, wrk->wr_bitmap) {
if (!(session = vcl_session_get (wrk, sid)))
{
clib_bitmap_set_no_check ((uword*)write_map, sid, 1);
@@ -2469,13 +2469,13 @@ vppcom_select (int n_bits, vcl_si_set * read_map, vcl_si_set * write_map,
}
else
svm_fifo_add_want_deq_ntf (session->tx_fifo, SVM_FIFO_WANT_DEQ_NOTIF);
- }));
+ }
check_rd:
if (!read_map)
goto check_mq;
- clib_bitmap_foreach (sid, wrk->rd_bitmap, ({
+ clib_bitmap_foreach (sid, wrk->rd_bitmap) {
if (!(session = vcl_session_get (wrk, sid)))
{
clib_bitmap_set_no_check ((uword*)read_map, sid, 1);
@@ -2488,7 +2488,7 @@ check_rd:
clib_bitmap_set_no_check ((uword*)read_map, sid, 1);
bits_set++;
}
- }));
+ }
/* *INDENT-ON* */
check_mq:
diff --git a/src/vlib/buffer.c b/src/vlib/buffer.c
index a30fca32d8b..e1c871c2a2a 100644
--- a/src/vlib/buffer.c
+++ b/src/vlib/buffer.c
@@ -886,7 +886,7 @@ vlib_buffer_main_init (struct vlib_main_t * vm)
VLIB_BUFFER_MAX_NUMA_NODES);
/* *INDENT-OFF* */
- clib_bitmap_foreach (numa_node, bmp,
+ clib_bitmap_foreach (numa_node, bmp)
{
u8 *index = bm->default_buffer_pool_index_for_numa + numa_node;
index[0] = ~0;
@@ -899,7 +899,7 @@ vlib_buffer_main_init (struct vlib_main_t * vm)
if (first_valid_buffer_pool_index == 0xff)
first_valid_buffer_pool_index = index[0];
- });
+ }
/* *INDENT-ON* */
if (first_valid_buffer_pool_index == (u8) ~ 0)
@@ -909,12 +909,12 @@ vlib_buffer_main_init (struct vlib_main_t * vm)
}
/* *INDENT-OFF* */
- clib_bitmap_foreach (numa_node, bmp,
+ clib_bitmap_foreach (numa_node, bmp)
{
if (bm->default_buffer_pool_index_for_numa[numa_node] == (u8) ~0)
bm->default_buffer_pool_index_for_numa[numa_node] =
first_valid_buffer_pool_index;
- });
+ }
/* *INDENT-ON* */
vec_foreach (bp, bm->buffer_pools)
diff --git a/src/vlib/cli.c b/src/vlib/cli.c
index db82dede152..e1db95d6af9 100644
--- a/src/vlib/cli.c
+++ b/src/vlib/cli.c
@@ -304,7 +304,7 @@ vlib_cli_get_possible_completions (u8 * str)
* autocomplete the next level of subcommands */
help_next_level = (vec_len (str) == 0) || isspace (str[vec_len (str) - 1]);
/* *INDENT-OFF* */
- clib_bitmap_foreach(index, match_bitmap, {
+ clib_bitmap_foreach (index, match_bitmap) {
if (help_next_level && is_unique) {
c = get_sub_command (vcm, c, index);
vec_foreach (sc, c->sub_commands) {
@@ -314,7 +314,7 @@ vlib_cli_get_possible_completions (u8 * str)
}
sc = &c->sub_commands[index];
vec_add1(result, (u8*) sc->name);
- });
+ }
/* *INDENT-ON* */
done:
diff --git a/src/vlib/node.c b/src/vlib/node.c
index 387b774f305..cf65f297d6a 100644
--- a/src/vlib/node.c
+++ b/src/vlib/node.c
@@ -223,14 +223,14 @@ vlib_node_add_next_with_slot (vlib_main_t * vm,
uword sib_node_index, sib_slot;
vlib_node_t *sib_node;
/* *INDENT-OFF* */
- clib_bitmap_foreach (sib_node_index, node->sibling_bitmap, ({
+ clib_bitmap_foreach (sib_node_index, node->sibling_bitmap) {
sib_node = vec_elt (nm->nodes, sib_node_index);
if (sib_node != node)
{
sib_slot = vlib_node_add_next_with_slot (vm, sib_node_index, next_node_index, slot);
ASSERT (sib_slot == slot);
}
- }));
+ }
/* *INDENT-ON* */
}
@@ -627,7 +627,7 @@ vlib_node_main_init (vlib_main_t * vm)
}
/* *INDENT-OFF* */
- clib_bitmap_foreach (si, sib->sibling_bitmap, ({
+ clib_bitmap_foreach (si, sib->sibling_bitmap) {
vlib_node_t * m = vec_elt (nm->nodes, si);
/* Connect all of sibling's siblings to us. */
@@ -635,7 +635,7 @@ vlib_node_main_init (vlib_main_t * vm)
/* Connect us to all of sibling's siblings. */
n->sibling_bitmap = clib_bitmap_ori (n->sibling_bitmap, si);
- }));
+ }
/* *INDENT-ON* */
/* Connect sibling to us. */
diff --git a/src/vlib/node_cli.c b/src/vlib/node_cli.c
index 7cfc4a36f8c..c5458b218bf 100644
--- a/src/vlib/node_cli.c
+++ b/src/vlib/node_cli.c
@@ -658,14 +658,14 @@ show_node (vlib_main_t * vm, unformat_input_t * input,
{
int j = 0;
/* *INDENT-OFF* */
- clib_bitmap_foreach (i, n->prev_node_bitmap, ({
+ clib_bitmap_foreach (i, n->prev_node_bitmap) {
vlib_node_t *pn = vlib_get_node (vm, i);
if (j++ % 3 == 0)
s = format (s, "\n ");
s2 = format (s2, "%v (%u)", pn->name, i);
s = format (s, "%-35v", s2);
vec_reset_length (s2);
- }));
+ }
/* *INDENT-ON* */
if (vec_len (s) == 0)
diff --git a/src/vlib/node_format.c b/src/vlib/node_format.c
index 19ebfc15b74..822a8f64e1a 100644
--- a/src/vlib/node_format.c
+++ b/src/vlib/node_format.c
@@ -74,11 +74,11 @@ format_vlib_node_graph (u8 * s, va_list * va)
j = 0;
/* *INDENT-OFF* */
- clib_bitmap_foreach (i, n->prev_node_bitmap, ({
+ clib_bitmap_foreach (i, n->prev_node_bitmap) {
vec_validate_init_empty (tmps, j, empty);
tmps[j].prev_node = i;
j++;
- }));
+ }
/* *INDENT-ON* */
for (i = 0; i < vec_len (tmps); i++)
diff --git a/src/vlib/threads.c b/src/vlib/threads.c
index 749770f9597..7efddff54e8 100644
--- a/src/vlib/threads.c
+++ b/src/vlib/threads.c
@@ -320,13 +320,13 @@ vlib_thread_init (vlib_main_t * vm)
{
uword c;
/* *INDENT-OFF* */
- clib_bitmap_foreach (c, tr->coremask, ({
+ clib_bitmap_foreach (c, tr->coremask) {
if (clib_bitmap_get(avail_cpu, c) == 0)
return clib_error_return (0, "cpu %u is not available to be used"
" for the '%s' thread",c, tr->name);
avail_cpu = clib_bitmap_set(avail_cpu, c, 0);
- }));
+ }
/* *INDENT-ON* */
}
else
@@ -606,14 +606,14 @@ vlib_get_thread_core_numa (vlib_worker_thread_t * w, unsigned cpu_id)
/* *INDENT-OFF* */
clib_sysfs_read ("/sys/devices/system/node/online", "%U",
unformat_bitmap_list, &nbmp);
- clib_bitmap_foreach (node, nbmp, ({
+ clib_bitmap_foreach (node, nbmp) {
p = format (p, "%s%u/cpulist%c", sys_node_path, node, 0);
clib_sysfs_read ((char *) p, "%U", unformat_bitmap_list, &cbmp);
if (clib_bitmap_get (cbmp, cpu_id))
numa_id = node;
vec_reset_length (cbmp);
vec_reset_length (p);
- }));
+ }
/* *INDENT-ON* */
vec_free (nbmp);
vec_free (cbmp);
@@ -976,13 +976,13 @@ start_workers (vlib_main_t * vm)
{
uword c;
/* *INDENT-OFF* */
- clib_bitmap_foreach (c, tr->coremask, ({
+ clib_bitmap_foreach (c, tr->coremask) {
w = vlib_worker_threads + worker_thread_index++;
err = vlib_launch_thread_int (vlib_worker_thread_bootstrap_fn,
w, c);
if (err)
clib_error_report (err);
- }));
+ }
/* *INDENT-ON* */
}
}
diff --git a/src/vnet/crypto/node.c b/src/vnet/crypto/node.c
index 12e6033ad80..63ed95e7d93 100644
--- a/src/vnet/crypto/node.c
+++ b/src/vnet/crypto/node.c
@@ -161,10 +161,10 @@ VLIB_NODE_FN (crypto_dispatch_node) (vlib_main_t * vm,
u32 index;
/* *INDENT-OFF* */
- clib_bitmap_foreach (index, cm->async_active_ids, ({
+ clib_bitmap_foreach (index, cm->async_active_ids) {
n_cache = crypto_dequeue_frame (vm, node, ct, cm->dequeue_handlers[index],
n_cache, &n_dispatched);
- }));
+ }
/* *INDENT-ON* */
if (n_cache)
vlib_buffer_enqueue_to_next (vm, node, ct->buffer_indice, ct->nexts,
diff --git a/src/vnet/fib/ip6_fib.c b/src/vnet/fib/ip6_fib.c
index 6943166663f..62bf16f0efc 100644
--- a/src/vnet/fib/ip6_fib.c
+++ b/src/vnet/fib/ip6_fib.c
@@ -264,11 +264,11 @@ compute_prefix_lengths_in_search_order (ip6_fib_table_instance_t *table)
old = table->prefix_lengths_in_search_order;
/* Note: bitmap reversed so this is in fact a longest prefix match */
- clib_bitmap_foreach (i, table->non_empty_dst_address_length_bitmap,
- ({
+ clib_bitmap_foreach (i, table->non_empty_dst_address_length_bitmap)
+ {
int dst_address_length = 128 - i;
vec_add1(prefix_lengths_in_search_order, dst_address_length);
- }));
+ }
table->prefix_lengths_in_search_order = prefix_lengths_in_search_order;
diff --git a/src/vnet/handoff.c b/src/vnet/handoff.c
index ca46b5a7ab6..cbdc5289243 100644
--- a/src/vnet/handoff.c
+++ b/src/vnet/handoff.c
@@ -213,10 +213,10 @@ interface_handoff_enable_disable (vlib_main_t * vm, u32 sw_if_index,
{
d->workers_bitmap = bitmap;
/* *INDENT-OFF* */
- clib_bitmap_foreach (i, bitmap,
- ({
+ clib_bitmap_foreach (i, bitmap)
+ {
vec_add1(d->workers, i);
- }));
+ }
/* *INDENT-ON* */
}
diff --git a/src/vnet/interface_api.c b/src/vnet/interface_api.c
index 240f13fa418..a06f02fe0ac 100644
--- a/src/vnet/interface_api.c
+++ b/src/vnet/interface_api.c
@@ -1078,8 +1078,8 @@ static void vl_api_sw_interface_rx_placement_dump_t_handler
/* *INDENT-OFF* */
foreach_vlib_main (({
- clib_bitmap_foreach (si, pn->sibling_bitmap,
- ({
+ clib_bitmap_foreach (si, pn->sibling_bitmap)
+ {
rt = vlib_node_get_runtime_data (this_vlib_main, si);
vec_foreach (dq, rt->devices_and_queues)
{
@@ -1088,7 +1088,7 @@ static void vl_api_sw_interface_rx_placement_dump_t_handler
send_interface_rx_placement_details (am, reg, hw->sw_if_index, index,
dq->queue_id, dq->mode, mp->context);
}
- }));
+ }
index++;
}));
/* *INDENT-ON* */
diff --git a/src/vnet/interface_cli.c b/src/vnet/interface_cli.c
index 73f70cf5b1b..c9f11546b31 100644
--- a/src/vnet/interface_cli.c
+++ b/src/vnet/interface_cli.c
@@ -139,12 +139,12 @@ show_or_clear_hw_interfaces (vlib_main_t * vm,
hi, verbose);
/* *INDENT-OFF* */
- clib_bitmap_foreach (hw_idx, hi->bond_info,
- ({
+ clib_bitmap_foreach (hw_idx, hi->bond_info)
+ {
shi = vnet_get_hw_interface(vnm, hw_idx);
vlib_cli_output (vm, "%U\n",
format_vnet_hw_interface, vnm, shi, verbose);
- }));
+ }
/* *INDENT-ON* */
}
}
@@ -1663,8 +1663,8 @@ show_interface_rx_placement_fn (vlib_main_t * vm, unformat_input_t * input,
/* *INDENT-OFF* */
foreach_vlib_main (({
- clib_bitmap_foreach (si, pn->sibling_bitmap,
- ({
+ clib_bitmap_foreach (si, pn->sibling_bitmap)
+ {
rt = vlib_node_get_runtime_data (this_vlib_main, si);
if (vec_len (rt->devices_and_queues))
@@ -1679,7 +1679,7 @@ show_interface_rx_placement_fn (vlib_main_t * vm, unformat_input_t * input,
dq->queue_id,
format_vnet_hw_if_rx_mode, dq->mode);
}
- }));
+ }
if (vec_len (s) > 0)
{
vlib_cli_output(vm, "Thread %u (%s):\n%v", index,
diff --git a/src/vnet/interface_format.c b/src/vnet/interface_format.c
index a2adc9bbb02..9038e5d96e7 100644
--- a/src/vnet/interface_format.c
+++ b/src/vnet/interface_format.c
@@ -142,9 +142,9 @@ format_vnet_hw_interface_rss_queues (u8 * s, va_list * args)
if (bitmap)
{
/* *INDENT-OFF* */
- clib_bitmap_foreach (i, bitmap, ({
+ clib_bitmap_foreach (i, bitmap) {
s = format (s, "%u ", i);
- }));
+ }
/* *INDENT-ON* */
}
@@ -181,8 +181,8 @@ format_vnet_hw_interface (u8 * s, va_list * args)
{
int hw_idx;
s = format (s, "Slave-Idx:");
- clib_bitmap_foreach (hw_idx, hi->bond_info, s =
- format (s, " %d", hw_idx));
+ clib_bitmap_foreach (hw_idx, hi->bond_info)
+ s = format (s, " %d", hw_idx);
}
else if (dev_class->format_device_name)
s = format (s, "%U", dev_class->format_device_name, hi->dev_instance);
diff --git a/src/vnet/l2/l2_rw.c b/src/vnet/l2/l2_rw.c
index 59b7de91279..a7c95fe1a77 100644
--- a/src/vnet/l2/l2_rw.c
+++ b/src/vnet/l2/l2_rw.c
@@ -498,9 +498,9 @@ l2_rw_show_interfaces_cli_fn (vlib_main_t * vm,
uword i;
/* *INDENT-OFF* */
- clib_bitmap_foreach(i, rw->configs_bitmap, {
+ clib_bitmap_foreach (i, rw->configs_bitmap) {
vlib_cli_output (vm, "sw_if_index:%d %U\n", i, format_l2_rw_config, &rw->configs[i]);
- });
+ }
/* *INDENT-ON* */
return 0;
}
diff --git a/src/vnet/mfib/ip6_mfib.c b/src/vnet/mfib/ip6_mfib.c
index b5e5bce8ffc..bbab7ae2214 100644
--- a/src/vnet/mfib/ip6_mfib.c
+++ b/src/vnet/mfib/ip6_mfib.c
@@ -457,10 +457,10 @@ compute_prefix_lengths_in_search_order (ip6_mfib_table_instance_t *table)
int i;
vec_reset_length (table->prefix_lengths_in_search_order);
/* Note: bitmap reversed so this is in fact a longest prefix match */
- clib_bitmap_foreach (i, table->non_empty_dst_address_length_bitmap,
- ({
+ clib_bitmap_foreach (i, table->non_empty_dst_address_length_bitmap)
+ {
vec_add1(table->prefix_lengths_in_search_order, (256 - i));
- }));
+ }
}
void
diff --git a/src/vnet/pg/input.c b/src/vnet/pg/input.c
index 63031cef35d..940bf124c56 100644
--- a/src/vnet/pg/input.c
+++ b/src/vnet/pg/input.c
@@ -1808,10 +1808,10 @@ pg_input (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
worker_index = vlib_get_current_worker_index ();
/* *INDENT-OFF* */
- clib_bitmap_foreach (i, pg->enabled_streams[worker_index], ({
+ clib_bitmap_foreach (i, pg->enabled_streams[worker_index]) {
pg_stream_t *s = vec_elt_at_index (pg->streams, i);
n_packets += pg_input_stream (node, pg, s);
- }));
+ }
/* *INDENT-ON* */
return n_packets;
diff --git a/src/vnet/span/node.c b/src/vnet/span/node.c
index 1a9d1bae724..ca5ea68ae90 100644
--- a/src/vnet/span/node.c
+++ b/src/vnet/span/node.c
@@ -85,7 +85,7 @@ span_mirror (vlib_main_t * vm, vlib_node_runtime_t * node, u32 sw_if_index0,
return;
/* *INDENT-OFF* */
- clib_bitmap_foreach (i, sm0->mirror_ports, (
+ clib_bitmap_foreach (i, sm0->mirror_ports)
{
if (mirror_frames[i] == 0)
{
@@ -121,7 +121,7 @@ span_mirror (vlib_main_t * vm, vlib_node_runtime_t * node, u32 sw_if_index0,
#endif
}
}
- }));
+ }
/* *INDENT-ON* */
}
diff --git a/src/vnet/span/span.c b/src/vnet/span/span.c
index fc923e0ce31..ec47920504a 100644
--- a/src/vnet/span/span.c
+++ b/src/vnet/span/span.c
@@ -212,7 +212,7 @@ show_interfaces_span_command_fn (vlib_main_t * vm,
}
s = format (s, "%U", format_vnet_sw_if_index_name, vnm,
si - sm->interfaces);
- clib_bitmap_foreach (i, b, (
+ clib_bitmap_foreach (i, b)
{
int device = (clib_bitmap_get (drxm->mirror_ports, i) +
clib_bitmap_get (dtxm->mirror_ports, i) * 2);
@@ -223,7 +223,7 @@ show_interfaces_span_command_fn (vlib_main_t * vm,
format_vnet_sw_if_index_name, vnm, i,
states[device], states[l2]);
vec_reset_length (s);
- }));
+ }
clib_bitmap_free (b);
clib_bitmap_free (l);
clib_bitmap_free (d);
diff --git a/src/vnet/span/span_api.c b/src/vnet/span/span_api.c
index dacbe2e0aa9..96d1facc2df 100644
--- a/src/vnet/span/span_api.c
+++ b/src/vnet/span/span_api.c
@@ -86,7 +86,7 @@ vl_api_sw_interface_span_dump_t_handler (vl_api_sw_interface_span_dump_t * mp)
clib_bitmap_t *b;
u32 i;
b = clib_bitmap_dup_or (rxm->mirror_ports, txm->mirror_ports);
- clib_bitmap_foreach (i, b, (
+ clib_bitmap_foreach (i, b)
{
rmp = vl_msg_api_alloc (sizeof (*rmp));
clib_memset (rmp, 0, sizeof (*rmp));
@@ -100,7 +100,7 @@ vl_api_sw_interface_span_dump_t_handler (vl_api_sw_interface_span_dump_t * mp)
rmp->is_l2 = mp->is_l2;
vl_api_send_msg (reg, (u8 *) rmp);
- }));
+ }
clib_bitmap_free (b);
}
}
diff --git a/src/vpp/api/gmon.c b/src/vpp/api/gmon.c
index a8eecbbde19..b3244452c7b 100644
--- a/src/vpp/api/gmon.c
+++ b/src/vpp/api/gmon.c
@@ -74,8 +74,8 @@ get_significant_errors (gmon_main_t * gm)
u64 significant_errors = 0;
/* *INDENT-OFF* */
- clib_bitmap_foreach (code, gm->sig_error_bitmap,
- ({
+ clib_bitmap_foreach (code, gm->sig_error_bitmap)
+ {
for (vm_index = 0; vm_index < vec_len (gm->my_vlib_mains); vm_index++)
{
this_vlib_main = gm->my_vlib_mains[vm_index];
@@ -84,7 +84,7 @@ get_significant_errors (gmon_main_t * gm)
((vec_len(em->counters_last_clear) > code) ?
em->counters_last_clear[code] : 0);
}
- }));
+ }
/* *INDENT-ON* */
return (significant_errors);
diff --git a/src/vppinfra/bitmap.h b/src/vppinfra/bitmap.h
index 44411163975..5c56068da77 100644
--- a/src/vppinfra/bitmap.h
+++ b/src/vppinfra/bitmap.h
@@ -358,7 +358,13 @@ clib_bitmap_set_region (uword * bitmap, uword i, uword value, uword n_bits)
@param ai - the bitmap
@param body - the expression to evaluate for each set bit
*/
-#define clib_bitmap_foreach(i,ai,body) \
+#define clib_bitmap_foreach(i,ai) \
+ if (ai) \
+ for (i = clib_bitmap_first_set (ai); \
+ i != ~0; \
+ i = clib_bitmap_next_set (ai, i + 1))
+
+#define clib_bitmap_foreach_old(i,ai,body) \
do { \
uword __bitmap_i, __bitmap_ai, __bitmap_len, __bitmap_first_set; \
__bitmap_len = vec_len ((ai)); \
diff --git a/src/vppinfra/elf.c b/src/vppinfra/elf.c
index e32d989a602..c492b3b0795 100644
--- a/src/vppinfra/elf.c
+++ b/src/vppinfra/elf.c
@@ -1705,7 +1705,7 @@ layout_sections (elf_main_t * em)
s_lo = s_hi = 0;
/* *INDENT-OFF* */
- clib_bitmap_foreach (si, g->section_index_bitmap, ({
+ clib_bitmap_foreach (si, g->section_index_bitmap) {
u64 lo, hi;
s = vec_elt_at_index (em->sections, si);
@@ -1728,7 +1728,7 @@ layout_sections (elf_main_t * em)
if (hi > s_hi)
s_hi = hi;
}
- }));
+ }
/* *INDENT-ON* */
if (n_sections == 0)
diff --git a/src/vppinfra/timing_wheel.c b/src/vppinfra/timing_wheel.c
index a6c476b2cfa..2c46d72a2fe 100644
--- a/src/vppinfra/timing_wheel.c
+++ b/src/vppinfra/timing_wheel.c
@@ -303,11 +303,11 @@ timing_wheel_insert (timing_wheel_t * w, u64 insert_cpu_time, u32 user_data)
vec_foreach (l, w->levels)
{
/* *INDENT-OFF* */
- clib_bitmap_foreach (wi, l->occupancy_bitmap, ({
+ clib_bitmap_foreach (wi, l->occupancy_bitmap) {
l->elts[wi] = delete_user_data (l->elts[wi], user_data);
if (vec_len (l->elts[wi]) == 0)
l->occupancy_bitmap = clib_bitmap_andnoti (l->occupancy_bitmap, wi);
- }));
+ }
/* *INDENT-ON* */
}
@@ -486,7 +486,7 @@ advance_cpu_time_base (timing_wheel_t * w, u32 * expired_user_data)
{
uword wi;
/* *INDENT-OFF* */
- clib_bitmap_foreach (wi, l->occupancy_bitmap, ({
+ clib_bitmap_foreach (wi, l->occupancy_bitmap) {
vec_foreach (e, l->elts[wi])
{
/* This should always be true since otherwise we would have already expired
@@ -495,7 +495,7 @@ advance_cpu_time_base (timing_wheel_t * w, u32 * expired_user_data)
ASSERT (e->cpu_time_relative_to_base >= delta);
e->cpu_time_relative_to_base -= delta;
}
- }));
+ }
/* *INDENT-ON* */
}
@@ -648,10 +648,10 @@ timing_wheel_advance (timing_wheel_t * w, u64 advance_cpu_time,
level = vec_elt_at_index (w->levels, level_index);
/* *INDENT-OFF* */
- clib_bitmap_foreach (wi, level->occupancy_bitmap, ({
+ clib_bitmap_foreach (wi, level->occupancy_bitmap) {
expired_user_data = expire_bin (w, level_index, wi, advance_cpu_time,
expired_user_data);
- }));
+ }
/* *INDENT-ON* */
}