pad: add some extra asserts to shut up clang-tidy

For some reason clang-tidy believes that in the second iteration group
is set to NULL and causes a NULL-pointer dereference.

../src/evdev-tablet-pad.c:305:2: error: Access to field 'next' results in a dereference of a null pointer [clang-analyzer-core.NullDereference,-warnings-as-errors]
  305 |         list_for_each(group, &pad->modes.mode_group_list, link) {
      |         ^
../src/util-list.h:265:13: note: expanded from macro 'list_for_each'
  265 |              pos = list_first_entry_by_type(&pos->member, __typeof__(*pos), member))
      |                    ^
../src/util-list.h:202:2: note: expanded from macro 'list_first_entry_by_type'
  202 |         container_of((head)->next, container_type, member)
      |         ^

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1298>
This commit is contained in:
Peter Hutterer 2025-08-11 15:10:35 +10:00
parent 48a26f91c3
commit 17617a75c4

View file

@ -303,6 +303,7 @@ pad_dial_get_mode_group(struct pad_dispatch *pad, unsigned int dial)
struct libinput_tablet_pad_mode_group *group;
list_for_each(group, &pad->modes.mode_group_list, link) {
assert(group != NULL); /* for clang-tidy */
if (libinput_tablet_pad_mode_group_has_dial(group, dial))
return group;
}
@ -321,6 +322,7 @@ pad_ring_get_mode_group(struct pad_dispatch *pad, unsigned int ring)
struct libinput_tablet_pad_mode_group *group;
list_for_each(group, &pad->modes.mode_group_list, link) {
assert(group != NULL); /* for clang-tidy */
if (libinput_tablet_pad_mode_group_has_ring(group, ring))
return group;
}
@ -339,6 +341,7 @@ pad_strip_get_mode_group(struct pad_dispatch *pad, unsigned int strip)
struct libinput_tablet_pad_mode_group *group;
list_for_each(group, &pad->modes.mode_group_list, link) {
assert(group != NULL); /* for clang-tidy */
if (libinput_tablet_pad_mode_group_has_strip(group, strip))
return group;
}