aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2022-04-04 22:40:45 +0200
committerDamjan Marion <dmarion@me.com>2022-04-04 23:17:13 +0000
commit8bea589cfe0fca1a6f560e16ca66a4cf199041a2 (patch)
treecf2767f8f5f31344468b65e14baa3f1a4c85fb91 /src
parenta2b358b1faf6e762e1d29a931d83c7735ac9a77d (diff)
vppinfra: make _vec_len() read-only
Use of _vec_len() to set vector length breaks address sanitizer. Users should use vec_set_len(), vec_inc_len(), vec_dec_len () instead. Type: improvement Change-Id: I441ae948771eb21c23a61f3ff9163bdad74a2cb8 Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src')
-rw-r--r--src/examples/vlib/main_stub.c2
-rw-r--r--src/examples/vlib/mc_test.c2
-rw-r--r--src/plugins/acl/acl.c2
-rw-r--r--src/plugins/acl/acl_test.c24
-rw-r--r--src/plugins/acl/hash_lookup.c4
-rw-r--r--src/plugins/acl/sess_mgmt_node.c7
-rw-r--r--src/plugins/builtinurl/builtins.c2
-rw-r--r--src/plugins/cdp/cdp_input.c39
-rw-r--r--src/plugins/cdp/cdp_periodic.c4
-rw-r--r--src/plugins/dhcp/dhcp6_pd_client_cp.c2
-rw-r--r--src/plugins/dns/dns.c8
-rw-r--r--src/plugins/dns/request_node.c2
-rw-r--r--src/plugins/dpdk/device/cli.c6
-rw-r--r--src/plugins/dpdk/device/dpdk_priv.h4
-rw-r--r--src/plugins/dpdk/device/init.c4
-rw-r--r--src/plugins/gtpu/gtpu.c4
-rw-r--r--src/plugins/hs_apps/echo_client.c2
-rw-r--r--src/plugins/hs_apps/http_cli.c4
-rw-r--r--src/plugins/http/http.c2
-rw-r--r--src/plugins/http_static/builtinurl/json_urls.c2
-rw-r--r--src/plugins/http_static/static_server.c2
-rw-r--r--src/plugins/ikev2/ikev2_crypto.c6
-rw-r--r--src/plugins/ioam/export-common/ioam_export.h2
-rw-r--r--src/plugins/l2tp/l2tp.c2
-rw-r--r--src/plugins/lacp/input.c6
-rw-r--r--src/plugins/lb/lb.c2
-rw-r--r--src/plugins/lisp/lisp-cp/control.c2
-rw-r--r--src/plugins/lisp/lisp-gpe/interface.c2
-rw-r--r--src/plugins/lldp/lldp_input.c4
-rw-r--r--src/plugins/lldp/lldp_node.c2
-rw-r--r--src/plugins/memif/device.c4
-rw-r--r--src/plugins/memif/memif.c2
-rw-r--r--src/plugins/memif/memif_api.c2
-rw-r--r--src/plugins/nsh/nsh_api.c2
-rw-r--r--src/plugins/pppoe/pppoe.c2
-rw-r--r--src/plugins/snort/enqueue.c2
-rw-r--r--src/plugins/unittest/bihash_test.c2
-rw-r--r--src/plugins/unittest/bitmap_test.c2
-rw-r--r--src/plugins/unittest/fib_test.c4
-rw-r--r--src/plugins/unittest/svm_fifo_test.c2
-rw-r--r--src/plugins/vmxnet3/vmxnet3_api.c4
-rw-r--r--src/svm/svmdb.c10
-rw-r--r--src/tools/perftool/cpel_util.c2
-rw-r--r--src/tools/perftool/cpelinreg.c10
-rw-r--r--src/vat/api_format.c4
-rw-r--r--src/vat/main.c2
-rw-r--r--src/vat/plugin.c2
-rw-r--r--src/vat2/plugin.c2
-rw-r--r--src/vcl/vcl_cfg.c2
-rw-r--r--src/vlib/cli.c4
-rw-r--r--src/vlib/lex.c6
-rw-r--r--src/vlib/main.c14
-rw-r--r--src/vlib/node_funcs.h4
-rw-r--r--src/vlib/threads.c10
-rw-r--r--src/vlib/trace.c2
-rw-r--r--src/vlib/trace_funcs.h2
-rw-r--r--src/vlib/unix/cli.c36
-rw-r--r--src/vlib/unix/main.c2
-rw-r--r--src/vlib/unix/mc_socket.c12
-rw-r--r--src/vlib/unix/util.c6
-rw-r--r--src/vlibapi/node_serialize.c2
-rw-r--r--src/vlibmemory/memclnt_api.c2
-rw-r--r--src/vlibmemory/memory_shared.c4
-rw-r--r--src/vlibmemory/socket_client.c14
-rw-r--r--src/vlibmemory/vlib_api_cli.c4
-rw-r--r--src/vnet/bfd/bfd_main.c4
-rw-r--r--src/vnet/classify/vnet_classify.c6
-rw-r--r--src/vnet/config.c4
-rw-r--r--src/vnet/devices/af_packet/node.c5
-rw-r--r--src/vnet/dpo/load_balance.c6
-rw-r--r--src/vnet/dpo/load_balance_map.c2
-rw-r--r--src/vnet/fib/fib_path_list.c3
-rw-r--r--src/vnet/fib/fib_urpf_list.c2
-rw-r--r--src/vnet/gso/node.c2
-rw-r--r--src/vnet/interface.c4
-rw-r--r--src/vnet/interface_cli.c4
-rw-r--r--src/vnet/interface_format.c4
-rw-r--r--src/vnet/ip/ip_api.c2
-rw-r--r--src/vnet/ip/reass/ip4_full_reass.c2
-rw-r--r--src/vnet/ip/reass/ip4_sv_reass.c5
-rw-r--r--src/vnet/ip/reass/ip6_full_reass.c2
-rw-r--r--src/vnet/ip/reass/ip6_sv_reass.c5
-rw-r--r--src/vnet/ipsec/ipsec_cli.c2
-rw-r--r--src/vnet/l2/l2_input.c2
-rw-r--r--src/vnet/pg/input.c2
-rw-r--r--src/vnet/pg/pg.h2
-rw-r--r--src/vnet/tcp/tcp_debug.c2
-rw-r--r--src/vnet/tcp/tcp_input.c6
-rw-r--r--src/vnet/udp/udp_inlines.h2
-rw-r--r--src/vnet/unix/tuntap.c6
-rw-r--r--src/vnet/vxlan-gpe/vxlan_gpe.c2
-rw-r--r--src/vpp/api/api_main.c2
-rw-r--r--src/vpp/api/plugin.c2
-rw-r--r--src/vppinfra/bitmap.h51
-rw-r--r--src/vppinfra/elf.c2
-rw-r--r--src/vppinfra/elog.c2
-rw-r--r--src/vppinfra/fifo.h2
-rw-r--r--src/vppinfra/format.c2
-rw-r--r--src/vppinfra/hash.c2
-rw-r--r--src/vppinfra/heap.c8
-rw-r--r--src/vppinfra/linux/mem.c2
-rw-r--r--src/vppinfra/linux/sysfs.c6
-rw-r--r--src/vppinfra/macros.c5
-rw-r--r--src/vppinfra/mem_dlmalloc.c2
-rw-r--r--src/vppinfra/mhash.c6
-rw-r--r--src/vppinfra/pool.h8
-rw-r--r--src/vppinfra/random_buffer.h2
-rw-r--r--src/vppinfra/serialize.c10
-rw-r--r--src/vppinfra/socket.c4
-rw-r--r--src/vppinfra/sparse_vec.h2
-rw-r--r--src/vppinfra/test_bihash_template.c3
-rw-r--r--src/vppinfra/test_fpool.c2
-rw-r--r--src/vppinfra/test_socket.c2
-rw-r--r--src/vppinfra/timing_wheel.c8
-rw-r--r--src/vppinfra/tw_timer_template.c4
-rw-r--r--src/vppinfra/unformat.c6
-rw-r--r--src/vppinfra/unix-misc.c2
-rw-r--r--src/vppinfra/vec.c2
-rw-r--r--src/vppinfra/vec_bootstrap.h20
119 files changed, 300 insertions, 299 deletions
diff --git a/src/examples/vlib/main_stub.c b/src/examples/vlib/main_stub.c
index 3735055d789..ef6475ca657 100644
--- a/src/examples/vlib/main_stub.c
+++ b/src/examples/vlib/main_stub.c
@@ -181,7 +181,7 @@ my_proc (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f)
vlib_cli_output (vm, "%U %v: completion #%d type %d data 0x%wx",
format_time_interval, "h:m:s:u",
vlib_time_now (vm), node->name, i, type, data[0]);
- _vec_len (data) = 0;
+ vec_set_len (data, 0);
}
vec_free (data);
diff --git a/src/examples/vlib/mc_test.c b/src/examples/vlib/mc_test.c
index 464d07cc471..6d63be3a912 100644
--- a/src/examples/vlib/mc_test.c
+++ b/src/examples/vlib/mc_test.c
@@ -241,7 +241,7 @@ mc_test_process (vlib_main_t * vm,
}
if (event_data)
- _vec_len (event_data) = 0;
+ vec_set_len (event_data, 0);
}
}
diff --git a/src/plugins/acl/acl.c b/src/plugins/acl/acl.c
index 01a1e87a29b..a7b81049761 100644
--- a/src/plugins/acl/acl.c
+++ b/src/plugins/acl/acl.c
@@ -3736,7 +3736,7 @@ acl_init (vlib_main_t * vm)
vec_validate (pw->expired,
ACL_N_TIMEOUTS *
am->fa_max_deleted_sessions_per_interval);
- _vec_len (pw->expired) = 0;
+ vec_set_len (pw->expired, 0);
vec_validate_init_empty (pw->fa_conn_list_head, ACL_N_TIMEOUTS - 1,
FA_SESSION_BOGUS_INDEX);
vec_validate_init_empty (pw->fa_conn_list_tail, ACL_N_TIMEOUTS - 1,
diff --git a/src/plugins/acl/acl_test.c b/src/plugins/acl/acl_test.c
index 44abf30923d..7514a8e2e85 100644
--- a/src/plugins/acl/acl_test.c
+++ b/src/plugins/acl/acl_test.c
@@ -493,10 +493,10 @@ static int api_acl_add_replace (vat_main_t * vam)
if (vec_len(tag) >= sizeof(mp->tag))
{
tag[sizeof(mp->tag)-1] = 0;
- _vec_len(tag) = sizeof(mp->tag);
- }
- clib_memcpy(mp->tag, tag, vec_len(tag));
- vec_free(tag);
+ vec_set_len (tag, sizeof (mp->tag));
+ }
+ clib_memcpy (mp->tag, tag, vec_len (tag));
+ vec_free (tag);
}
mp->acl_index = ntohl(acl_index);
mp->count = htonl(n_rules);
@@ -1333,10 +1333,10 @@ static int api_macip_acl_add (vat_main_t * vam)
if (vec_len(tag) >= sizeof(mp->tag))
{
tag[sizeof(mp->tag)-1] = 0;
- _vec_len(tag) = sizeof(mp->tag);
- }
- clib_memcpy(mp->tag, tag, vec_len(tag));
- vec_free(tag);
+ vec_set_len (tag, sizeof (mp->tag));
+ }
+ clib_memcpy (mp->tag, tag, vec_len (tag));
+ vec_free (tag);
}
mp->count = htonl(n_rules);
@@ -1475,10 +1475,10 @@ static int api_macip_acl_add_replace (vat_main_t * vam)
if (vec_len(tag) >= sizeof(mp->tag))
{
tag[sizeof(mp->tag)-1] = 0;
- _vec_len(tag) = sizeof(mp->tag);
- }
- clib_memcpy(mp->tag, tag, vec_len(tag));
- vec_free(tag);
+ vec_set_len (tag, sizeof (mp->tag));
+ }
+ clib_memcpy (mp->tag, tag, vec_len (tag));
+ vec_free (tag);
}
mp->acl_index = ntohl(acl_index);
diff --git a/src/plugins/acl/hash_lookup.c b/src/plugins/acl/hash_lookup.c
index 85b54b3e8ac..c137b15a080 100644
--- a/src/plugins/acl/hash_lookup.c
+++ b/src/plugins/acl/hash_lookup.c
@@ -682,7 +682,7 @@ hash_acl_apply(acl_main_t *am, u32 lc_index, int acl_index, u32 acl_position)
if (vec_len(ha->rules) > 0) {
int old_vec_len = vec_len(*applied_hash_aces);
vec_validate((*applied_hash_aces), old_vec_len + vec_len(ha->rules) - 1);
- _vec_len((*applied_hash_aces)) = old_vec_len;
+ vec_set_len ((*applied_hash_aces), old_vec_len);
}
/* add the rules from the ACL to the hash table for lookup and append to the vector*/
@@ -903,7 +903,7 @@ hash_acl_unapply(acl_main_t *am, u32 lc_index, int acl_index)
move_applied_ace_hash_entry(am, lc_index, applied_hash_aces, tail_offset + i, base_offset + i);
}
/* trim the end of the vector */
- _vec_len((*applied_hash_aces)) -= vec_len(ha->rules);
+ vec_dec_len ((*applied_hash_aces), vec_len (ha->rules));
remake_hash_applied_mask_info_vec(am, applied_hash_aces, lc_index);
diff --git a/src/plugins/acl/sess_mgmt_node.c b/src/plugins/acl/sess_mgmt_node.c
index f9a3064cbb1..d0ec5936896 100644
--- a/src/plugins/acl/sess_mgmt_node.c
+++ b/src/plugins/acl/sess_mgmt_node.c
@@ -188,8 +188,7 @@ acl_fa_check_idle_sessions (acl_main_t * am, u16 thread_index, u64 now)
}
}
if (pw->wip_session_change_requests)
- _vec_len (pw->wip_session_change_requests) = 0;
-
+ vec_set_len (pw->wip_session_change_requests, 0);
{
u8 tt = 0;
@@ -309,7 +308,7 @@ acl_fa_check_idle_sessions (acl_main_t * am, u16 thread_index, u64 now)
total_expired = vec_len (pw->expired);
/* zero out the vector which we have acted on */
if (pw->expired)
- _vec_len (pw->expired) = 0;
+ vec_set_len (pw->expired, 0);
/* if we were advancing and reached the end
* (no more sessions to recycle), reset the fast-forward timestamp */
@@ -788,7 +787,7 @@ acl_fa_session_cleaner_process (vlib_main_t * vm, vlib_node_runtime_t * rt,
send_interrupts_to_workers (vm, am);
if (event_data)
- _vec_len (event_data) = 0;
+ vec_set_len (event_data, 0);
/*
* If the interrupts were not processed yet, ensure we wait a bit,
diff --git a/src/plugins/builtinurl/builtins.c b/src/plugins/builtinurl/builtins.c
index 14b68ce4a58..24323cd596e 100644
--- a/src/plugins/builtinurl/builtins.c
+++ b/src/plugins/builtinurl/builtins.c
@@ -54,7 +54,7 @@ trim_path_from_request (u8 * s, char *path)
* like a c-string.
*/
*cp = 0;
- _vec_len (s) = cp - s;
+ vec_set_len (s, cp - s);
break;
}
cp++;
diff --git a/src/plugins/cdp/cdp_input.c b/src/plugins/cdp/cdp_input.c
index 76a3d70a292..c6198d81de1 100644
--- a/src/plugins/cdp/cdp_input.c
+++ b/src/plugins/cdp/cdp_input.c
@@ -167,25 +167,24 @@ _(version,DEBUG_TLV_DUMP) \
_(platform,DEBUG_TLV_DUMP) \
_(port_id,DEBUG_TLV_DUMP)
-#define _(z,dbg) \
-static \
-cdp_error_t process_##z##_tlv (cdp_main_t *cm, cdp_neighbor_t *n, \
- cdp_tlv_t *t) \
-{ \
- int i; \
- if (dbg) \
- fformat(stdout, "%U\n", format_text_tlv, t); \
- \
- if (n->z) \
- _vec_len(n->z) = 0; \
- \
- for (i = 0; i < (t->l - sizeof (*t)); i++) \
- vec_add1(n->z, t->v[i]); \
- \
- vec_add1(n->z, 0); \
- \
- return CDP_ERROR_NONE; \
-}
+#define _(z, dbg) \
+ static cdp_error_t process_##z##_tlv (cdp_main_t *cm, cdp_neighbor_t *n, \
+ cdp_tlv_t *t) \
+ { \
+ int i; \
+ if (dbg) \
+ fformat (stdout, "%U\n", format_text_tlv, t); \
+ \
+ if (n->z) \
+ vec_set_len (n->z, 0); \
+ \
+ for (i = 0; i < (t->l - sizeof (*t)); i++) \
+ vec_add1 (n->z, t->v[i]); \
+ \
+ vec_add1 (n->z, 0); \
+ \
+ return CDP_ERROR_NONE; \
+ }
foreach_text_to_struct_tlv
#undef _
@@ -354,7 +353,7 @@ cdp_input (vlib_main_t * vm, vlib_buffer_t * b0, u32 bi0)
*/
if (n->last_rx_pkt)
- _vec_len (n->last_rx_pkt) = 0;
+ vec_set_len (n->last_rx_pkt, 0);
/* cdp disabled on this interface, we're done */
if (n->disabled)
diff --git a/src/plugins/cdp/cdp_periodic.c b/src/plugins/cdp/cdp_periodic.c
index c73d86be316..295cf8fcfb1 100644
--- a/src/plugins/cdp/cdp_periodic.c
+++ b/src/plugins/cdp/cdp_periodic.c
@@ -394,9 +394,9 @@ cdp_periodic (vlib_main_t * vm)
delete_neighbor (cm, n, 1);
}
if (delete_list)
- _vec_len (delete_list) = 0;
+ vec_set_len (delete_list, 0);
if (n_list)
- _vec_len (n_list) = 0;
+ vec_set_len (n_list, 0);
}
static clib_error_t *
diff --git a/src/plugins/dhcp/dhcp6_pd_client_cp.c b/src/plugins/dhcp/dhcp6_pd_client_cp.c
index f6d30fa0c7d..b1784bd9420 100644
--- a/src/plugins/dhcp/dhcp6_pd_client_cp.c
+++ b/src/plugins/dhcp/dhcp6_pd_client_cp.c
@@ -992,7 +992,7 @@ dhcp6_cp_ip6_address_add_del (u32 sw_if_index, const u8 * prefix_group,
return VNET_API_ERROR_DUPLICATE_IF_ADDRESS;
cp_ip6_address_add_del_now (address_info, 0 /* del */ );
*address_info = apm->addresses[n - 1];
- _vec_len (apm->addresses) = n - 1;
+ vec_set_len (apm->addresses, n - 1);
return 0;
}
}
diff --git a/src/plugins/dns/dns.c b/src/plugins/dns/dns.c
index 76ce3dabd30..ac6d1229441 100644
--- a/src/plugins/dns/dns.c
+++ b/src/plugins/dns/dns.c
@@ -829,7 +829,7 @@ re_resolve:
clib_memset (ep, 0, sizeof (*ep));
ep->name = format (0, "%s%c", name, 0);
- _vec_len (ep->name) = vec_len (ep->name) - 1;
+ vec_set_len (ep->name, vec_len (ep->name) - 1);
hash_set_mem (dm->cache_entry_by_name, ep->name, ep - dm->entries);
@@ -988,7 +988,7 @@ found_last_request:
cname = vnet_dns_labels_to_name (rr->rdata, reply, &pos2);
/* Save the cname */
vec_add1 (cname, 0);
- _vec_len (cname) -= 1;
+ vec_dec_len (cname, 1);
ep = pool_elt_at_index (dm->entries, ep_index);
ep->cname = cname;
ep->flags |= (DNS_CACHE_ENTRY_FLAG_CNAME | DNS_CACHE_ENTRY_FLAG_VALID);
@@ -1007,7 +1007,7 @@ found_last_request:
clib_memset (next_ep, 0, sizeof (*next_ep));
next_ep->name = vec_dup (cname);
vec_add1 (next_ep->name, 0);
- _vec_len (next_ep->name) -= 1;
+ vec_dec_len (next_ep->name, 1);
hash_set_mem (dm->cache_entry_by_name, next_ep->name,
next_ep - dm->entries);
@@ -2611,7 +2611,7 @@ test_dns_expire_command_fn (vlib_main_t * vm,
if (unformat (input, "%v", &name))
{
vec_add1 (name, 0);
- _vec_len (name) -= 1;
+ vec_dec_len (name, 1);
}
else
return clib_error_return (0, "no name provided");
diff --git a/src/plugins/dns/request_node.c b/src/plugins/dns/request_node.c
index 72a76d12e4f..9179bf8dbdd 100644
--- a/src/plugins/dns/request_node.c
+++ b/src/plugins/dns/request_node.c
@@ -214,7 +214,7 @@ dns46_request_inline (vlib_main_t * vm,
*/
name0 = vnet_dns_labels_to_name (label0, (u8 *) d0, (u8 **) & q0);
vec_add1 (name0, 0);
- _vec_len (name0) -= 1;
+ vec_dec_len (name0, 1);
t0->request_type = DNS_PEER_PENDING_NAME_TO_IP;
diff --git a/src/plugins/dpdk/device/cli.c b/src/plugins/dpdk/device/cli.c
index f49a94fa98f..af522a56198 100644
--- a/src/plugins/dpdk/device/cli.c
+++ b/src/plugins/dpdk/device/cli.c
@@ -142,7 +142,7 @@ show_dpdk_physmem (vlib_main_t * vm, unformat_input_t * input,
err = clib_error_return_unix (0, "read");
goto error;
}
- _vec_len (s) = len + (n < 0 ? 0 : n);
+ vec_set_len (s, len + (n < 0 ? 0 : n));
}
vlib_cli_output (vm, "%v", s);
@@ -198,7 +198,7 @@ test_dpdk_buffer (vlib_main_t * vm, unformat_input_t * input,
first = vec_len (allocated_buffers) - n_free;
vlib_buffer_free (vm, allocated_buffers + first, n_free);
- _vec_len (allocated_buffers) = first;
+ vec_set_len (allocated_buffers, first);
}
if (n_alloc)
{
@@ -208,7 +208,7 @@ test_dpdk_buffer (vlib_main_t * vm, unformat_input_t * input,
actual_alloc = vlib_buffer_alloc (vm, allocated_buffers + first,
n_alloc);
- _vec_len (allocated_buffers) = first + actual_alloc;
+ vec_set_len (allocated_buffers, first + actual_alloc);
if (actual_alloc < n_alloc)
vlib_cli_output (vm, "WARNING: only allocated %d buffers",
diff --git a/src/plugins/dpdk/device/dpdk_priv.h b/src/plugins/dpdk/device/dpdk_priv.h
index 4e4438a007e..ed30cd8cd23 100644
--- a/src/plugins/dpdk/device/dpdk_priv.h
+++ b/src/plugins/dpdk/device/dpdk_priv.h
@@ -63,11 +63,11 @@ dpdk_get_xstats (dpdk_device_t * xd)
ret = rte_eth_xstats_get (xd->port_id, xd->xstats, len);
if (ret < 0 || ret > len)
{
- _vec_len (xd->xstats) = 0;
+ vec_set_len (xd->xstats, 0);
return;
}
- _vec_len (xd->xstats) = len;
+ vec_set_len (xd->xstats, len);
}
#define DPDK_UPDATE_COUNTER(vnm, tidx, xd, stat, cnt) \
diff --git a/src/plugins/dpdk/device/init.c b/src/plugins/dpdk/device/init.c
index a94f83bc42d..9d68775d86a 100644
--- a/src/plugins/dpdk/device/init.c
+++ b/src/plugins/dpdk/device/init.c
@@ -921,7 +921,7 @@ dpdk_log_read_ready (clib_file_t * uf)
n = read (uf->file_descriptor, s + len, n_try);
if (n < 0 && errno != EAGAIN)
return clib_error_return_unix (0, "read");
- _vec_len (s) = len + (n < 0 ? 0 : n);
+ vec_set_len (s, len + (n < 0 ? 0 : n));
}
unformat_init_vector (&input, s);
@@ -1254,7 +1254,7 @@ dpdk_config (vlib_main_t * vm, unformat_input_t * input)
/* NULL terminate the "argv" vector, in case of stupidity */
vec_add1 (conf->eal_init_args, 0);
- _vec_len (conf->eal_init_args) -= 1;
+ vec_dec_len (conf->eal_init_args, 1);
/* Set up DPDK eal and packet mbuf pool early. */
diff --git a/src/plugins/gtpu/gtpu.c b/src/plugins/gtpu/gtpu.c
index db596703158..33af26d70ee 100644
--- a/src/plugins/gtpu/gtpu.c
+++ b/src/plugins/gtpu/gtpu.c
@@ -292,7 +292,7 @@ ip_udp_gtpu_rewrite (gtpu_tunnel_t * t, bool is_ip6)
t->rewrite = r.rw;
/* Now only support 8-byte gtpu header. TBD */
- _vec_len (t->rewrite) = sizeof (ip4_gtpu_header_t) - 4;
+ vec_set_len (t->rewrite, sizeof (ip4_gtpu_header_t) - 4);
return;
}
@@ -419,7 +419,7 @@ int vnet_gtpu_add_mod_del_tunnel
vnet_interface_main_t *im = &vnm->interface_main;
hw_if_index = gtm->free_gtpu_tunnel_hw_if_indices
[vec_len (gtm->free_gtpu_tunnel_hw_if_indices) - 1];
- _vec_len (gtm->free_gtpu_tunnel_hw_if_indices) -= 1;
+ vec_dec_len (gtm->free_gtpu_tunnel_hw_if_indices, 1);
hi = vnet_get_hw_interface (vnm, hw_if_index);
hi->dev_instance = t - gtm->tunnels;
diff --git a/src/plugins/hs_apps/echo_client.c b/src/plugins/hs_apps/echo_client.c
index 1d33a855240..b7bc85b82a9 100644
--- a/src/plugins/hs_apps/echo_client.c
+++ b/src/plugins/hs_apps/echo_client.c
@@ -248,7 +248,7 @@ ec_node_fn (vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
conn_indices + vec_len (conn_indices) -
nconns_this_batch,
nconns_this_batch * sizeof (u32));
- _vec_len (conn_indices) -= nconns_this_batch;
+ vec_dec_len (conn_indices, nconns_this_batch);
}
/*
diff --git a/src/plugins/hs_apps/http_cli.c b/src/plugins/hs_apps/http_cli.c
index fec1427994c..d742121ad2c 100644
--- a/src/plugins/hs_apps/http_cli.c
+++ b/src/plugins/hs_apps/http_cli.c
@@ -221,7 +221,7 @@ hcs_cli_process (vlib_main_t *vm, vlib_node_runtime_t *rt, vlib_frame_t *f)
else if (request[i] == ' ')
{
/* vlib_cli_input is vector-based, no need for a NULL */
- _vec_len (request) = i;
+ vec_set_len (request, i);
break;
}
i++;
@@ -269,7 +269,7 @@ alloc_cli_process (hcs_cli_args_t *args)
{
n = vlib_get_node (vm, hcm->free_http_cli_process_node_indices[l - 1]);
vlib_node_set_state (vm, n->index, VLIB_NODE_STATE_POLLING);
- _vec_len (hcm->free_http_cli_process_node_indices) = l - 1;
+ vec_set_len (hcm->free_http_cli_process_node_indices, l - 1);
}
else
{
diff --git a/src/plugins/http/http.c b/src/plugins/http/http.c
index 828e57d3640..f40715f055d 100644
--- a/src/plugins/http/http.c
+++ b/src/plugins/http/http.c
@@ -329,7 +329,7 @@ read_request (http_conn_t *hc)
if (svm_fifo_is_empty (ts->rx_fifo))
svm_fifo_unset_event (ts->rx_fifo);
- _vec_len (hc->rx_buf) = cursize + n_read;
+ vec_set_len (hc->rx_buf, cursize + n_read);
return 0;
}
diff --git a/src/plugins/http_static/builtinurl/json_urls.c b/src/plugins/http_static/builtinurl/json_urls.c
index 0d83d39fade..808893aac79 100644
--- a/src/plugins/http_static/builtinurl/json_urls.c
+++ b/src/plugins/http_static/builtinurl/json_urls.c
@@ -51,7 +51,7 @@ trim_path_from_request (u8 *s, char *path)
* like a c-string.
*/
*cp = 0;
- _vec_len (s) = cp - s;
+ vec_set_len (s, cp - s);
break;
}
cp++;
diff --git a/src/plugins/http_static/static_server.c b/src/plugins/http_static/static_server.c
index 4eafb1f0111..b92af892eaf 100644
--- a/src/plugins/http_static/static_server.c
+++ b/src/plugins/http_static/static_server.c
@@ -224,7 +224,7 @@ try_index_file (hss_main_t *hsm, hss_session_t *hs, u8 *path)
u32 plen;
/* Remove the trailing space */
- _vec_len (path) -= 1;
+ vec_dec_len (path, 1);
plen = vec_len (path);
/* Append "index.html" */
diff --git a/src/plugins/ikev2/ikev2_crypto.c b/src/plugins/ikev2/ikev2_crypto.c
index a9ab1bc8067..3d4ad0a28ed 100644
--- a/src/plugins/ikev2/ikev2_crypto.c
+++ b/src/plugins/ikev2/ikev2_crypto.c
@@ -488,7 +488,7 @@ BN_bn2binpad (const BIGNUM * a, unsigned char *to, int tolen)
{
vec_insert (to, pad, 0);
clib_memset (to, 0, pad);
- _vec_len (to) -= pad;
+ vec_dec_len (to, pad);
}
return tolen;
}
@@ -553,7 +553,7 @@ ikev2_generate_dh (ikev2_sa_t * sa, ikev2_sa_transform_t * t)
{
vec_insert (sa->dh_shared_key, pad, 0);
clib_memset (sa->dh_shared_key, 0, pad);
- _vec_len (sa->dh_shared_key) -= pad;
+ vec_dec_len (sa->dh_shared_key, pad);
}
BN_clear_free (ex);
}
@@ -679,7 +679,7 @@ ikev2_complete_dh (ikev2_sa_t * sa, ikev2_sa_transform_t * t)
{
vec_insert (sa->dh_shared_key, pad, 0);
clib_memset (sa->dh_shared_key, 0, pad);
- _vec_len (sa->dh_shared_key) -= pad;
+ vec_dec_len (sa->dh_shared_key, pad);
}
BN_clear_free (ex);
DH_free (dh);
diff --git a/src/plugins/ioam/export-common/ioam_export.h b/src/plugins/ioam/export-common/ioam_export.h
index f242ad7a788..1b764f66b15 100644
--- a/src/plugins/ioam/export-common/ioam_export.h
+++ b/src/plugins/ioam/export-common/ioam_export.h
@@ -287,7 +287,7 @@ ioam_export_header_create (ioam_export_main_t * em,
(DEFAULT_EXPORT_RECORDS *
DEFAULT_EXPORT_SIZE));
ip->checksum = ip4_header_checksum (ip);
- _vec_len (rewrite) = sizeof (ip4_ipfix_data_packet_t);
+ vec_set_len (rewrite, sizeof (ip4_ipfix_data_packet_t));
em->record_header = rewrite;
return (1);
}
diff --git a/src/plugins/l2tp/l2tp.c b/src/plugins/l2tp/l2tp.c
index 08fa6d1e60b..a975fa7f059 100644
--- a/src/plugins/l2tp/l2tp.c
+++ b/src/plugins/l2tp/l2tp.c
@@ -377,7 +377,7 @@ create_l2tpv3_ipv6_tunnel (l2t_main_t * lm,
{
hw_if_index = lm->free_l2tpv3_tunnel_hw_if_indices
[vec_len (lm->free_l2tpv3_tunnel_hw_if_indices) - 1];
- _vec_len (lm->free_l2tpv3_tunnel_hw_if_indices) -= 1;
+ vec_dec_len (lm->free_l2tpv3_tunnel_hw_if_indices, 1);
hi = vnet_get_hw_interface (vnm, hw_if_index);
hi->dev_instance = s - lm->sessions;
diff --git a/src/plugins/lacp/input.c b/src/plugins/lacp/input.c
index 3997af897eb..31450286f34 100644
--- a/src/plugins/lacp/input.c
+++ b/src/plugins/lacp/input.c
@@ -155,7 +155,7 @@ lacp_input (vlib_main_t * vm, vlib_buffer_t * b0, u32 bi0)
{
mif->last_marker_pdu_recd_time = vlib_time_now (vm);
if (mif->last_marker_pkt)
- _vec_len (mif->last_marker_pkt) = 0;
+ vec_set_len (mif->last_marker_pkt, 0);
vec_validate (mif->last_marker_pkt,
vlib_buffer_length_in_chain (vm, b0) - 1);
nbytes = vlib_buffer_contents (vm, bi0, mif->last_marker_pkt);
@@ -176,7 +176,7 @@ lacp_input (vlib_main_t * vm, vlib_buffer_t * b0, u32 bi0)
* and reuse it.
*/
if (mif->last_rx_pkt)
- _vec_len (mif->last_rx_pkt) = 0;
+ vec_set_len (mif->last_rx_pkt, 0);
/*
* Make sure the per-neighbor rx buffer is big enough to hold
@@ -225,7 +225,7 @@ lacp_input (vlib_main_t * vm, vlib_buffer_t * b0, u32 bi0)
mif->pdu_received++;
if (mif->last_rx_pkt)
- _vec_len (mif->last_rx_pkt) = 0;
+ vec_set_len (mif->last_rx_pkt, 0);
return e;
}
diff --git a/src/plugins/lb/lb.c b/src/plugins/lb/lb.c
index 5bc7cf25a97..dfdc5066a3d 100644
--- a/src/plugins/lb/lb.c
+++ b/src/plugins/lb/lb.c
@@ -422,7 +422,7 @@ out:
sort_arr[i].as_index = as - lbm->ass;
i++;
}
- _vec_len(sort_arr) = i;
+ vec_set_len (sort_arr, i);
vec_sort_with_function(sort_arr, lb_pseudorand_compare);
diff --git a/src/plugins/lisp/lisp-cp/control.c b/src/plugins/lisp/lisp-cp/control.c
index 7293e03eea0..24dd50b7de0 100644
--- a/src/plugins/lisp/lisp-cp/control.c
+++ b/src/plugins/lisp/lisp-cp/control.c
@@ -4830,7 +4830,7 @@ send_map_resolver_service (vlib_main_t * vm,
{
process_expired_mapping (lcm, mi[0]);
}
- _vec_len (expired) = 0;
+ vec_set_len (expired, 0);
}
}
diff --git a/src/plugins/lisp/lisp-gpe/interface.c b/src/plugins/lisp/lisp-gpe/interface.c
index 9dcf52d1ba6..05669ae975f 100644
--- a/src/plugins/lisp/lisp-gpe/interface.c
+++ b/src/plugins/lisp/lisp-gpe/interface.c
@@ -429,7 +429,7 @@ lisp_gpe_create_iface (lisp_gpe_main_t * lgm, u32 vni, u32 dp_table,
if (flen > 0)
{
hw_if_index = lgm->free_tunnel_hw_if_indices[flen - 1];
- _vec_len (lgm->free_tunnel_hw_if_indices) -= 1;
+ vec_dec_len (lgm->free_tunnel_hw_if_indices, 1);
hi = vnet_get_hw_interface (vnm, hw_if_index);
diff --git a/src/plugins/lldp/lldp_input.c b/src/plugins/lldp/lldp_input.c
index 327ef10f9de..b8aa846e385 100644
--- a/src/plugins/lldp/lldp_input.c
+++ b/src/plugins/lldp/lldp_input.c
@@ -48,13 +48,13 @@ lldp_rpc_update_peer_cb (const lldp_intf_update_t * a)
if (n->chassis_id)
{
- _vec_len (n->chassis_id) = 0;
+ vec_set_len (n->chassis_id, 0);
}
vec_add (n->chassis_id, chassis_id, a->chassis_id_len);
n->chassis_id_subtype = a->chassis_id_subtype;
if (n->port_id)
{
- _vec_len (n->port_id) = 0;
+ vec_set_len (n->port_id, 0);
}
vec_add (n->port_id, portid, a->portid_len);
n->port_id_subtype = a->portid_subtype;
diff --git a/src/plugins/lldp/lldp_node.c b/src/plugins/lldp/lldp_node.c
index dbb54af91f0..d4b6d529d9b 100644
--- a/src/plugins/lldp/lldp_node.c
+++ b/src/plugins/lldp/lldp_node.c
@@ -220,7 +220,7 @@ lldp_process (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f)
#endif
if (event_data)
{
- _vec_len (event_data) = 0;
+ vec_set_len (event_data, 0);
}
}
diff --git a/src/plugins/memif/device.c b/src/plugins/memif/device.c
index 94789223ea7..f049a7be38e 100644
--- a/src/plugins/memif/device.c
+++ b/src/plugins/memif/device.c
@@ -194,8 +194,8 @@ retry:
else
{
/* we need to rollback vectors before bailing out */
- _vec_len (ptd->buffers) = saved_ptd_buffers_len;
- _vec_len (ptd->copy_ops) = saved_ptd_copy_ops_len;
+ vec_set_len (ptd->buffers, saved_ptd_buffers_len);
+ vec_set_len (ptd->copy_ops, saved_ptd_copy_ops_len);
vlib_error_count (vm, node->node_index,
MEMIF_TX_ERROR_ROLLBACK, 1);
slot = saved_slot;
diff --git a/src/plugins/memif/memif.c b/src/plugins/memif/memif.c
index b89665f9a29..f4543c837db 100644
--- a/src/plugins/memif/memif.c
+++ b/src/plugins/memif/memif.c
@@ -991,8 +991,6 @@ memif_create_if (vlib_main_t * vm, memif_create_if_args_t * args)
bt->total_length_not_including_first_buffer = 0;
vnet_buffer (bt)->sw_if_index[VLIB_TX] = (u32) ~ 0;
- /* initially prealloc copy_ops so we can use
- _vec_len instead of vec_elen */
vec_validate_aligned (ptd->copy_ops, 0, CLIB_CACHE_LINE_BYTES);
vec_reset_length (ptd->copy_ops);
vec_validate_aligned (ptd->buffers, 0, CLIB_CACHE_LINE_BYTES);
diff --git a/src/plugins/memif/memif_api.c b/src/plugins/memif/memif_api.c
index a50e7ce8882..593306a1ec7 100644
--- a/src/plugins/memif/memif_api.c
+++ b/src/plugins/memif/memif_api.c
@@ -289,7 +289,7 @@ vl_api_memif_dump_t_handler (vl_api_memif_dump_t * mp)
vnm, swif, 0);
send_memif_details (reg, mif, swif, if_name, mp->context);
- _vec_len (if_name) = 0;
+ vec_set_len (if_name, 0);
}
/* *INDENT-ON* */
diff --git a/src/plugins/nsh/nsh_api.c b/src/plugins/nsh/nsh_api.c
index 1faaea36c50..4a9eab4daec 100644
--- a/src/plugins/nsh/nsh_api.c
+++ b/src/plugins/nsh/nsh_api.c
@@ -346,7 +346,7 @@ nsh_add_del_map (nsh_add_del_map_args_t * a, u32 * map_indexp)
{
nsh_hw_if = nm->free_nsh_tunnel_hw_if_indices
[vec_len (nm->free_nsh_tunnel_hw_if_indices) - 1];
- _vec_len (nm->free_nsh_tunnel_hw_if_indices) -= 1;
+ vec_dec_len (nm->free_nsh_tunnel_hw_if_indices, 1);
hi = vnet_get_hw_interface (vnm, nsh_hw_if);
hi->dev_instance = map_index;
diff --git a/src/plugins/pppoe/pppoe.c b/src/plugins/pppoe/pppoe.c
index 182f93b6156..2bdbd3abed8 100644
--- a/src/plugins/pppoe/pppoe.c
+++ b/src/plugins/pppoe/pppoe.c
@@ -374,7 +374,7 @@ int vnet_pppoe_add_del_session
vnet_interface_main_t *im = &vnm->interface_main;
hw_if_index = pem->free_pppoe_session_hw_if_indices
[vec_len (pem->free_pppoe_session_hw_if_indices) - 1];
- _vec_len (pem->free_pppoe_session_hw_if_indices) -= 1;
+ vec_dec_len (pem->free_pppoe_session_hw_if_indices, 1);
hi = vnet_get_hw_interface (vnm, hw_if_index);
hi->dev_instance = t - pem->sessions;
diff --git a/src/plugins/snort/enqueue.c b/src/plugins/snort/enqueue.c
index 147d3a4a67b..409c0e49078 100644
--- a/src/plugins/snort/enqueue.c
+++ b/src/plugins/snort/enqueue.c
@@ -197,7 +197,7 @@ snort_enq_node_inline (vlib_main_t *vm, vlib_node_runtime_t *node,
}
__atomic_store_n (qp->enq_head, head, __ATOMIC_RELEASE);
- _vec_len (qp->freelist) = freelist_len;
+ vec_set_len (qp->freelist, freelist_len);
if (sm->input_mode == VLIB_NODE_STATE_INTERRUPT)
{
if (write (qp->enq_fd, &ctr, sizeof (ctr)) < 0)
diff --git a/src/plugins/unittest/bihash_test.c b/src/plugins/unittest/bihash_test.c
index c5cc752ade0..0789735c1d7 100644
--- a/src/plugins/unittest/bihash_test.c
+++ b/src/plugins/unittest/bihash_test.c
@@ -512,7 +512,7 @@ test_bihash_command_fn (vlib_main_t * vm,
/* Preallocate hash table, key vector */
tm->key_hash = hash_create (tm->nitems, sizeof (uword));
vec_validate (tm->keys, tm->nitems - 1);
- _vec_len (tm->keys) = 0;
+ vec_set_len (tm->keys, 0);
switch (which)
{
diff --git a/src/plugins/unittest/bitmap_test.c b/src/plugins/unittest/bitmap_test.c
index 04a06d39a18..adee9764f46 100644
--- a/src/plugins/unittest/bitmap_test.c
+++ b/src/plugins/unittest/bitmap_test.c
@@ -30,7 +30,7 @@ test_bitmap_command_fn (vlib_main_t * vm,
junk = clib_bitmap_next_clear (bm, 65);
bm2 = clib_bitmap_set_multiple (bm2, 0, ~0ULL, BITS (uword));
- _vec_len (bm2) = 1;
+ vec_set_len (bm2, 1);
junk = clib_bitmap_next_clear (bm2, 0);
diff --git a/src/plugins/unittest/fib_test.c b/src/plugins/unittest/fib_test.c
index 57ab29e1f72..d417d5ff6ea 100644
--- a/src/plugins/unittest/fib_test.c
+++ b/src/plugins/unittest/fib_test.c
@@ -10628,7 +10628,7 @@ fib_test_sticky (void)
fib_route_path_t *r_paths2 = NULL;
r_paths2 = vec_dup(r_paths);
- _vec_len(r_paths2) = 3;
+ vec_set_len (r_paths2, 3);
pl_index = fib_path_list_create(FIB_PATH_LIST_FLAG_SHARED, r_paths2);
fib_path_list_lock(pl_index);
@@ -10699,7 +10699,7 @@ fib_test_sticky (void)
fib_route_path_t *r_paths3 = NULL;
r_paths3 = vec_dup(r_paths);
- _vec_len(r_paths3) = 3;
+ vec_set_len (r_paths3, 3);
r_paths3[0].frp_weight = 3;
diff --git a/src/plugins/unittest/svm_fifo_test.c b/src/plugins/unittest/svm_fifo_test.c
index a57795c38b9..8e186a86c9d 100644
--- a/src/plugins/unittest/svm_fifo_test.c
+++ b/src/plugins/unittest/svm_fifo_test.c
@@ -2519,7 +2519,7 @@ sfifo_test_fifo_segment_mempig (int verbose)
fifo_segment_free_fifo (sp, f);
}
- _vec_len (flist) = 0;
+ vec_set_len (flist, 0);
for (i = 0; i < 1000; i++)
{
diff --git a/src/plugins/vmxnet3/vmxnet3_api.c b/src/plugins/vmxnet3/vmxnet3_api.c
index 90608082a3e..36fa7bd9958 100644
--- a/src/plugins/vmxnet3/vmxnet3_api.c
+++ b/src/plugins/vmxnet3/vmxnet3_api.c
@@ -179,7 +179,7 @@ vl_api_vmxnet3_dump_t_handler (vl_api_vmxnet3_dump_t * mp)
if_name = format (if_name, "%U%c", format_vnet_sw_interface_name, vnm,
swif, 0);
send_vmxnet3_details (reg, vd, swif, if_name, mp->context);
- _vec_len (if_name) = 0;
+ vec_set_len (if_name, 0);
}
/* *INDENT-ON* */
@@ -220,7 +220,7 @@ static void vl_api_sw_vmxnet3_interface_dump_t_handler
if_name = format (if_name, "%U%c", format_vnet_sw_interface_name, vnm,
swif, 0);
send_vmxnet3_details (reg, vd, swif, if_name, mp->context);
- _vec_len (if_name) = 0;
+ vec_set_len (if_name, 0);
}
}
/* *INDENT-ON* */
diff --git a/src/svm/svmdb.c b/src/svm/svmdb.c
index 2c3d351f0c7..7628c0ae809 100644
--- a/src/svm/svmdb.c
+++ b/src/svm/svmdb.c
@@ -281,7 +281,7 @@ local_unset_variable_nolock (svmdb_client_t * client,
if (vec_len (oldvalue->notifications))
notify_value (oldvalue, SVMDB_ACTION_UNSET);
/* zero length value means unset */
- _vec_len (oldvalue->value) = 0;
+ vec_set_len (oldvalue->value, 0);
}
client->shm->namespaces[namespace] = h;
}
@@ -317,7 +317,7 @@ local_set_variable_nolock (svmdb_client_t * client,
oldvalue = pool_elt_at_index (client->shm->values, hp->value[0]);
vec_alloc (oldvalue->value, vec_len (val) * elsize);
clib_memcpy (oldvalue->value, val, vec_len (val) * elsize);
- _vec_len (oldvalue->value) = vec_len (val);
+ vec_set_len (oldvalue->value, vec_len (val));
notify_value (oldvalue, SVMDB_ACTION_SET);
}
else
@@ -328,7 +328,7 @@ local_set_variable_nolock (svmdb_client_t * client,
newvalue->elsize = elsize;
vec_alloc (newvalue->value, vec_len (val) * elsize);
clib_memcpy (newvalue->value, val, vec_len (val) * elsize);
- _vec_len (newvalue->value) = vec_len (val);
+ vec_set_len (newvalue->value, vec_len (val));
name = format (0, "%s%c", var, 0);
hash_set_mem (h, name, newvalue - shm->values);
}
@@ -589,7 +589,7 @@ svmdb_local_get_vec_variable (svmdb_client_t * client, char *var, u32 elsize)
/* Make a copy in process-local memory */
vec_alloc (copy, vec_len (rv) * elsize);
clib_memcpy (copy, rv, vec_len (rv) * elsize);
- _vec_len (copy) = vec_len (rv);
+ vec_set_len (copy, vec_len (rv));
region_unlock (client->db_rp);
return (copy);
}
@@ -653,7 +653,7 @@ svmdb_local_find_or_add_vec_variable (svmdb_client_t * client,
clib_memset (newvalue, 0, sizeof (*newvalue));
newvalue->elsize = 1;
vec_alloc (newvalue->value, nbytes);
- _vec_len (newvalue->value) = nbytes;
+ vec_set_len (newvalue->value, nbytes);
name = format (0, "%s%c", var, 0);
hash_set_mem (h, name, newvalue - shm->values);
shm->namespaces[SVMDB_NAMESPACE_VEC] = h;
diff --git a/src/tools/perftool/cpel_util.c b/src/tools/perftool/cpel_util.c
index 4f5f98a51cc..4dc1eaf3256 100644
--- a/src/tools/perftool/cpel_util.c
+++ b/src/tools/perftool/cpel_util.c
@@ -424,7 +424,7 @@ void alpha_sort_tracks(void)
alpha_compare_tracks);
vec_validate(track_alpha_map, vec_len(the_tracks));
- _vec_len(track_alpha_map) = vec_len(the_tracks);
+ vec_set_len (track_alpha_map, vec_len (the_tracks));
for (i = 0; i < vec_len(the_tracks); i++) {
this_track = &the_tracks[i];
diff --git a/src/tools/perftool/cpelinreg.c b/src/tools/perftool/cpelinreg.c
index 115afad7fb2..44399904237 100644
--- a/src/tools/perftool/cpelinreg.c
+++ b/src/tools/perftool/cpelinreg.c
@@ -617,12 +617,12 @@ int event_pass (cpel_section_header_t *sh, int verbose, FILE *ofp)
} else {
dup_events++;
}
- _vec_len(tp->start_datum) = sp;
- _vec_len(tp->start_time) = sp;
- _vec_len(tp->dup_event) = sp;
- }
+ vec_set_len (tp->start_datum, sp);
+ vec_set_len (tp->start_time, sp);
+ vec_set_len (tp->dup_event, sp);
+ }
- ep++;
+ ep++;
}
last_end_time = now;
diff --git a/src/vat/api_format.c b/src/vat/api_format.c
index 4827d55815c..14546b51be8 100644
--- a/src/vat/api_format.c
+++ b/src/vat/api_format.c
@@ -1427,7 +1427,7 @@ unformat_classify_mask (unformat_input_t * input, va_list * args)
if (match == 0)
clib_warning ("BUG: match 0");
- _vec_len (mask) = match * sizeof (u32x4);
+ vec_set_len (mask, match * sizeof (u32x4));
*matchp = match;
*maskp = mask;
@@ -1994,7 +1994,7 @@ api_unformat_classify_match (unformat_input_t * input, va_list * args)
sizeof (u32x4));
/* Set size, include skipped vectors */
- _vec_len (match) = (match_n_vectors + skip_n_vectors) * sizeof (u32x4);
+ vec_set_len (match, (match_n_vectors + skip_n_vectors) * sizeof (u32x4));
*matchp = match;
diff --git a/src/vat/main.c b/src/vat/main.c
index 1640c5ded6a..e7c08184de3 100644
--- a/src/vat/main.c
+++ b/src/vat/main.c
@@ -98,7 +98,7 @@ do_one_file (vat_main_t * vam)
rv = write (1, "exec# ", 6);
}
- _vec_len (vam->inbuf) = 4096;
+ vec_set_len (vam->inbuf, 4096);
if (vam->do_exit ||
fgets ((char *) vam->inbuf, vec_len (vam->inbuf), vam->ifp) == 0)
diff --git a/src/vat/plugin.c b/src/vat/plugin.c
index 09a96fd2ca4..bc780001bbd 100644
--- a/src/vat/plugin.c
+++ b/src/vat/plugin.c
@@ -155,7 +155,7 @@ vat_load_new_plugins (plugin_main_t * pm)
if (load_one_plugin (pm, pi))
{
vec_free (plugin_name);
- _vec_len (pm->plugin_info) = vec_len (pm->plugin_info) - 1;
+ vec_set_len (pm->plugin_info, vec_len (pm->plugin_info) - 1);
continue;
}
hash_set_mem (pm->plugin_by_name_hash, plugin_name,
diff --git a/src/vat2/plugin.c b/src/vat2/plugin.c
index 6b6d55ac9b0..3ad870519da 100644
--- a/src/vat2/plugin.c
+++ b/src/vat2/plugin.c
@@ -165,7 +165,7 @@ vat2_load_plugins (char *path, char *filter, int *loaded)
{
res = -1;
vec_free (plugin_name);
- _vec_len (plugin_info) = vec_len (plugin_info) - 1;
+ vec_set_len (plugin_info, vec_len (plugin_info) - 1);
continue;
}
clib_memset (pi, 0, sizeof (*pi));
diff --git a/src/vcl/vcl_cfg.c b/src/vcl/vcl_cfg.c
index 4e0b583e2ec..ac768c4d6e3 100644
--- a/src/vcl/vcl_cfg.c
+++ b/src/vcl/vcl_cfg.c
@@ -431,7 +431,7 @@ vppcom_cfg_read_file (char *conf_fname)
u32 nsid_vec_len = vec_len (vcl_cfg->namespace_id);
if (nsid_vec_len > max_nsid_vec_len)
{
- _vec_len (vcl_cfg->namespace_id) = max_nsid_vec_len;
+ vec_set_len (vcl_cfg->namespace_id, max_nsid_vec_len);
VCFG_DBG (0, "VCL<%d>: configured namespace_id is too long,"
" truncated to %d characters!",
getpid (), max_nsid_vec_len);
diff --git a/src/vlib/cli.c b/src/vlib/cli.c
index b7c4c0030b0..dcabe8dfbaf 100644
--- a/src/vlib/cli.c
+++ b/src/vlib/cli.c
@@ -617,7 +617,7 @@ vlib_cli_dispatch_sub_commands (vlib_main_t * vm,
vec_add1 (c_error->what, 0);
ed->err = elog_string (vlib_get_elog_main (),
(char *) c_error->what);
- _vec_len (c_error->what) -= 1;
+ vec_dec_len (c_error->what, 1);
}
else
ed->err = elog_string (vlib_get_elog_main (), "OK");
@@ -1179,7 +1179,7 @@ vlib_cli_normalize_path (char *input, char **result)
/* Remove any extra space at end. */
if (l > 0 && s[l - 1] == ' ')
- _vec_len (s) -= 1;
+ vec_dec_len (s, 1);
*result = s;
return index_of_last_space;
diff --git a/src/vlib/lex.c b/src/vlib/lex.c
index 1cc8f1678d2..7facba5fe25 100644
--- a/src/vlib/lex.c
+++ b/src/vlib/lex.c
@@ -113,7 +113,7 @@ vlib_lex_get_token (vlib_lex_main_t * lm, vlib_lex_token_t * rv)
lm->lex_token_names[VLIB_LEX_word],
rv->value.as_pointer);
}
- _vec_len (lm->token_buffer) = 0;
+ vec_set_len (lm->token_buffer, 0);
/* Rescan the character which terminated the keyword/word. */
lm->current_index--;
@@ -233,7 +233,7 @@ void
vlib_lex_reset (vlib_lex_main_t * lm, u8 * input_vector)
{
if (lm->pushback_vector)
- _vec_len (lm->pushback_vector) = 0;
+ vec_set_len (lm->pushback_vector, 0);
lm->pushback_sp = -1;
lm->input_vector = input_vector;
@@ -255,7 +255,7 @@ lex_onetime_init (vlib_main_t * vm)
#undef _
vec_validate (lm->token_buffer, 127);
- _vec_len (lm->token_buffer) = 0;
+ vec_set_len (lm->token_buffer, 0);
return 0;
}
diff --git a/src/vlib/main.c b/src/vlib/main.c
index fd0c1fc5f7c..a9efe7e936d 100644
--- a/src/vlib/main.c
+++ b/src/vlib/main.c
@@ -81,7 +81,7 @@ vlib_frame_alloc_to_node (vlib_main_t * vm, u32 to_node_index,
{
/* Allocate from end of free list. */
f = fs->free_frames[l - 1];
- _vec_len (fs->free_frames) = l - 1;
+ vec_set_len (fs->free_frames, l - 1);
}
else
{
@@ -1458,7 +1458,7 @@ vlib_main_or_worker_loop (vlib_main_t * vm, int is_main)
if (is_main)
{
vec_resize (nm->pending_frames, 32);
- _vec_len (nm->pending_frames) = 0;
+ vec_set_len (nm->pending_frames, 0);
}
/* Mark time of main loop start. */
@@ -1584,7 +1584,7 @@ vlib_main_or_worker_loop (vlib_main_t * vm, int is_main)
for (i = 0; i < _vec_len (nm->pending_frames); i++)
cpu_time_now = dispatch_pending_node (vm, i, cpu_time_now);
/* Reset pending vector for next iteration. */
- _vec_len (nm->pending_frames) = 0;
+ vec_set_len (nm->pending_frames, 0);
if (is_main)
{
@@ -1670,7 +1670,7 @@ vlib_main_or_worker_loop (vlib_main_t * vm, int is_main)
dispatch_suspended_process (vm, di, cpu_time_now);
}
}
- _vec_len (nm->data_from_advancing_timing_wheel) = 0;
+ vec_set_len (nm->data_from_advancing_timing_wheel, 0);
}
}
vlib_increment_main_loop_counter (vm);
@@ -1946,7 +1946,7 @@ vlib_main (vlib_main_t * volatile vm, unformat_input_t * input)
CLIB_CACHE_LINE_BYTES);
vec_validate (nm->data_from_advancing_timing_wheel, 10);
- _vec_len (nm->data_from_advancing_timing_wheel) = 0;
+ vec_set_len (nm->data_from_advancing_timing_wheel, 0);
/* Create the process timing wheel */
TW (tw_timer_wheel_init) ((TWT (tw_timer_wheel) *) nm->timing_wheel,
@@ -1955,9 +1955,9 @@ vlib_main (vlib_main_t * volatile vm, unformat_input_t * input)
~0 /* max expirations per call */ );
vec_validate (vm->pending_rpc_requests, 0);
- _vec_len (vm->pending_rpc_requests) = 0;
+ vec_set_len (vm->pending_rpc_requests, 0);
vec_validate (vm->processing_rpc_requests, 0);
- _vec_len (vm->processing_rpc_requests) = 0;
+ vec_set_len (vm->processing_rpc_requests, 0);
/* Default params for the buffer allocator fault injector, if configured */
if (VLIB_BUFFER_ALLOC_FAULT_INJECTOR > 0)
diff --git a/src/vlib/node_funcs.h b/src/vlib/node_funcs.h
index de6fd4818be..df8ec7c40e6 100644
--- a/src/vlib/node_funcs.h
+++ b/src/vlib/node_funcs.h
@@ -604,7 +604,7 @@ vlib_process_get_events (vlib_main_t * vm, uword ** data_vector)
l = _vec_len (p->pending_event_data_by_type_index[t]);
if (data_vector)
vec_add (*data_vector, p->pending_event_data_by_type_index[t], l);
- _vec_len (p->pending_event_data_by_type_index[t]) = 0;
+ vec_set_len (p->pending_event_data_by_type_index[t], 0);
et = pool_elt_at_index (p->event_type_pool, t);
@@ -628,7 +628,7 @@ vlib_process_get_events_helper (vlib_process_t * p, uword t,
l = _vec_len (p->pending_event_data_by_type_index[t]);
if (data_vector)
vec_add (*data_vector, p->pending_event_data_by_type_index[t], l);
- _vec_len (p->pending_event_data_by_type_index[t]) = 0;
+ vec_set_len (p->pending_event_data_by_type_index[t], 0);
vlib_process_maybe_free_event_type (p, t);
diff --git a/src/vlib/threads.c b/src/vlib/threads.c
index 567ba62891b..36a80800a09 100644
--- a/src/vlib/threads.c
+++ b/src/vlib/threads.c
@@ -235,7 +235,7 @@ vlib_thread_init (vlib_main_t * vm)
/* Set up thread 0 */
vec_validate_aligned (vlib_worker_threads, 0, CLIB_CACHE_LINE_BYTES);
- _vec_len (vlib_worker_threads) = 1;
+ vec_set_len (vlib_worker_threads, 1);
w = vlib_worker_threads;
w->thread_mheap = clib_mem_get_heap ();
w->thread_stack = vlib_thread_stacks[0];
@@ -558,7 +558,7 @@ start_workers (vlib_main_t * vm)
vec_validate_aligned (vgm->vlib_mains, n_vlib_mains - 1,
CLIB_CACHE_LINE_BYTES);
- _vec_len (vgm->vlib_mains) = 0;
+ vec_set_len (vgm->vlib_mains, 0);
vec_add1_aligned (vgm->vlib_mains, vm, CLIB_CACHE_LINE_BYTES);
if (n_vlib_mains > 1)
@@ -640,7 +640,7 @@ start_workers (vlib_main_t * vm)
vm_clone->thread_index = worker_thread_index;
vm_clone->pending_rpc_requests = 0;
vec_validate (vm_clone->pending_rpc_requests, 0);
- _vec_len (vm_clone->pending_rpc_requests) = 0;
+ vec_set_len (vm_clone->pending_rpc_requests, 0);
clib_memset (&vm_clone->random_buffer, 0,
sizeof (vm_clone->random_buffer));
clib_spinlock_init
@@ -670,7 +670,7 @@ start_workers (vlib_main_t * vm)
/* fork the frame dispatch queue */
nm_clone->pending_frames = 0;
vec_validate (nm_clone->pending_frames, 10);
- _vec_len (nm_clone->pending_frames) = 0;
+ vec_set_len (nm_clone->pending_frames, 0);
/* fork nodes */
nm_clone->nodes = 0;
@@ -1616,7 +1616,7 @@ vlib_frame_queue_main_init (u32 node_index, u32 frame_queue_nelts)
fqm->frame_queue_nelts = frame_queue_nelts;
vec_validate (fqm->vlib_frame_queues, tm->n_vlib_mains - 1);
- _vec_len (fqm->vlib_frame_queues) = 0;
+ vec_set_len (fqm->vlib_frame_queues, 0);
for (i = 0; i < tm->n_vlib_mains; i++)
{
fq = vlib_frame_queue_alloc (frame_queue_nelts);
diff --git a/src/vlib/trace.c b/src/vlib/trace.c
index 4bbd9505b71..49b521eb886 100644
--- a/src/vlib/trace.c
+++ b/src/vlib/trace.c
@@ -272,7 +272,7 @@ trace_apply_filter (vlib_main_t * vm)
for (index = 0; index < vec_len (traces_to_remove); index++)
{
trace_index = traces_to_remove[index] - tm->trace_buffer_pool;
- _vec_len (tm->trace_buffer_pool[trace_index]) = 0;
+ vec_set_len (tm->trace_buffer_pool[trace_index], 0);
pool_put_index (tm->trace_buffer_pool, trace_index);
}
diff --git a/src/vlib/trace_funcs.h b/src/vlib/trace_funcs.h
index 9313d41eb7d..3ed4768bc7b 100644
--- a/src/vlib/trace_funcs.h
+++ b/src/vlib/trace_funcs.h
@@ -125,7 +125,7 @@ vlib_free_trace (vlib_main_t * vm, vlib_buffer_t * b)
vlib_trace_main_t *tm = &vm->trace_main;
u32 trace_index = vlib_buffer_get_trace_index (b);
vlib_validate_trace (tm, b);
- _vec_len (tm->trace_buffer_pool[trace_index]) = 0;
+ vec_set_len (tm->trace_buffer_pool[trace_index], 0);
pool_put_index (tm->trace_buffer_pool, trace_index);
}
diff --git a/src/vlib/unix/cli.c b/src/vlib/unix/cli.c
index c546948b536..244c8df3b90 100644
--- a/src/vlib/unix/cli.c
+++ b/src/vlib/unix/cli.c
@@ -1610,7 +1610,7 @@ unix_cli_line_process_one (unix_cli_main_t * cm,
/* Delete the desired text from the command */
memmove (cf->current_command, cf->current_command + j, delta);
- _vec_len (cf->current_command) = delta;
+ vec_set_len (cf->current_command, delta);
/* Print the new contents */
unix_vlib_cli_output_cooked (cf, uf, cf->current_command, delta);
@@ -1635,7 +1635,7 @@ unix_cli_line_process_one (unix_cli_main_t * cm,
unix_vlib_cli_output_cursor_left (cf, uf);
/* Truncate the line at the cursor */
- _vec_len (cf->current_command) = cf->cursor;
+ vec_set_len (cf->current_command, cf->cursor);
cf->search_mode = 0;
break;
@@ -1677,7 +1677,7 @@ unix_cli_line_process_one (unix_cli_main_t * cm,
unix_vlib_cli_output_cooked (cf, uf, (u8 *) " ", 1);
for (; (cf->current_command + cf->cursor) > save; cf->cursor--)
unix_vlib_cli_output_cursor_left (cf, uf);
- _vec_len (cf->current_command) -= delta;
+ vec_dec_len (cf->current_command, delta);
}
}
cf->search_mode = 0;
@@ -1734,13 +1734,13 @@ unix_cli_line_process_one (unix_cli_main_t * cm,
if (cf->excursion == vec_len (cf->command_history))
{
/* down-arrowed to last entry - want a blank line */
- _vec_len (cf->current_command) = 0;
+ vec_set_len (cf->current_command, 0);
}
else if (cf->excursion < 0)
{
/* up-arrowed over the start to the end, want a blank line */
cf->excursion = vec_len (cf->command_history);
- _vec_len (cf->current_command) = 0;
+ vec_set_len (cf->current_command, 0);
}
else
{
@@ -1753,7 +1753,7 @@ unix_cli_line_process_one (unix_cli_main_t * cm,
vec_validate (cf->current_command, vec_len (prev) - 1);
clib_memcpy (cf->current_command, prev, vec_len (prev));
- _vec_len (cf->current_command) = vec_len (prev);
+ vec_set_len (cf->current_command, vec_len (prev));
unix_vlib_cli_output_cooked (cf, uf, cf->current_command,
vec_len (cf->current_command));
}
@@ -1840,7 +1840,7 @@ unix_cli_line_process_one (unix_cli_main_t * cm,
cf->cursor++;
unix_vlib_cli_output_cursor_left (cf, uf);
cf->cursor--;
- _vec_len (cf->current_command)--;
+ vec_dec_len (cf->current_command, 1);
}
else if (cf->cursor > 0)
{
@@ -1848,7 +1848,7 @@ unix_cli_line_process_one (unix_cli_main_t * cm,
j = vec_len (cf->current_command) - cf->cursor;
memmove (cf->current_command + cf->cursor - 1,
cf->current_command + cf->cursor, j);
- _vec_len (cf->current_command)--;
+ vec_dec_len (cf->current_command, 1);
/* redraw the rest of the line */
unix_vlib_cli_output_cursor_left (cf, uf);
@@ -1884,7 +1884,7 @@ unix_cli_line_process_one (unix_cli_main_t * cm,
j = vec_len (cf->current_command) - cf->cursor - 1;
memmove (cf->current_command + cf->cursor,
cf->current_command + cf->cursor + 1, j);
- _vec_len (cf->current_command)--;
+ vec_dec_len (cf->current_command, 1);
/* redraw the rest of the line */
unix_vlib_cli_output_cooked (cf, uf,
cf->current_command + cf->cursor,
@@ -1956,7 +1956,7 @@ unix_cli_line_process_one (unix_cli_main_t * cm,
vec_resize (save, vec_len (cf->current_command) - cf->cursor);
clib_memcpy (save, cf->current_command + cf->cursor,
vec_len (cf->current_command) - cf->cursor);
- _vec_len (cf->current_command) = cf->cursor;
+ vec_set_len (cf->current_command, cf->cursor);
}
else
{
@@ -1978,7 +1978,7 @@ unix_cli_line_process_one (unix_cli_main_t * cm,
cf->cursor--;
j--;
}
- _vec_len (cf->current_command) = j;
+ vec_set_len (cf->current_command, j);
/* replace it with the newly expanded command */
vec_append (cf->current_command, completed);
@@ -2385,7 +2385,7 @@ unix_cli_line_process_one (unix_cli_main_t * cm,
vec_validate (cf->current_command, vec_len (item) - 1);
clib_memcpy (cf->current_command, item, vec_len (item));
- _vec_len (cf->current_command) = vec_len (item);
+ vec_set_len (cf->current_command, vec_len (item));
unix_vlib_cli_output_cooked (cf, uf, cf->current_command,
vec_len (cf->current_command));
@@ -2599,7 +2599,7 @@ more:
0 /* level */ ,
8 /* max_level */ );
/* Macro processor NULL terminates the return */
- _vec_len (expanded) -= 1;
+ vec_dec_len (expanded, 1);
vec_reset_length (cf->current_command);
vec_append (cf->current_command, expanded);
vec_free (expanded);
@@ -2754,7 +2754,7 @@ unix_cli_process (vlib_main_t * vm,
}
if (data)
- _vec_len (data) = 0;
+ vec_set_len (data, 0);
}
done:
@@ -2836,7 +2836,7 @@ unix_cli_read_ready (clib_file_t * uf)
return clib_error_return_unix (0, "read");
n_read = n < 0 ? 0 : n;
- _vec_len (cf->input_vector) = l + n_read;
+ vec_set_len (cf->input_vector, l + n_read);
}
if (!(n < 0))
@@ -2918,7 +2918,7 @@ unix_cli_file_add (unix_cli_main_t * cm, char *name, int fd)
vec_free (old_name);
vlib_node_set_state (vm, n->index, VLIB_NODE_STATE_POLLING);
- _vec_len (cm->unused_cli_process_node_indices) = l - 1;
+ vec_set_len (cm->unused_cli_process_node_indices, l - 1);
}
else
{
@@ -2954,7 +2954,7 @@ unix_cli_file_add (unix_cli_main_t * cm, char *name, int fd)
cf->output_vector = 0;
cf->input_vector = 0;
vec_validate (cf->current_command, 0);
- _vec_len (cf->current_command) = 0;
+ vec_set_len (cf->current_command, 0);
vlib_start_process (vm, n->runtime_index);
@@ -3445,7 +3445,7 @@ unix_cli_exec (vlib_main_t * vm,
0 /* level */ ,
8 /* max_level */ );
/* Macro processor NULL terminates the return */
- _vec_len (expanded) -= 1;
+ vec_dec_len (expanded, 1);
vec_reset_length (sub_input.buffer);
vec_append (sub_input.buffer, expanded);
vec_free (expanded);
diff --git a/src/vlib/unix/main.c b/src/vlib/unix/main.c
index 0b73597dab3..3710d8e8b68 100644
--- a/src/vlib/unix/main.c
+++ b/src/vlib/unix/main.c
@@ -316,7 +316,7 @@ startup_config_process (vlib_main_t * vm,
n = read (fd, buf + l, 4096);
if (n > 0)
{
- _vec_len (buf) = l + n;
+ vec_set_len (buf, l + n);
if (n < 4096)
break;
}
diff --git a/src/vlib/unix/mc_socket.c b/src/vlib/unix/mc_socket.c
index 9800b1e744c..1f3b4e9a8f1 100644
--- a/src/vlib/unix/mc_socket.c
+++ b/src/vlib/unix/mc_socket.c
@@ -90,7 +90,7 @@ sendmsg_helper (mc_socket_main_t * msm,
h.msg_namelen = sizeof (tx_addr[0]);
if (msm->iovecs)
- _vec_len (msm->iovecs) = 0;
+ vec_set_len (msm->iovecs, 0);
n_bytes = append_buffer_index_to_iovec (vm, buffer_index, &msm->iovecs);
ASSERT (n_bytes <= msm->mc_main.transport.max_packet_size);
@@ -177,7 +177,7 @@ recvmsg_helper (mc_socket_main_t * msm,
vec_validate (msm->rx_buffers, max_alloc - 1);
n_alloc =
vlib_buffer_alloc (vm, msm->rx_buffers + n_left, max_alloc - n_left);
- _vec_len (msm->rx_buffers) = n_left + n_alloc;
+ vec_set_len (msm->rx_buffers, n_left + n_alloc);
}
ASSERT (vec_len (msm->rx_buffers) >= n_mtu);
@@ -192,7 +192,7 @@ recvmsg_helper (mc_socket_main_t * msm,
msm->iovecs[i].iov_base = b->data;
msm->iovecs[i].iov_len = buffer_size;
}
- _vec_len (msm->iovecs) = n_mtu;
+ vec_set_len (msm->iovecs, n_mtu);
{
struct msghdr h;
@@ -237,7 +237,7 @@ recvmsg_helper (mc_socket_main_t * msm,
b->next_buffer = msm->rx_buffers[i_rx];
}
- _vec_len (msm->rx_buffers) = i_rx;
+ vec_set_len (msm->rx_buffers, i_rx);
return 0 /* no error */ ;
}
@@ -418,7 +418,7 @@ catchup_socket_read_ready (clib_file_t * uf, int is_server)
}
}
- _vec_len (c->input_vector) = l + n;
+ vec_set_len (c->input_vector, l + n);
if (is_eof && vec_len (c->input_vector) > 0)
{
@@ -426,7 +426,7 @@ catchup_socket_read_ready (clib_file_t * uf, int is_server)
{
mc_msg_catchup_request_handler (mcm, (void *) c->input_vector,
c - msm->catchups);
- _vec_len (c->input_vector) = 0;
+ vec_set_len (c->input_vector, 0);
}
else
{
diff --git a/src/vlib/unix/util.c b/src/vlib/unix/util.c
index 03aef364357..04cd6f593ac 100644
--- a/src/vlib/unix/util.c
+++ b/src/vlib/unix/util.c
@@ -86,8 +86,8 @@ foreach_directory_file (char *dir_name,
s = format (s, "%s/%s", dir_name, e->d_name);
t = format (t, "%s", e->d_name);
error = f (arg, s, t);
- _vec_len (s) = 0;
- _vec_len (t) = 0;
+ vec_set_len (s, 0);
+ vec_set_len (t, 0);
if (error)
break;
@@ -116,7 +116,7 @@ vlib_unix_recursive_mkdir (char *path)
error = clib_error_return_unix (0, "mkdir '%s'", c);
goto done;
}
- _vec_len (c)--;
+ vec_dec_len (c, 1);
}
vec_add1 (c, path[i]);
i++;
diff --git a/src/vlibapi/node_serialize.c b/src/vlibapi/node_serialize.c
index b50d79e2922..061f763358d 100644
--- a/src/vlibapi/node_serialize.c
+++ b/src/vlibapi/node_serialize.c
@@ -176,7 +176,7 @@ vlib_node_unserialize (u8 * vector)
nstat_vms = unserialize_likely_small_unsigned_integer (sm);
vec_validate (nodes_by_thread, nstat_vms - 1);
- _vec_len (nodes_by_thread) = 0;
+ vec_set_len (nodes_by_thread, 0);
for (i = 0; i < nstat_vms; i++)
{
diff --git a/src/vlibmemory/memclnt_api.c b/src/vlibmemory/memclnt_api.c
index 87bb36a5426..289a4c5d947 100644
--- a/src/vlibmemory/memclnt_api.c
+++ b/src/vlibmemory/memclnt_api.c
@@ -500,7 +500,7 @@ api_rx_from_node (vlib_main_t *vm, vlib_node_runtime_t *node,
if (b0->flags & VLIB_BUFFER_NEXT_PRESENT)
{
ASSERT (long_msg != 0);
- _vec_len (long_msg) = 0;
+ vec_set_len (long_msg, 0);
vec_add (long_msg, msg, msg_len);
while (b0->flags & VLIB_BUFFER_NEXT_PRESENT)
{
diff --git a/src/vlibmemory/memory_shared.c b/src/vlibmemory/memory_shared.c
index 1716f271466..5244b27ad37 100644
--- a/src/vlibmemory/memory_shared.c
+++ b/src/vlibmemory/memory_shared.c
@@ -545,8 +545,8 @@ vl_map_shmem (const char *region_name, int is_vlib)
if (strstr (region_name, vpe_api_region_suffix))
{
u8 *root_path = format (0, "%s", region_name);
- _vec_len (root_path) = (vec_len (root_path) -
- strlen (vpe_api_region_suffix));
+ vec_set_len (root_path,
+ vec_len (root_path) - strlen (vpe_api_region_suffix));
vec_terminate_c_string (root_path);
a->root_path = (const char *) root_path;
am->root_path = (const char *) root_path;
diff --git a/src/vlibmemory/socket_client.c b/src/vlibmemory/socket_client.c
index 7082d8ba7e0..237d2224d24 100644
--- a/src/vlibmemory/socket_client.c
+++ b/src/vlibmemory/socket_client.c
@@ -93,7 +93,7 @@ vl_socket_client_read_internal (socket_client_main_t * scm, int wait)
current_rx_index = vec_len (scm->socket_rx_buffer);
vec_validate (scm->socket_rx_buffer, current_rx_index
+ scm->socket_buffer_size - 1);
- _vec_len (scm->socket_rx_buffer) = current_rx_index;
+ vec_set_len (scm->socket_rx_buffer, current_rx_index);
n = read (scm->socket_fd, scm->socket_rx_buffer + current_rx_index,
scm->socket_buffer_size);
if (n < 0)
@@ -104,7 +104,7 @@ vl_socket_client_read_internal (socket_client_main_t * scm, int wait)
clib_unix_warning ("socket_read");
return -1;
}
- _vec_len (scm->socket_rx_buffer) += n;
+ vec_inc_len (scm->socket_rx_buffer, n);
}
#if CLIB_DEBUG > 1
@@ -116,7 +116,7 @@ vl_socket_client_read_internal (socket_client_main_t * scm, int wait)
data_len = ntohl (mbp->data_len);
current_rx_index = vec_len (scm->socket_rx_buffer);
vec_validate (scm->socket_rx_buffer, current_rx_index + data_len);
- _vec_len (scm->socket_rx_buffer) = current_rx_index;
+ vec_set_len (scm->socket_rx_buffer, current_rx_index);
mbp = (msgbuf_t *) (scm->socket_rx_buffer);
msg_size = data_len + sizeof (*mbp);
@@ -133,7 +133,7 @@ vl_socket_client_read_internal (socket_client_main_t * scm, int wait)
clib_unix_warning ("socket_read");
return -1;
}
- _vec_len (scm->socket_rx_buffer) += n;
+ vec_inc_len (scm->socket_rx_buffer, n);
}
if (vec_len (scm->socket_rx_buffer) >= data_len + sizeof (*mbp))
@@ -141,7 +141,7 @@ vl_socket_client_read_internal (socket_client_main_t * scm, int wait)
vl_msg_api_socket_handler ((void *) (mbp->data), data_len);
if (vec_len (scm->socket_rx_buffer) == data_len + sizeof (*mbp))
- _vec_len (scm->socket_rx_buffer) = 0;
+ vec_set_len (scm->socket_rx_buffer, 0);
else
vec_delete (scm->socket_rx_buffer, data_len + sizeof (*mbp), 0);
mbp = 0;
@@ -480,8 +480,8 @@ vl_socket_client_connect_internal (socket_client_main_t * scm,
SOCKET_CLIENT_DEFAULT_BUFFER_SIZE;
vec_validate (scm->socket_tx_buffer, scm->socket_buffer_size - 1);
vec_validate (scm->socket_rx_buffer, scm->socket_buffer_size - 1);
- _vec_len (scm->socket_rx_buffer) = 0;
- _vec_len (scm->socket_tx_buffer) = 0;
+ vec_set_len (scm->socket_rx_buffer, 0);
+ vec_set_len (scm->socket_tx_buffer, 0);
scm->name = format (0, "%s", client_name);
mp = vl_socket_client_msg_alloc2 (scm, sizeof (*mp));
diff --git a/src/vlibmemory/vlib_api_cli.c b/src/vlibmemory/vlib_api_cli.c
index e3e7ee38e10..732ced7634c 100644
--- a/src/vlibmemory/vlib_api_cli.c
+++ b/src/vlibmemory/vlib_api_cli.c
@@ -673,7 +673,7 @@ vl_msg_api_process_file (vlib_main_t * vm, u8 * filename,
break;
}
- _vec_len (tmpbuf) = 0;
+ vec_set_len (tmpbuf, 0);
msg += size;
}
@@ -1285,7 +1285,7 @@ extract_name (u8 * s)
rv = vec_dup (s);
while (vec_len (rv) && rv[vec_len (rv)] != '_')
- _vec_len (rv)--;
+ vec_dec_len (rv, 0);
rv[vec_len (rv)] = 0;
diff --git a/src/vnet/bfd/bfd_main.c b/src/vnet/bfd/bfd_main.c
index f77d66c9db8..4f5b36b37e4 100644
--- a/src/vnet/bfd/bfd_main.c
+++ b/src/vnet/bfd/bfd_main.c
@@ -1266,11 +1266,11 @@ bfd_process (vlib_main_t *vm, CLIB_UNUSED (vlib_node_runtime_t *rt),
bfd_unlock (bm);
if (expired)
{
- _vec_len (expired) = 0;
+ vec_set_len (expired, 0);
}
if (event_data)
{
- _vec_len (event_data) = 0;
+ vec_set_len (event_data, 0);
}
}
diff --git a/src/vnet/classify/vnet_classify.c b/src/vnet/classify/vnet_classify.c
index 1bdbee764a8..c9a6fc6ac5b 100644
--- a/src/vnet/classify/vnet_classify.c
+++ b/src/vnet/classify/vnet_classify.c
@@ -1320,7 +1320,7 @@ unformat_classify_mask (unformat_input_t * input, va_list * args)
if (match == 0)
clib_warning ("BUG: match 0");
- _vec_len (mask) = match * sizeof (u32x4);
+ vec_set_len (mask, match * sizeof (u32x4));
*matchp = match;
*maskp = mask;
@@ -2770,8 +2770,8 @@ unformat_classify_match (unformat_input_t * input, va_list * args)
sizeof (u32x4));
/* Set size, include skipped vectors */
- _vec_len (match) =
- (t->match_n_vectors + t->skip_n_vectors) * sizeof (u32x4);
+ vec_set_len (match,
+ (t->match_n_vectors + t->skip_n_vectors) * sizeof (u32x4));
*matchp = match;
diff --git a/src/vnet/config.c b/src/vnet/config.c
index 4ff001a17f8..c05da663fb7 100644
--- a/src/vnet/config.c
+++ b/src/vnet/config.c
@@ -97,7 +97,7 @@ find_config_with_features (vlib_main_t * vm,
config_string = cm->config_string_temp;
cm->config_string_temp = 0;
if (config_string)
- _vec_len (config_string) = 0;
+ vec_set_len (config_string, 0);
vec_foreach (f, feature_vector)
{
@@ -296,7 +296,7 @@ vnet_config_modify_end_node (vlib_main_t * vm,
if (new_features[last].node_index == cm->default_end_node_index)
{
vec_free (new_features->feature_config);
- _vec_len (new_features) = last;
+ vec_set_len (new_features, last);
}
}
diff --git a/src/vnet/devices/af_packet/node.c b/src/vnet/devices/af_packet/node.c
index 323508bd304..631bbac1117 100644
--- a/src/vnet/devices/af_packet/node.c
+++ b/src/vnet/devices/af_packet/node.c
@@ -293,7 +293,7 @@ af_packet_device_input_fn (vlib_main_t *vm, vlib_node_runtime_t *node,
n_required + n_free_bufs - 1);
n_free_bufs += vlib_buffer_alloc (
vm, &apm->rx_buffers[thread_index][n_free_bufs], n_required);
- _vec_len (apm->rx_buffers[thread_index]) = n_free_bufs;
+ vec_set_len (apm->rx_buffers[thread_index], n_free_bufs);
}
while (num_pkts && (n_free_bufs >= min_bufs))
@@ -341,7 +341,8 @@ af_packet_device_input_fn (vlib_main_t *vm, vlib_node_runtime_t *node,
u32 last_empty_buffer =
vec_len (apm->rx_buffers[thread_index]) - 1;
bi0 = apm->rx_buffers[thread_index][last_empty_buffer];
- _vec_len (apm->rx_buffers[thread_index]) = last_empty_buffer;
+ vec_set_len (apm->rx_buffers[thread_index],
+ last_empty_buffer);
n_free_bufs--;
/* copy data */
diff --git a/src/vnet/dpo/load_balance.c b/src/vnet/dpo/load_balance.c
index 4666c9a7ca1..9001a351ccb 100644
--- a/src/vnet/dpo/load_balance.c
+++ b/src/vnet/dpo/load_balance.c
@@ -408,7 +408,7 @@ ip_multipath_normalize_next_hops (const load_balance_path_t * raw_next_hops,
{
nhs[0] = raw_next_hops[0];
nhs[0].path_weight = 1;
- _vec_len (nhs) = 1;
+ vec_set_len (nhs, 1);
sum_weight = 1;
goto done;
}
@@ -425,7 +425,7 @@ ip_multipath_normalize_next_hops (const load_balance_path_t * raw_next_hops,
if (nhs[0].path_weight == nhs[1].path_weight)
{
nhs[0].path_weight = nhs[1].path_weight = 1;
- _vec_len (nhs) = 2;
+ vec_set_len (nhs, 2);
sum_weight = 2;
goto done;
}
@@ -491,7 +491,7 @@ ip_multipath_normalize_next_hops (const load_balance_path_t * raw_next_hops,
if (error <= multipath_next_hop_error_tolerance*n_adj)
{
/* Truncate any next hops with zero weight. */
- _vec_len (nhs) = i;
+ vec_set_len (nhs, i);
break;
}
}
diff --git a/src/vnet/dpo/load_balance_map.c b/src/vnet/dpo/load_balance_map.c
index 55249747e5d..765cd856608 100644
--- a/src/vnet/dpo/load_balance_map.c
+++ b/src/vnet/dpo/load_balance_map.c
@@ -317,7 +317,7 @@ load_balance_map_fill (load_balance_map_t *lbm)
bucket += lbmp->lbmp_weight;
}
}
- _vec_len(tmp_buckets) = jj;
+ vec_set_len (tmp_buckets, jj);
/*
* If the number of temporaries written is as many as we need, implying
diff --git a/src/vnet/fib/fib_path_list.c b/src/vnet/fib/fib_path_list.c
index d7e860ecb8c..ebd2c0e9be1 100644
--- a/src/vnet/fib/fib_path_list.c
+++ b/src/vnet/fib/fib_path_list.c
@@ -964,8 +964,7 @@ fib_path_list_copy_and_path_add (fib_node_index_t orig_path_list_index,
}
if (duplicate)
{
- _vec_len(path_list->fpl_paths) =
- vec_len(path_list->fpl_paths) - 1;
+ vec_set_len(path_list->fpl_paths, vec_len(path_list->fpl_paths) - 1);
fib_path_destroy(new_path_index);
}
else
diff --git a/src/vnet/fib/fib_urpf_list.c b/src/vnet/fib/fib_urpf_list.c
index 55f3b8a526b..b1bbe7399d1 100644
--- a/src/vnet/fib/fib_urpf_list.c
+++ b/src/vnet/fib/fib_urpf_list.c
@@ -173,7 +173,7 @@ fib_urpf_list_bake (index_t ui)
if (urpf->furpf_itfs[i] != urpf->furpf_itfs[j])
urpf->furpf_itfs[++i] = urpf->furpf_itfs[j];
/* set the length of the vector to the number of unique itfs */
- _vec_len(urpf->furpf_itfs) = i+1;
+ vec_set_len (urpf->furpf_itfs, i+1);
}
urpf->furpf_flags |= FIB_URPF_LIST_BAKED;
diff --git a/src/vnet/gso/node.c b/src/vnet/gso/node.c
index 093cd669e3c..97bccc8879c 100644
--- a/src/vnet/gso/node.c
+++ b/src/vnet/gso/node.c
@@ -759,7 +759,7 @@ vnet_gso_node_inline (vlib_main_t * vm,
to_next, n_left_to_next);
}
/* The buffers were enqueued. Reset the length */
- _vec_len (ptd->split_buffers) = 0;
+ vec_set_len (ptd->split_buffers, 0);
/* Free the now segmented buffer */
vlib_buffer_free_one (vm, bi0);
b += 1;
diff --git a/src/vnet/interface.c b/src/vnet/interface.c
index c44f2647ddf..9ce7f6f9aef 100644
--- a/src/vnet/interface.c
+++ b/src/vnet/interface.c
@@ -163,7 +163,7 @@ serialize_vnet_interface_state (serialize_main_t * m, va_list * va)
vec_serialize (m, sts, serialize_vec_vnet_sw_hw_interface_state);
if (sts)
- _vec_len (sts) = 0;
+ vec_set_len (sts, 0);
/* *INDENT-OFF* */
pool_foreach (hif, im->hw_interfaces) {
@@ -992,7 +992,7 @@ vnet_register_interface (vnet_main_t * vnm,
VLIB_NODE_RUNTIME_PERF_RESET);
}
- _vec_len (im->deleted_hw_interface_nodes) -= 1;
+ vec_dec_len (im->deleted_hw_interface_nodes, 1);
}
else
{
diff --git a/src/vnet/interface_cli.c b/src/vnet/interface_cli.c
index 452849eaf9f..4de908f88f0 100644
--- a/src/vnet/interface_cli.c
+++ b/src/vnet/interface_cli.c
@@ -415,7 +415,7 @@ show_sw_interfaces (vlib_main_t * vm,
/* Gather interfaces. */
sorted_sis =
vec_new (vnet_sw_interface_t, pool_elts (im->sw_interfaces));
- _vec_len (sorted_sis) = 0;
+ vec_set_len (sorted_sis, 0);
/* *INDENT-OFF* */
pool_foreach (si, im->sw_interfaces)
{
@@ -1236,7 +1236,7 @@ show_interface_sec_mac_addr_fn (vlib_main_t * vm, unformat_input_t * input,
{
sorted_sis =
vec_new (vnet_sw_interface_t, pool_elts (im->sw_interfaces));
- _vec_len (sorted_sis) = 0;
+ vec_set_len (sorted_sis, 0);
/* *INDENT-OFF* */
pool_foreach (si, im->sw_interfaces)
{
diff --git a/src/vnet/interface_format.c b/src/vnet/interface_format.c
index 1ef4704257c..e34b6fb62c0 100644
--- a/src/vnet/interface_format.c
+++ b/src/vnet/interface_format.c
@@ -369,11 +369,11 @@ format_vnet_sw_interface_cntrs (u8 * s, vnet_interface_main_t * im,
n_printed += 2;
if (n)
- _vec_len (n) = 0;
+ vec_set_len (n, 0);
n = format (n, "%s packets", cm->name);
s = format (s, "%-16v%16Ld", n, vtotal.packets);
- _vec_len (n) = 0;
+ vec_set_len (n, 0);
n = format (n, "%s bytes", cm->name);
s = format (s, "\n%U%-16v%16Ld",
format_white_space, indent, n, vtotal.bytes);
diff --git a/src/vnet/ip/ip_api.c b/src/vnet/ip/ip_api.c
index 3ff3a6ce5e0..ae4ee0cec52 100644
--- a/src/vnet/ip/ip_api.c
+++ b/src/vnet/ip/ip_api.c
@@ -1237,7 +1237,7 @@ vl_api_ip_dump_t_handler (vl_api_ip_dump_t * mp)
/* Gather interfaces. */
sorted_sis = vec_new (vnet_sw_interface_t, pool_elts (im->sw_interfaces));
- _vec_len (sorted_sis) = 0;
+ vec_set_len (sorted_sis, 0);
/* *INDENT-OFF* */
pool_foreach (si, im->sw_interfaces)
{
diff --git a/src/vnet/ip/reass/ip4_full_reass.c b/src/vnet/ip/reass/ip4_full_reass.c
index 220117278c0..e4839aaa981 100644
--- a/src/vnet/ip/reass/ip4_full_reass.c
+++ b/src/vnet/ip/reass/ip4_full_reass.c
@@ -1615,7 +1615,7 @@ ip4_full_reass_walk_expired (vlib_main_t *vm, vlib_node_runtime_t *node,
vec_free (pool_indexes_to_free);
if (event_data)
{
- _vec_len (event_data) = 0;
+ vec_set_len (event_data, 0);
}
}
diff --git a/src/vnet/ip/reass/ip4_sv_reass.c b/src/vnet/ip/reass/ip4_sv_reass.c
index 9971dafd9fd..dfe3f578e98 100644
--- a/src/vnet/ip/reass/ip4_sv_reass.c
+++ b/src/vnet/ip/reass/ip4_sv_reass.c
@@ -924,7 +924,8 @@ slow_path:
to_next, n_left_to_next, bi0,
next0);
}
- _vec_len (reass->cached_buffers) = 0; // buffers are owned by frame now
+ vec_set_len (reass->cached_buffers,
+ 0); // buffers are owned by frame now
}
goto next_packet;
@@ -1303,7 +1304,7 @@ ip4_sv_reass_walk_expired (vlib_main_t *vm,
vec_free (pool_indexes_to_free);
if (event_data)
{
- _vec_len (event_data) = 0;
+ vec_set_len (event_data, 0);
}
}
diff --git a/src/vnet/ip/reass/ip6_full_reass.c b/src/vnet/ip/reass/ip6_full_reass.c
index 1bcb6bd0f20..3b61d141d85 100644
--- a/src/vnet/ip/reass/ip6_full_reass.c
+++ b/src/vnet/ip/reass/ip6_full_reass.c
@@ -1647,7 +1647,7 @@ ip6_full_reass_walk_expired (vlib_main_t *vm, vlib_node_runtime_t *node,
vec_free (vec_icmp_bi);
if (event_data)
{
- _vec_len (event_data) = 0;
+ vec_set_len (event_data, 0);
}
}
diff --git a/src/vnet/ip/reass/ip6_sv_reass.c b/src/vnet/ip/reass/ip6_sv_reass.c
index 23ae6784127..e1493c95e54 100644
--- a/src/vnet/ip/reass/ip6_sv_reass.c
+++ b/src/vnet/ip/reass/ip6_sv_reass.c
@@ -734,7 +734,8 @@ ip6_sv_reassembly_inline (vlib_main_t * vm,
to_next, n_left_to_next, bi0,
next0);
}
- _vec_len (reass->cached_buffers) = 0; // buffers are owned by frame now
+ vec_set_len (reass->cached_buffers,
+ 0); // buffers are owned by frame now
}
goto next_packet;
@@ -1050,7 +1051,7 @@ ip6_sv_reass_walk_expired (vlib_main_t *vm,
vec_free (pool_indexes_to_free);
if (event_data)
{
- _vec_len (event_data) = 0;
+ vec_set_len (event_data, 0);
}
}
diff --git a/src/vnet/ipsec/ipsec_cli.c b/src/vnet/ipsec/ipsec_cli.c
index 95e8145fe92..c48d6855169 100644
--- a/src/vnet/ipsec/ipsec_cli.c
+++ b/src/vnet/ipsec/ipsec_cli.c
@@ -652,7 +652,7 @@ ipsec_show_backends_command_fn (vlib_main_t * vm,
}
/* *INDENT-ON* */
vlib_cli_output (vm, "%v", s);
- _vec_len (s) = 0;
+ vec_set_len (s, 0);
vlib_cli_output (vm, "IPsec ESP backends available:");
s = format (s, "%=25s %=25s %=10s\n", "Name", "Index", "Active");
ipsec_esp_backend_t *eb;
diff --git a/src/vnet/l2/l2_input.c b/src/vnet/l2/l2_input.c
index de22cef600e..b09555aa6ed 100644
--- a/src/vnet/l2/l2_input.c
+++ b/src/vnet/l2/l2_input.c
@@ -809,7 +809,7 @@ show_int_mode (vlib_main_t * vm,
{
/* Gather interfaces. */
sis = vec_new (vnet_sw_interface_t, pool_elts (im->sw_interfaces));
- _vec_len (sis) = 0;
+ vec_set_len (sis, 0);
/* *INDENT-OFF* */
pool_foreach (si, im->sw_interfaces) { vec_add1 (sis, si[0]); }
/* *INDENT-ON* */
diff --git a/src/vnet/pg/input.c b/src/vnet/pg/input.c
index 14c8b98d540..6f38ed0869a 100644
--- a/src/vnet/pg/input.c
+++ b/src/vnet/pg/input.c
@@ -965,7 +965,7 @@ pg_generate_fix_multi_buffer_lengths (pg_main_t * pg,
if (vec_len (unused_buffers) > 0)
{
vlib_buffer_free_no_next (vm, unused_buffers, vec_len (unused_buffers));
- _vec_len (unused_buffers) = 0;
+ vec_set_len (unused_buffers, 0);
}
}
diff --git a/src/vnet/pg/pg.h b/src/vnet/pg/pg.h
index 963d23a8e01..e69ee6458e7 100644
--- a/src/vnet/pg/pg.h
+++ b/src/vnet/pg/pg.h
@@ -296,7 +296,7 @@ pg_free_edit_group (pg_stream_t * s)
pg_edit_group_free (g);
clib_memset (g, 0, sizeof (g[0]));
- _vec_len (s->edit_groups) = i;
+ vec_set_len (s->edit_groups, i);
}
typedef enum pg_interface_mode_t_
diff --git a/src/vnet/tcp/tcp_debug.c b/src/vnet/tcp/tcp_debug.c
index e3d7452b591..309b6951559 100644
--- a/src/vnet/tcp/tcp_debug.c
+++ b/src/vnet/tcp/tcp_debug.c
@@ -26,7 +26,7 @@ tcp_evt_track_register (elog_track_t * et)
if (fl_len)
{
track_index = tdm->free_track_indices[fl_len - 1];
- _vec_len (tdm->free_track_indices) -= 1;
+ vec_dec_len (tdm->free_track_indices, 1);
et->track_index_plus_one = track_index + 1;
}
else
diff --git a/src/vnet/tcp/tcp_input.c b/src/vnet/tcp/tcp_input.c
index 160619d2d95..4950553fc7a 100644
--- a/src/vnet/tcp/tcp_input.c
+++ b/src/vnet/tcp/tcp_input.c
@@ -594,7 +594,7 @@ tcp_handle_postponed_dequeues (tcp_worker_ctx_t * wrk)
tc->burst_acked = 0;
}
- _vec_len (wrk->pending_deq_acked) = 0;
+ vec_set_len (wrk->pending_deq_acked, 0);
}
static void
@@ -1099,7 +1099,7 @@ tcp_handle_disconnects (tcp_worker_ctx_t * wrk)
tcp_disconnect_pending_off (tc);
session_transport_closing_notify (&tc->connection);
}
- _vec_len (wrk->pending_disconnects) = 0;
+ vec_set_len (wrk->pending_disconnects, 0);
}
if (vec_len (wrk->pending_resets))
@@ -1112,7 +1112,7 @@ tcp_handle_disconnects (tcp_worker_ctx_t * wrk)
tcp_disconnect_pending_off (tc);
tcp_handle_rst (tc);
}
- _vec_len (wrk->pending_resets) = 0;
+ vec_set_len (wrk->pending_resets, 0);
}
}
diff --git a/src/vnet/udp/udp_inlines.h b/src/vnet/udp/udp_inlines.h
index d79dc9a2bad..915f891f8b9 100644
--- a/src/vnet/udp/udp_inlines.h
+++ b/src/vnet/udp/udp_inlines.h
@@ -142,7 +142,7 @@ ip_udp_encap_two (vlib_main_t *vm, vlib_buffer_t *b0, vlib_buffer_t *b1,
udp_header_t *udp0, *udp1;
int payload_ip4 = (payload_family == AF_IP4);
- ASSERT (_vec_len (ec0) == _vec_len (ec1));
+ ASSERT (vec_len (ec0) == vec_len (ec1));
if (payload_family < N_AF)
{
diff --git a/src/vnet/unix/tuntap.c b/src/vnet/unix/tuntap.c
index c588cfd208c..1ce13e79254 100644
--- a/src/vnet/unix/tuntap.c
+++ b/src/vnet/unix/tuntap.c
@@ -172,7 +172,7 @@ tuntap_tx (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
/* Re-set iovecs if present. */
if (tm->threads[thread_index].iovecs)
- _vec_len (tm->threads[thread_index].iovecs) = 0;
+ vec_set_len (tm->threads[thread_index].iovecs, 0);
/** VLIB buffer chain -> Unix iovec(s). */
vec_add2 (tm->threads[thread_index].iovecs, iov, 1);
@@ -260,7 +260,7 @@ tuntap_rx (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
vlib_buffer_alloc (vm,
tm->threads[thread_index].rx_buffers + n_left,
VLIB_FRAME_SIZE - n_left);
- _vec_len (tm->threads[thread_index].rx_buffers) = n_left + n_alloc;
+ vec_set_len (tm->threads[thread_index].rx_buffers, n_left + n_alloc);
}
}
@@ -324,7 +324,7 @@ tuntap_rx (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
+ VNET_INTERFACE_COUNTER_RX,
thread_index, tm->sw_if_index, 1, n_bytes_in_packet);
- _vec_len (tm->threads[thread_index].rx_buffers) = i_rx;
+ vec_set_len (tm->threads[thread_index].rx_buffers, i_rx);
}
b = vlib_get_buffer (vm, bi);
diff --git a/src/vnet/vxlan-gpe/vxlan_gpe.c b/src/vnet/vxlan-gpe/vxlan_gpe.c
index 8ef94d44337..a926847051f 100644
--- a/src/vnet/vxlan-gpe/vxlan_gpe.c
+++ b/src/vnet/vxlan-gpe/vxlan_gpe.c
@@ -544,7 +544,7 @@ int vnet_vxlan_gpe_add_del_tunnel
vnet_interface_main_t *im = &vnm->interface_main;
hw_if_index = ngm->free_vxlan_gpe_tunnel_hw_if_indices
[vec_len (ngm->free_vxlan_gpe_tunnel_hw_if_indices) - 1];
- _vec_len (ngm->free_vxlan_gpe_tunnel_hw_if_indices) -= 1;
+ vec_dec_len (ngm->free_vxlan_gpe_tunnel_hw_if_indices, 1);
hi = vnet_get_hw_interface (vnm, hw_if_index);
hi->dev_instance = t - ngm->tunnels;
diff --git a/src/vpp/api/api_main.c b/src/vpp/api/api_main.c
index 63bb5f21c06..47d974877e1 100644
--- a/src/vpp/api/api_main.c
+++ b/src/vpp/api/api_main.c
@@ -176,7 +176,7 @@ api_command_fn (vlib_main_t * vm,
maybe_register_api_client (vam);
/* vec_validated in the init routine */
- _vec_len (vam->inbuf) = 0;
+ vec_set_len (vam->inbuf, 0);
vam->input = &_input;
diff --git a/src/vpp/api/plugin.c b/src/vpp/api/plugin.c
index 3d89161cb86..e7ca874dbc9 100644
--- a/src/vpp/api/plugin.c
+++ b/src/vpp/api/plugin.c
@@ -170,7 +170,7 @@ vat_load_new_plugins (plugin_main_t * pm)
{
vec_free (file_name);
vec_free (plugin_name);
- _vec_len (pm->plugin_info) = vec_len (pm->plugin_info) - 1;
+ vec_set_len (pm->plugin_info, vec_len (pm->plugin_info) - 1);
continue;
}
hash_set_mem (pm->plugin_by_name_hash, plugin_name,
diff --git a/src/vppinfra/bitmap.h b/src/vppinfra/bitmap.h
index 096d3f1aa4a..02f9c7e55ab 100644
--- a/src/vppinfra/bitmap.h
+++ b/src/vppinfra/bitmap.h
@@ -142,7 +142,7 @@ _clib_bitmap_remove_trailing_zeros (uword * a)
for (i = _vec_len (a) - 1; i >= 0; i--)
if (a[i] != 0)
break;
- _vec_len (a) = i + 1;
+ vec_set_len (a, i + 1);
}
return a;
}
@@ -518,29 +518,32 @@ always_inline uword *clib_bitmap_or (uword * ai, uword * bi);
always_inline uword *clib_bitmap_xor (uword * ai, uword * bi);
/* ALU function definition macro for functions taking two bitmaps. */
-#define _(name, body, check_zero) \
-always_inline uword * \
-clib_bitmap_##name (uword * ai, uword * bi) \
-{ \
- uword i, a, b, bi_len, n_trailing_zeros; \
- \
- n_trailing_zeros = 0; \
- bi_len = vec_len (bi); \
- if (bi_len > 0) \
- clib_bitmap_vec_validate (ai, bi_len - 1); \
- for (i = 0; i < vec_len (ai); i++) \
- { \
- a = ai[i]; \
- b = i < bi_len ? bi[i] : 0; \
- do { body; } while (0); \
- ai[i] = a; \
- if (check_zero) \
- n_trailing_zeros = a ? 0 : (n_trailing_zeros + 1); \
- } \
- if (check_zero) \
- _vec_len (ai) -= n_trailing_zeros; \
- return ai; \
-}
+#define _(name, body, check_zero) \
+ always_inline uword *clib_bitmap_##name (uword *ai, uword *bi) \
+ { \
+ uword i, a, b, bi_len, n_trailing_zeros; \
+ \
+ n_trailing_zeros = 0; \
+ bi_len = vec_len (bi); \
+ if (bi_len > 0) \
+ clib_bitmap_vec_validate (ai, bi_len - 1); \
+ for (i = 0; i < vec_len (ai); i++) \
+ { \
+ a = ai[i]; \
+ b = i < bi_len ? bi[i] : 0; \
+ do \
+ { \
+ body; \
+ } \
+ while (0); \
+ ai[i] = a; \
+ if (check_zero) \
+ n_trailing_zeros = a ? 0 : (n_trailing_zeros + 1); \
+ } \
+ if (check_zero) \
+ vec_dec_len (ai, n_trailing_zeros); \
+ return ai; \
+ }
/* ALU functions: */
/* *INDENT-OFF* */
diff --git a/src/vppinfra/elf.c b/src/vppinfra/elf.c
index 7a74fad4c4f..d11fd7e99a9 100644
--- a/src/vppinfra/elf.c
+++ b/src/vppinfra/elf.c
@@ -1975,7 +1975,7 @@ elf_create_section_with_contents (elf_main_t * em,
if ((p = hash_get_mem (em->section_by_name, section_name)))
{
s = vec_elt_at_index (em->sections, p[0]);
- _vec_len (s->contents) = 0;
+ vec_set_len (s->contents, 0);
c = s->contents;
}
else
diff --git a/src/vppinfra/elog.c b/src/vppinfra/elog.c
index 8ae752eb6af..ddc09a37d72 100644
--- a/src/vppinfra/elog.c
+++ b/src/vppinfra/elog.c
@@ -494,7 +494,7 @@ elog_alloc_internal (elog_main_t * em, u32 n_events, int free_ring)
em->event_ring_size = n_events = max_pow2 (n_events);
vec_validate_aligned (em->event_ring, n_events, CLIB_CACHE_LINE_BYTES);
- _vec_len (em->event_ring) = n_events;
+ vec_set_len (em->event_ring, n_events);
}
__clib_export void
diff --git a/src/vppinfra/fifo.h b/src/vppinfra/fifo.h
index 611fadb95d7..b6a8b8f5c3b 100644
--- a/src/vppinfra/fifo.h
+++ b/src/vppinfra/fifo.h
@@ -91,7 +91,7 @@ clib_fifo_reset (void *v)
if (v)
{
f->head_index = f->tail_index = 0;
- _vec_len (v) = 0;
+ vec_set_len (v, 0);
}
}
diff --git a/src/vppinfra/format.c b/src/vppinfra/format.c
index ccd999e582f..cf17b8a1acb 100644
--- a/src/vppinfra/format.c
+++ b/src/vppinfra/format.c
@@ -114,7 +114,7 @@ justify (u8 * s, format_info_t * fi, uword s_len_orig)
l0 = l1;
if (l1 > l0)
- _vec_len (s) = l0;
+ vec_set_len (s, l0);
else if (l0 > l1)
{
uword n = l0 - l1;
diff --git a/src/vppinfra/hash.c b/src/vppinfra/hash.c
index df740c5f659..7deff4a5bee 100644
--- a/src/vppinfra/hash.c
+++ b/src/vppinfra/hash.c
@@ -342,7 +342,7 @@ unset_indirect (void *v, uword i, hash_pair_t * q)
else
zero_pair (h, q);
if (is_vec)
- _vec_len (pi->pairs) -= 1;
+ vec_dec_len (pi->pairs, 1);
else
indirect_pair_set (pi, indirect_pair_get_log2_bytes (pi), len - 1);
}
diff --git a/src/vppinfra/heap.c b/src/vppinfra/heap.c
index 47b6cf53214..066756b4db9 100644
--- a/src/vppinfra/heap.c
+++ b/src/vppinfra/heap.c
@@ -139,7 +139,7 @@ elt_delete (heap_header_t * h, heap_elt_t * e)
if (e < l)
vec_add1 (h->free_elts, e - h->elts);
else
- _vec_len (h->elts)--;
+ vec_dec_len (h->elts, 1);
}
/*
@@ -200,7 +200,7 @@ elt_new (heap_header_t * h)
if ((l = vec_len (h->free_elts)) > 0)
{
e = elt_at (h, h->free_elts[l - 1]);
- _vec_len (h->free_elts) -= 1;
+ vec_dec_len (h->free_elts, 1);
}
else
vec_add2 (h->elts, e, 1);
@@ -276,7 +276,7 @@ remove_free_block (void *v, uword b, uword i)
h->free_lists[b][i] = t;
set_free_elt (v, elt_at (h, t), i);
}
- _vec_len (h->free_lists[b]) = l - 1;
+ vec_set_len (h->free_lists[b], l - 1);
}
static heap_elt_t *
@@ -425,7 +425,7 @@ _heap_alloc (void *v,
v = _vec_realloc (v, offset + align_size, elt_bytes, sizeof (h[0]),
HEAP_DATA_ALIGN, 0);
else
- _vec_len (v) += align_size;
+ vec_inc_len (v, align_size);
if (offset == 0)
{
diff --git a/src/vppinfra/linux/mem.c b/src/vppinfra/linux/mem.c
index 6c3e036d951..9cf598d3c6f 100644
--- a/src/vppinfra/linux/mem.c
+++ b/src/vppinfra/linux/mem.c
@@ -261,7 +261,7 @@ clib_mem_vm_create_fd (clib_mem_page_sz_t log2_page_size, char *fmt, ...)
/* memfd_create maximum string size is 249 chars without trailing zero */
if (vec_len (s) > 249)
- _vec_len (s) = 249;
+ vec_set_len (s, 249);
vec_add1 (s, 0);
/* memfd_create introduced in kernel 3.17, we don't support older kernels */
diff --git a/src/vppinfra/linux/sysfs.c b/src/vppinfra/linux/sysfs.c
index 758eaa1a86c..a3e122cf1e0 100644
--- a/src/vppinfra/linux/sysfs.c
+++ b/src/vppinfra/linux/sysfs.c
@@ -70,7 +70,7 @@ clib_sysfs_read (char *file_name, char *fmt, ...)
return clib_error_return_unix (0, "read `%s'", file_name);
}
- _vec_len (s) = sz;
+ vec_set_len (s, sz);
unformat_init_vector (&input, s);
va_list va;
@@ -154,7 +154,7 @@ clib_sysfs_set_nr_hugepages (int numa_node, int log2_page_size, int nr)
goto done;
}
- _vec_len (p) -= 1;
+ vec_dec_len (p, 1);
p = format (p, "/hugepages/hugepages-%ukB/nr_hugepages%c", page_size, 0);
clib_sysfs_write ((char *) p, "%d", nr);
@@ -207,7 +207,7 @@ clib_sysfs_get_xxx_hugepages (char *type, int numa_node,
goto done;
}
- _vec_len (p) -= 1;
+ vec_dec_len (p, 1);
p = format (p, "/hugepages/hugepages-%ukB/%s_hugepages%c", page_size,
type, 0);
error = clib_sysfs_read ((char *) p, "%d", val);
diff --git a/src/vppinfra/macros.c b/src/vppinfra/macros.c
index b8a8e1744aa..27a92a8abe2 100644
--- a/src/vppinfra/macros.c
+++ b/src/vppinfra/macros.c
@@ -175,7 +175,7 @@ clib_macro_eval (clib_macro_main_t * mm, i8 * s, i32 complain, u16 level,
/* add results to answer */
vec_append (rv, ts);
/* Remove NULL termination or the results are sad */
- _vec_len (rv) = vec_len (rv) - 1;
+ vec_set_len (rv, vec_len (rv) - 1);
vec_free (ts);
}
else
@@ -183,8 +183,7 @@ clib_macro_eval (clib_macro_main_t * mm, i8 * s, i32 complain, u16 level,
if (complain)
clib_warning ("Undefined Variable Reference: %s\n", varname);
vec_append (rv, format (0, "UNSET "));
- _vec_len (rv) = vec_len (rv) - 1;
-
+ vec_set_len (rv, vec_len (rv) - 1);
}
vec_free (varname);
}
diff --git a/src/vppinfra/mem_dlmalloc.c b/src/vppinfra/mem_dlmalloc.c
index 3829e7c7740..fdde720bc73 100644
--- a/src/vppinfra/mem_dlmalloc.c
+++ b/src/vppinfra/mem_dlmalloc.c
@@ -101,7 +101,7 @@ mheap_get_trace (uword offset, uword size)
if (i > 0)
{
trace_index = tm->trace_free_list[i - 1];
- _vec_len (tm->trace_free_list) = i - 1;
+ vec_set_len (tm->trace_free_list, i - 1);
}
else
{
diff --git a/src/vppinfra/mhash.c b/src/vppinfra/mhash.c
index c556312e64f..f0f1aa470d7 100644
--- a/src/vppinfra/mhash.c
+++ b/src/vppinfra/mhash.c
@@ -295,7 +295,7 @@ mhash_set_mem (mhash_t * h, void *key, uword * new_value, uword * old_value)
{
i = h->key_vector_free_indices[l - 1];
k = vec_elt_at_index (h->key_vector_or_heap, i);
- _vec_len (h->key_vector_free_indices) = l - 1;
+ vec_set_len (h->key_vector_free_indices, l - 1);
}
else
{
@@ -332,10 +332,10 @@ mhash_set_mem (mhash_t * h, void *key, uword * new_value, uword * old_value)
if (key_alloc_from_free_list)
{
h->key_vector_free_indices[l] = i;
- _vec_len (h->key_vector_free_indices) = l + 1;
+ vec_set_len (h->key_vector_free_indices, l + 1);
}
else
- _vec_len (h->key_vector_or_heap) -= h->n_key_bytes;
+ vec_dec_len (h->key_vector_or_heap, h->n_key_bytes);
}
}
diff --git a/src/vppinfra/pool.h b/src/vppinfra/pool.h
index 4db1f7b6bdf..9f9194f59e2 100644
--- a/src/vppinfra/pool.h
+++ b/src/vppinfra/pool.h
@@ -184,7 +184,7 @@ _pool_get (void **pp, void **ep, uword align, int zero, uword elt_sz)
e = p + index * elt_sz;
ph->free_bitmap =
clib_bitmap_andnoti_notrim (ph->free_bitmap, index);
- _vec_len (ph->free_indices) = n_free - 1;
+ vec_set_len (ph->free_indices, n_free - 1);
CLIB_MEM_UNPOISON (e, elt_sz);
goto done;
}
@@ -294,7 +294,7 @@ _pool_put_index (void *p, uword index, uword elt_sz)
if (ph->max_elts)
{
ph->free_indices[_vec_len (ph->free_indices)] = index;
- _vec_len (ph->free_indices) += 1;
+ vec_inc_len (ph->free_indices, 1);
}
else
vec_add1 (ph->free_indices, index);
@@ -321,12 +321,12 @@ _pool_alloc (void **pp, uword n_elts, uword align, void *heap, uword elt_sz)
pp[0] = _vec_realloc_inline (pp[0], len + n_elts, elt_sz,
sizeof (pool_header_t), align, heap);
- _vec_len (pp[0]) = len;
+ _vec_set_len (pp[0], len, elt_sz);
CLIB_MEM_POISON (pp[0] + len * elt_sz, n_elts * elt_sz);
ph = pool_header (pp[0]);
vec_resize (ph->free_indices, n_elts);
- _vec_len (ph->free_indices) -= n_elts;
+ vec_dec_len (ph->free_indices, n_elts);
clib_bitmap_vec_validate (ph->free_bitmap, len + n_elts - 1);
}
diff --git a/src/vppinfra/random_buffer.h b/src/vppinfra/random_buffer.h
index dded53163fc..078e9607caa 100644
--- a/src/vppinfra/random_buffer.h
+++ b/src/vppinfra/random_buffer.h
@@ -100,7 +100,7 @@ clib_random_buffer_get_data (clib_random_buffer_t * b, uword n_bytes)
clib_random_buffer_fill (b, n_words);
i = vec_len (b->buffer) - n_words;
- _vec_len (b->buffer) = i;
+ vec_set_len (b->buffer, i);
if (n_bytes < sizeof (uword))
{
diff --git a/src/vppinfra/serialize.c b/src/vppinfra/serialize.c
index 95eca96758a..d84d7ca06c5 100644
--- a/src/vppinfra/serialize.c
+++ b/src/vppinfra/serialize.c
@@ -714,7 +714,7 @@ serialize_write_not_inline (serialize_main_header_t * m,
n_left_b -= n;
n_left_o -= n;
if (n_left_o == 0)
- _vec_len (s->overflow_buffer) = 0;
+ vec_set_len (s->overflow_buffer, 0);
else
vec_delete (s->overflow_buffer, n, 0);
}
@@ -771,7 +771,7 @@ serialize_read_not_inline (serialize_main_header_t * m,
if (n_left_o == 0 && s->overflow_buffer)
{
s->current_overflow_index = 0;
- _vec_len (s->overflow_buffer) = 0;
+ vec_set_len (s->overflow_buffer, 0);
}
n_left_to_read = n_bytes_to_read;
@@ -923,7 +923,7 @@ serialize_close_vector (serialize_main_t * m)
serialize_close (m); /* frees overflow buffer */
if (s->buffer)
- _vec_len (s->buffer) = s->current_buffer_index;
+ vec_set_len (s->buffer, s->current_buffer_index);
result = s->buffer;
clib_memset (m, 0, sizeof (m[0]));
return result;
@@ -1161,7 +1161,7 @@ clib_file_write (serialize_main_header_t * m, serialize_stream_t * s)
serialize_error (m, clib_error_return_unix (0, "write"));
}
if (n == s->current_buffer_index)
- _vec_len (s->buffer) = 0;
+ vec_set_len (s->buffer, 0);
else
vec_delete (s->buffer, n, 0);
s->current_buffer_index = vec_len (s->buffer);
@@ -1197,7 +1197,7 @@ serialize_open_clib_file_descriptor_helper (serialize_main_t * m, int fd,
if (!is_read)
{
m->stream.n_buffer_bytes = vec_len (m->stream.buffer);
- _vec_len (m->stream.buffer) = 0;
+ vec_set_len (m->stream.buffer, 0);
}
m->header.data_function = is_read ? clib_file_read : clib_file_write;
diff --git a/src/vppinfra/socket.c b/src/vppinfra/socket.c
index a09a390dab3..a3024ae7a8c 100644
--- a/src/vppinfra/socket.c
+++ b/src/vppinfra/socket.c
@@ -230,7 +230,7 @@ default_socket_write (clib_socket_t * s)
else if (written > 0)
{
if (written == tx_len)
- _vec_len (s->tx_buffer) = 0;
+ vec_set_len (s->tx_buffer, 0);
else
vec_delete (s->tx_buffer, written, 0);
}
@@ -278,7 +278,7 @@ default_socket_read (clib_socket_t * sock, int n_bytes)
sock->flags |= CLIB_SOCKET_F_RX_END_OF_FILE;
non_fatal:
- _vec_len (sock->rx_buffer) += n_read - n_bytes;
+ vec_inc_len (sock->rx_buffer, n_read - n_bytes);
return 0;
}
diff --git a/src/vppinfra/sparse_vec.h b/src/vppinfra/sparse_vec.h
index 6cab868a8b2..dc9cb00380a 100644
--- a/src/vppinfra/sparse_vec.h
+++ b/src/vppinfra/sparse_vec.h
@@ -81,7 +81,7 @@ sparse_vec_new (uword elt_bytes, uword sparse_index_bits)
/* heap */ 0);
/* Make space for invalid entry (entry 0). */
- _vec_len (v) = 1;
+ _vec_find (v)->len = 1;
h = sparse_vec_header (v);
diff --git a/src/vppinfra/test_bihash_template.c b/src/vppinfra/test_bihash_template.c
index ffed5c73287..155b8bd408d 100644
--- a/src/vppinfra/test_bihash_template.c
+++ b/src/vppinfra/test_bihash_template.c
@@ -522,8 +522,7 @@ test_bihash_main (test_main_t * tm)
/* Preallocate hash table, key vector */
tm->key_hash = hash_create (tm->nitems, sizeof (uword));
vec_validate (tm->keys, tm->nitems - 1);
- _vec_len (tm->keys) = 0;
-
+ vec_set_len (tm->keys, 0);
switch (which)
{
diff --git a/src/vppinfra/test_fpool.c b/src/vppinfra/test_fpool.c
index e2d67f16907..02d9d219717 100644
--- a/src/vppinfra/test_fpool.c
+++ b/src/vppinfra/test_fpool.c
@@ -30,7 +30,7 @@ main (int argc, char *argv[])
clib_mem_init (0, 3ULL << 30);
vec_validate (indices, NELTS - 1);
- _vec_len (indices) = 0;
+ vec_set_len (indices, 0);
pool_init_fixed (tp, NELTS);
diff --git a/src/vppinfra/test_socket.c b/src/vppinfra/test_socket.c
index ea0ae658943..3a0e6b29ce6 100644
--- a/src/vppinfra/test_socket.c
+++ b/src/vppinfra/test_socket.c
@@ -99,7 +99,7 @@ test_socket_main (unformat_input_t * input)
break;
if_verbose ("%v", s->rx_buffer);
- _vec_len (s->rx_buffer) = 0;
+ vec_set_len (s->rx_buffer, 0);
}
error = clib_socket_close (s);
diff --git a/src/vppinfra/timing_wheel.c b/src/vppinfra/timing_wheel.c
index 2c46d72a2fe..edd878239cf 100644
--- a/src/vppinfra/timing_wheel.c
+++ b/src/vppinfra/timing_wheel.c
@@ -185,7 +185,7 @@ free_elt_vector (timing_wheel_t * w, timing_wheel_elt_t * ev)
/* Poison free elements so we never use them by mistake. */
if (CLIB_DEBUG > 0)
clib_memset (ev, ~0, vec_len (ev) * sizeof (ev[0]));
- _vec_len (ev) = 0;
+ vec_set_len (ev, 0);
vec_add1 (w->free_elt_vectors, ev);
}
@@ -459,7 +459,7 @@ expire_bin (timing_wheel_t * w,
/* Adjust for deleted elts. */
if (j < e_len)
- _vec_len (expired_user_data) -= e_len - j;
+ vec_dec_len (expired_user_data, e_len - j);
free_elt_vector (w, e);
@@ -613,7 +613,7 @@ timing_wheel_advance (timing_wheel_t * w, u64 advance_cpu_time,
if (PREDICT_FALSE (current_ti != advance_ti))
{
if (w->unexpired_elts_pending_insert)
- _vec_len (w->unexpired_elts_pending_insert) = 0;
+ vec_set_len (w->unexpired_elts_pending_insert, 0);
level_index = 0;
while (current_ti != advance_ti)
@@ -684,7 +684,7 @@ timing_wheel_advance (timing_wheel_t * w, u64 advance_cpu_time,
{
timing_wheel_elt_t *e;
vec_foreach (e, w->unexpired_elts_pending_insert) insert_elt (w, e);
- _vec_len (w->unexpired_elts_pending_insert) = 0;
+ vec_set_len (w->unexpired_elts_pending_insert, 0);
}
/* Don't advance until necessary. */
diff --git a/src/vppinfra/tw_timer_template.c b/src/vppinfra/tw_timer_template.c
index 97c70b223ce..6e8a58dbfaf 100644
--- a/src/vppinfra/tw_timer_template.c
+++ b/src/vppinfra/tw_timer_template.c
@@ -424,7 +424,7 @@ TW (tw_timer_wheel_init) (TWT (tw_timer_wheel) * tw,
tw->ticks_per_second = 1.0 / timer_interval_in_seconds;
vec_validate (tw->expired_timer_handles, 0);
- _vec_len (tw->expired_timer_handles) = 0;
+ vec_set_len (tw->expired_timer_handles, 0);
for (ring = 0; ring < TW_TIMER_WHEELS; ring++)
{
@@ -536,7 +536,7 @@ static inline
if (callback_vector_arg == 0)
{
- _vec_len (tw->expired_timer_handles) = 0;
+ vec_set_len (tw->expired_timer_handles, 0);
callback_vector = tw->expired_timer_handles;
}
else
diff --git a/src/vppinfra/unformat.c b/src/vppinfra/unformat.c
index 3904b450f48..e8e5c28ea8c 100644
--- a/src/vppinfra/unformat.c
+++ b/src/vppinfra/unformat.c
@@ -952,7 +952,7 @@ parse_fail:
if (!input_matches_format)
input->index = input->buffer_marks[l - 1];
- _vec_len (input->buffer_marks) = l - 1;
+ vec_set_len (input->buffer_marks, l - 1);
}
return input_matches_format;
@@ -987,7 +987,7 @@ unformat_user (unformat_input_t * input, unformat_function_t * func, ...)
if (!result && input->index != UNFORMAT_END_OF_INPUT)
input->index = input->buffer_marks[l];
- _vec_len (input->buffer_marks) = l;
+ vec_set_len (input->buffer_marks, l);
return result;
}
@@ -1037,7 +1037,7 @@ clib_file_fill_buffer (unformat_input_t * input)
vec_resize (input->buffer, 4096);
n = read (fd, input->buffer + l, 4096);
if (n > 0)
- _vec_len (input->buffer) = l + n;
+ vec_set_len (input->buffer, l + n);
if (n <= 0)
return UNFORMAT_END_OF_INPUT;
diff --git a/src/vppinfra/unix-misc.c b/src/vppinfra/unix-misc.c
index 5559a2392fe..e73d01a15d6 100644
--- a/src/vppinfra/unix-misc.c
+++ b/src/vppinfra/unix-misc.c
@@ -158,7 +158,7 @@ unix_proc_file_contents (char *file, u8 ** result)
if (bytes == 0)
{
- _vec_len (rv) = pos;
+ vec_set_len (rv, pos);
break;
}
pos += bytes;
diff --git a/src/vppinfra/vec.c b/src/vppinfra/vec.c
index 805fdc02b7e..8bd0ec01f42 100644
--- a/src/vppinfra/vec.c
+++ b/src/vppinfra/vec.c
@@ -83,7 +83,7 @@ _vec_realloc (void *v, uword n_elts, uword elt_sz, uword hdr_sz, uword align,
}
CLIB_MEM_POISON (p + new_data_size, alloc_size - new_data_size);
- _vec_len (v) = n_elts;
+ _vec_find (v)->len = n_elts;
return v;
}
diff --git a/src/vppinfra/vec_bootstrap.h b/src/vppinfra/vec_bootstrap.h
index d6451f3d172..0054802e8c1 100644
--- a/src/vppinfra/vec_bootstrap.h
+++ b/src/vppinfra/vec_bootstrap.h
@@ -116,21 +116,21 @@ vec_header_end (void *v)
return v + vec_get_header_size (v);
}
-/** \brief Number of elements in vector (lvalue-capable)
-
- _vec_len (v) does not check for null, but can be used as an lvalue
- (e.g. _vec_len (v) = 99).
-*/
-
-#define _vec_len(v) (_vec_find(v)->len)
-
/** \brief Number of elements in vector (rvalue-only, NULL tolerant)
vec_len (v) checks for NULL, but cannot be used as an lvalue.
If in doubt, use vec_len...
*/
+static_always_inline u32
+__vec_len (void *v)
+{
+ return _vec_find (v)->len;
+}
+
+#define _vec_len(v) __vec_len ((void *) (v))
#define vec_len(v) ((v) ? _vec_len(v) : 0)
+
u32 vec_len_not_inline (void *v);
/** \brief Number of data bytes in vector. */
@@ -180,10 +180,12 @@ _vec_set_len (void *v, uword len, uword elt_sz)
else if (len > old_len)
CLIB_MEM_POISON (v + len * elt_sz, (old_len - len) * elt_sz);
- _vec_len (v) = len;
+ _vec_find (v)->len = len;
}
#define vec_set_len(v, l) _vec_set_len ((void *) v, l, _vec_elt_sz (v))
+#define vec_inc_len(v, l) vec_set_len (v, _vec_len (v) + (l))
+#define vec_dec_len(v, l) vec_set_len (v, _vec_len (v) - (l))
/** \brief Reset vector length to zero
NULL-pointer tolerant