vppinfra: type prove vec_new and vec_resize
Some vector functions (e.g. vec_new) pass the vector pointer through
vec_resize. This turn the pointer from a real type into a void pointer.
Explicitly cast the pointer back to its original type to catch type
mismatches.
Type: improvement
@@ -117,7 +117,11 @@ void *vec_resize_allocate_memory (void *v,
*/
#define _vec_resize_numa(V,L,DB,HB,A,S) \
- _vec_resize_inline(V,L,DB,HB,clib_max((__alignof__((V)[0])),(A)),(S))
+({ \
+ __typeof__ ((V)) _V; \
+ _V = _vec_resize_inline(V,L,DB,HB,clib_max((__alignof__((V)[0])),(A)),(S)); \
+ _V; \
+})
#define _vec_resize(V,L,DB,HB,A) \
_vec_resize_numa(V,L,DB,HB,A,VEC_NUMA_UNSPECIFIED)
@@ -333,7 +337,7 @@ do { \
#define vec_new_ha(T,N,H,A) \
({ \
word _v(n) = (N); \
- _vec_resize ((T *) 0, _v(n), _v(n) * sizeof (T), (H), (A)); \
+ (T *)_vec_resize ((T *) 0, _v(n), _v(n) * sizeof (T), (H), (A)); \
})
/** \brief Create new vector of given type and length
