mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-31 00:40:07 +01:00
gestures: rewrite the gesture state transition debugging code
Fixes a spurious compiler error in release builds:
cc -Ilibinput-plugin-test-suite.p -I. -I.. -I../src -I../include -I/usr/include/libevdev-1.0 -I/usr/include/libwacom-1.0 -I/usr/include/gudev-1.0 -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/sysprof-6 -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu99 -O3 -Wno-unused-parameter -Wmissing-prototypes -Wstrict-prototypes -Wundef -Wlogical-op -Wpointer-arith -Wuninitialized -Winit-self -Wstrict-prototypes -Wimplicit-fallthrough -Wredundant-decls -Wincompatible-pointer-types -Wformat=2 -Wno-missing-field-initializers -Wmissing-declarations -fvisibility=hidden -Werror -pthread -MD -MQ libinput-plugin-test-suite.p/src_evdev-mt-touchpad-gestures.c.o -MF libinput-plugin-test-suite.p/src_evdev-mt-touchpad-gestures.c.o.d -o libinput-plugin-test-suite.p/src_evdev-mt-touchpad-gestures.c.o -c ../src/evdev-mt-touchpad-gestures.c
../src/evdev-mt-touchpad-gestures.c: In function ‘tp_gesture_handle_state’:
../src/evdev-mt-touchpad-gestures.c:1814:69: error: ‘%s’ directive argument is null [-Werror=format-truncation=]
1814 | int n = snprintf(&buf[slen], remaining, " → %s", gesture_state_to_str(*s));
| ^~
Apparently because gesture_state_to_str() may return null (this cannot
happen in our code) it fails with an error here. So let's rewrite it to
use our strv helpers.
Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1201>
This commit is contained in:
parent
97a7ab7f9d
commit
0e67cdc4ed
1 changed files with 7 additions and 10 deletions
|
|
@ -1807,20 +1807,17 @@ tp_gesture_handle_state(struct tp_dispatch *tp, uint64_t time,
|
|||
#undef REMEMBER_TRANSITION
|
||||
|
||||
if (oldstate != tp->gesture.state) {
|
||||
char buf[1024] = {0};
|
||||
size_t remaining = sizeof(buf);
|
||||
size_t slen = 0;
|
||||
_autostrvfree_ char **states = NULL;
|
||||
states = strv_append_strdup(states, gesture_state_to_str(oldstate));
|
||||
for (enum tp_gesture_state *s = transitions + 1; s < transition_state; s++) {
|
||||
int n = snprintf(&buf[slen], remaining, " → %s", gesture_state_to_str(*s));
|
||||
slen += n;
|
||||
remaining -= n;
|
||||
states = strv_append_strdup(states, gesture_state_to_str(*s));
|
||||
}
|
||||
states = strv_append_strdup(states, gesture_state_to_str(tp->gesture.state));
|
||||
_autofree_ char *str = strv_join(states, " → ");
|
||||
evdev_log_debug(tp->device,
|
||||
"gesture: [%dfg] state %s%s → %s\n",
|
||||
"gesture: [%dfg] state %s\n",
|
||||
tp->gesture.finger_count,
|
||||
gesture_state_to_str(oldstate),
|
||||
buf,
|
||||
gesture_state_to_str(tp->gesture.state));
|
||||
str);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue