misc: refactor clib_bitmap_foreach macro 97/30397/2
authorDamjan Marion <damarion@cisco.com>
Sun, 13 Dec 2020 22:26:56 +0000 (23:26 +0100)
committerDave Barach <openvpp@barachs.net>
Mon, 14 Dec 2020 12:14:21 +0000 (12:14 +0000)
Type: refactor
Change-Id: I077110e1a422722e20aa546a6f3224c06ab0cde5
Signed-off-by: Damjan Marion <damarion@cisco.com>
33 files changed:
src/plugins/acl/acl.c
src/plugins/cnat/cnat_snat.c
src/plugins/dpdk/device/device.c
src/plugins/dpdk/device/init.c
src/plugins/lisp/lisp-cp/gid_dictionary.c
src/plugins/map/lpm.c
src/plugins/nat/nat.c
src/plugins/nat/nat64/nat64.c
src/vcl/ldp.c
src/vcl/vcl_locked.c
src/vcl/vppcom.c
src/vlib/buffer.c
src/vlib/cli.c
src/vlib/node.c
src/vlib/node_cli.c
src/vlib/node_format.c
src/vlib/threads.c
src/vnet/crypto/node.c
src/vnet/fib/ip6_fib.c
src/vnet/handoff.c
src/vnet/interface_api.c
src/vnet/interface_cli.c
src/vnet/interface_format.c
src/vnet/l2/l2_rw.c
src/vnet/mfib/ip6_mfib.c
src/vnet/pg/input.c
src/vnet/span/node.c
src/vnet/span/span.c
src/vnet/span/span_api.c
src/vpp/api/gmon.c
src/vppinfra/bitmap.h
src/vppinfra/elf.c
src/vppinfra/timing_wheel.c

index 05251c6..35f8b8c 100644 (file)
@@ -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]);
index cc83dce..7c79906 100644 (file)
@@ -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* */
 }
 
index 7a86ee0..4d26abd 100644 (file)
@@ -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 */
index bd8d435..19898b1 100644 (file)
@@ -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* */
     }
 
index 9b0af3f..a0cc9c0 100644 (file)
@@ -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* */
 }
 
index 4abeefc..c0e5bad 100644 (file)
@@ -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;
 }
 
index 0694c34..05c7afc 100644 (file)
@@ -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);
index ae7bb35..6e5ceec 100644 (file)
@@ -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);
index 0f2412b..98ed4a9 100644 (file)
@@ -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* */
 }
 
index 5beaecd..f3136f9 100644 (file)
@@ -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* */
 }
 
index abad979..58c13c2 100644 (file)
@@ -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:
index a30fca3..e1c871c 100644 (file)
@@ -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)
index db82ded..e1db95d 100644 (file)
@@ -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:
index 387b774..cf65f29 100644 (file)
@@ -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. */
index 7cfc4a3..c5458b2 100644 (file)
@@ -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)
index 19ebfc1..822a8f6 100644 (file)
@@ -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++)
index 749770f..7efddff 100644 (file)
@@ -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* */
        }
     }
index 12e6033..63ed95e 100644 (file)
@@ -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,
index 6943166..62bf16f 100644 (file)
@@ -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;
 
index ca46b5a..cbdc528 100644 (file)
@@ -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* */
     }
 
index 240f13f..a06f02f 100644 (file)
@@ -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* */
index 73f70cf..c9f1154 100644 (file)
@@ -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,
index a2adc9b..9038e5d 100644 (file)
@@ -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);
index 59b7de9..a7c95fe 100644 (file)
@@ -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;
 }
index b5e5bce..bbab7ae 100644 (file)
@@ -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
index 63031ce..940bf12 100644 (file)
@@ -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;
index 1a9d1ba..ca5ea68 100644 (file)
@@ -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* */
 }
 
index fc923e0..ec47920 100644 (file)
@@ -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);
index dacbe2e..96d1fac 100644 (file)
@@ -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);
     }
     }
index a8eecbb..b324445 100644 (file)
@@ -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);
index 4441116..5c56068 100644 (file)
@@ -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));                                       \
index e32d989..c492b3b 100644 (file)
@@ -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)
index a6c476b..2c46d72 100644 (file)
@@ -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* */
     }