diff options
author | Damjan Marion <damarion@cisco.com> | 2022-04-04 22:40:45 +0200 |
---|---|---|
committer | Damjan Marion <dmarion@me.com> | 2022-04-04 23:17:13 +0000 |
commit | 8bea589cfe0fca1a6f560e16ca66a4cf199041a2 (patch) | |
tree | cf2767f8f5f31344468b65e14baa3f1a4c85fb91 /src/vppinfra/pool.h | |
parent | a2b358b1faf6e762e1d29a931d83c7735ac9a77d (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/vppinfra/pool.h')
-rw-r--r-- | src/vppinfra/pool.h | 8 |
1 files changed, 4 insertions, 4 deletions
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); } |