]> git.ipfire.org Git - thirdparty/kmod.git/commit
tools: depmod: fix -Walloc-size
authorSam James <sam@gentoo.org>
Sun, 5 Nov 2023 22:02:25 +0000 (22:02 +0000)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Mon, 6 Nov 2023 00:22:05 +0000 (18:22 -0600)
commit3af2f475b0b729f20279f2ce488cc9f727f0b763
tree60bfb801fb6449684096b7b267b5b1edf3920a2c
parentecef7c131618bbd9c559924ecae55764089db0dd
tools: depmod: fix -Walloc-size

GCC 14 introduces a new -Walloc-size included in -Wextra which gives:
```
tools/depmod.c:192:14: warning: allocation of insufficient size ‘1’ for type ‘struct index_node’ with size ‘1048’ [-Walloc-size]
tools/depmod.c:255:11: warning: allocation of insufficient size ‘1’ for type ‘struct index_value’ with size ‘16’ [-Walloc-size]
tools/depmod.c:286:35: warning: allocation of insufficient size ‘1’ for type ‘struct index_node’ with size ‘1048’ [-Walloc-size]
tools/depmod.c:315:44: warning: allocation of insufficient size ‘1’ for type ‘struct index_node’ with size ‘1048’ [-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.

Signed-off-by: Sam James <sam@gentoo.org>
tools/depmod.c