backend: fix build against upcoming `gcc-14` (`-Werror=calloc-transposed-args`)

`gcc-14` added a new `-Wcalloc-transposed-args` warning recently. It
detected minor infelicity in `calloc()` API usage in `wlroots`:

    ../backend/libinput/tablet_pad.c: In function 'add_pad_group_from_libinput':
    ../backend/libinput/tablet_pad.c:36:38: error: 'calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Werror=calloc-transposed-args]
       36 |         group->rings = calloc(sizeof(unsigned int), group->ring_count);
          |                                      ^~~~~~~~
    ../backend/libinput/tablet_pad.c:36:38: note: earlier argument should specify number of elements, later size of each element
This commit is contained in:
Sergei Trofimovich 2023-12-21 21:06:20 +00:00
parent 11e3c376e7
commit f3e1f7b2a7
1 changed files with 3 additions and 3 deletions

View File

@ -33,7 +33,7 @@ static void add_pad_group_from_libinput(struct wlr_tablet_pad *pad,
++group->ring_count; ++group->ring_count;
} }
} }
group->rings = calloc(sizeof(unsigned int), group->ring_count); group->rings = calloc(group->ring_count, sizeof(unsigned int));
if (group->rings == NULL) { if (group->rings == NULL) {
goto group_fail; goto group_fail;
} }
@ -50,7 +50,7 @@ static void add_pad_group_from_libinput(struct wlr_tablet_pad *pad,
++group->strip_count; ++group->strip_count;
} }
} }
group->strips = calloc(sizeof(unsigned int), group->strip_count); group->strips = calloc(group->strip_count, sizeof(unsigned int));
if (group->strips == NULL) { if (group->strips == NULL) {
goto group_fail; goto group_fail;
} }
@ -66,7 +66,7 @@ static void add_pad_group_from_libinput(struct wlr_tablet_pad *pad,
++group->button_count; ++group->button_count;
} }
} }
group->buttons = calloc(sizeof(unsigned int), group->button_count); group->buttons = calloc(group->button_count, sizeof(unsigned int));
if (group->buttons == NULL) { if (group->buttons == NULL) {
goto group_fail; goto group_fail;
} }