tytso / e2fsprogs

Ext2/3/4 file system utilities
http://ext4.wiki.kernel.org
373 stars 219 forks source link

ext2fs: Fix -Walloc-size #166

Closed thesamesam closed 4 months ago

thesamesam commented 10 months ago

GCC 14 introduces a new -Walloc-size included in -Wextra which gives:

lib/ext2fs/hashmap.c:37:36: warning: allocation of insufficient size ‘1’ for type ‘struct ext2fs_hashmap’ with size ‘20’ [-Walloc-size]

The calloc prototype is:

void *calloc(size_t nmemb, size_t size);

So, just swap the number of members and size arguments to match the prototype, as we're initialising 1 struct of size sizeof(...). GCC then sees we're not doing anything wrong.

thesamesam commented 10 months ago

Sent to ML at https://lore.kernel.org/linux-ext4/20231107233122.2013191-1-sam@gentoo.org/T/#u.