From fed96378a1deef990a190b62ab07329ae546447b Mon Sep 17 00:00:00 2001 From: Sam James Date: Sun, 5 Nov 2023 22:06:40 +0000 Subject: [PATCH] state: fix -Walloc-size MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GCC 14 introduces a new -Walloc-size included in -Wextra which gives: ``` src/state.c:589:9: warning: allocation of insufficient size ‘1’ for type ‘struct xkb_state’ with size ‘128’ [-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 xkb_state)`. GCC then sees we're not doing anything wrong. Signed-off-by: Sam James --- src/state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/state.c b/src/state.c index b269e6d..d449697 100644 --- a/src/state.c +++ b/src/state.c @@ -586,7 +586,7 @@ xkb_state_new(struct xkb_keymap *keymap) { struct xkb_state *ret; - ret = calloc(sizeof(*ret), 1); + ret = calloc(1, sizeof(*ret)); if (!ret) return NULL;