diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2020-02-21 10:28:56 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2020-02-24 01:53:21 +0000 |
commit | 20cf83789df6563828f16fc938ccf05437d366c2 (patch) | |
tree | 2368c5e5006887b6895a935d48000bb8e3ccfdb9 /tools/libinput-debug-events.c | |
parent | 2bfbdfaf6be5ccebfca38a626d5f36430c98ba13 (diff) | |
download | libinput-20cf83789df6563828f16fc938ccf05437d366c2.tar.gz |
tools: constify the optarg handling of seats
This shuts up scan-build complaining about memory leaks in libinput
debug-events (needs the right combination of --device option and eventually
triggering usage()) and saves us a bunch of unnecessary allocations.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'tools/libinput-debug-events.c')
-rw-r--r-- | tools/libinput-debug-events.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/tools/libinput-debug-events.c b/tools/libinput-debug-events.c index 013fe39d..efdc93f5 100644 --- a/tools/libinput-debug-events.c +++ b/tools/libinput-debug-events.c @@ -967,7 +967,7 @@ main(int argc, char **argv) { struct libinput *li; enum tools_backend backend = BACKEND_NONE; - char *seat_or_devices[60] = {NULL}; + const char *seat_or_devices[60] = {NULL}; size_t ndevices = 0; bool grab = false; bool verbose = false; @@ -1024,7 +1024,7 @@ main(int argc, char **argv) } backend = BACKEND_DEVICE; - seat_or_devices[ndevices++] = safe_strdup(optarg); + seat_or_devices[ndevices++] = optarg; break; case OPT_UDEV: if (backend == BACKEND_DEVICE || @@ -1034,7 +1034,7 @@ main(int argc, char **argv) } backend = BACKEND_UDEV; - seat_or_devices[0] = safe_strdup(optarg); + seat_or_devices[0] = optarg; ndevices = 1; break; case OPT_GRAB: @@ -1064,12 +1064,11 @@ main(int argc, char **argv) usage(); return EXIT_INVALID_USAGE; } - seat_or_devices[ndevices++] = safe_strdup(argv[optind]); + seat_or_devices[ndevices++] = argv[optind]; } while(++optind < argc); } else if (backend == BACKEND_NONE) { backend = BACKEND_UDEV; - seat_or_devices[0] = safe_strdup("seat0"); - ndevices = 1; + seat_or_devices[0] = "seat0"; } memset(&act, 0, sizeof(act)); @@ -1089,9 +1088,6 @@ main(int argc, char **argv) if (!li) return EXIT_FAILURE; - while (ndevices-- > 0) - free(seat_or_devices[ndevices]); - mainloop(li); libinput_unref(li); |