Fix transposed calloc arguments warning

GCC 14 added a new warning (included in `-Wextra`) when calling
`calloc` with `sizeof` in the first argument and the number of
elements in the second argument. See:
https://gcc.gnu.org/onlinedocs/gcc-14.1.0/gcc/Warning-Options.html#index-Wcalloc-transposed-args

Note that this is just a coding style warning.
This commit is contained in:
Joan Bruguera Micó 2024-07-07 12:06:06 +00:00 committed by Jari Vetoniemi
parent fa84d4b2d6
commit 6f63f3f197
2 changed files with 2 additions and 2 deletions

View File

@ -64,7 +64,7 @@ list_set_items(struct list *list, const void *items, uint32_t nmemb, list_free_f
}
void *new_items;
if (!(new_items = calloc(sizeof(void*), nmemb)))
if (!(new_items = calloc(nmemb, sizeof(void*))))
return false;
memcpy(new_items, items, sizeof(void*) * nmemb);

View File

@ -767,7 +767,7 @@ bm_menu_set_selected_items(struct bm_menu *menu, struct bm_item **items, uint32_
assert(menu);
struct bm_item **new_items;
if (!(new_items = calloc(sizeof(struct bm_item*), nmemb)))
if (!(new_items = calloc(nmemb, sizeof(struct bm_item*))))
return 0;
memcpy(new_items, items, sizeof(struct bm_item*) * nmemb);