On Wed, May 07, 2025 at 09:05:52PM +0200, Martin Wilck wrote: > We always add or remove a single element in vector_add_slot() and > vector_remove_slot(). Use of the VECTOR_DEFAULT_SIZE macro suggests that > its value can be changed, but this is not the case. > > Remove the macro. > > Signed-off-by: Martin Wilck <mwi...@suse.com>
Reviewed-by: Benjamin Marzinski <bmarz...@redhat.com> > --- > libmpathutil/vector.c | 4 ++-- > libmpathutil/vector.h | 3 +-- > 2 files changed, 3 insertions(+), 4 deletions(-) > > diff --git a/libmpathutil/vector.c b/libmpathutil/vector.c > index 6ad5dd5..34a8512 100644 > --- a/libmpathutil/vector.c > +++ b/libmpathutil/vector.c > @@ -45,7 +45,7 @@ vector_alloc_slot(vector v) > if (!v) > return false; > > - new_allocated = v->allocated + VECTOR_DEFAULT_SIZE; > + new_allocated = v->allocated + 1; > new_slot = realloc(v->slot, sizeof (void *) * new_allocated); > if (!new_slot) > return false; > @@ -115,7 +115,7 @@ vector_del_slot(vector v, int slot) > for (i = slot + 1; i < VECTOR_SIZE(v); i++) > v->slot[i - 1] = v->slot[i]; > > - v->allocated -= VECTOR_DEFAULT_SIZE; > + v->allocated--; > > if (v->allocated <= 0) { > free(v->slot); > diff --git a/libmpathutil/vector.h b/libmpathutil/vector.h > index 171ab6a..0a5b32e 100644 > --- a/libmpathutil/vector.h > +++ b/libmpathutil/vector.h > @@ -32,8 +32,7 @@ struct vector_s { > }; > typedef struct vector_s *vector; > > -#define VECTOR_DEFAULT_SIZE 1 > -#define VECTOR_SIZE(V) ((V) ? ((V)->allocated) / VECTOR_DEFAULT_SIZE : 0) > +#define VECTOR_SIZE(V) ((V) ? (V)->allocated : 0) > #define VECTOR_SLOT(V,E) (((V) && (E) < VECTOR_SIZE(V) && (E) >= 0) ? > (V)->slot[(E)] : NULL) > #define VECTOR_LAST_SLOT(V) (((V) && VECTOR_SIZE(V) > 0) ? > (V)->slot[(VECTOR_SIZE(V) - 1)] : NULL) > > -- > 2.49.0