Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GCC 14 introduces a new -Walloc-size included in -Wextra which gives: ``` src/install/hashmap.c: In function ‘hashmap_new’: src/install/hashmap.c:83:11: warning: allocation of insufficient size ‘1’ for type ‘Hashmap’ with size ‘40’ [-Walloc-size] 83 | h = malloc0(size); | ^ ``` malloc0 is a macro deifned by Dracut (and systemd, see below): ``` malloc0(n) (calloc((n), 1)) ``` 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. This was fixed upstream in systemd in commit f80bb1f7eaf31476a44c2093d3ee02aba817a0b0 [0]. [0] systemd/systemd@f80bb1f Signed-off-by: Sam James <[email protected]>
- Loading branch information