Skip to content

Commit

Permalink
state: fix -Walloc-size
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
thesamesam authored and whot committed Nov 6, 2023
1 parent 3aaa4e2 commit fed9637
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/state.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit fed9637

Please sign in to comment.