kdave / btrfs-progs

Development of userspace BTRFS tools
GNU General Public License v2.0
527 stars 239 forks source link

Fix -Walloc-size #707

Closed thesamesam closed 7 months ago

thesamesam commented 8 months ago

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

common/utils.c:983:15: warning: allocation of insufficient size ‘1’ for type ‘struct config_param’ with size ‘32’ [-Walloc-size]
cmds/qgroup.c:1644:13: warning: allocation of insufficient size ‘1’ for type ‘struct btrfs_qgroup_inherit’ with size ‘72’ [-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(struct ...). GCC then sees we're not doing anything wrong.

kdave commented 7 months ago

Merged to devel, thanks.

thesamesam commented 7 months ago

Thank you!