evdev: use autofree for the sysname

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1193>
This commit is contained in:
Peter Hutterer 2025-04-24 10:07:35 +10:00
parent 43c4224e56
commit b481170918

View file

@ -2385,7 +2385,7 @@ evdev_device_create(struct libinput_seat *seat,
int fd = -1;
int unhandled_device = 0;
const char *devnode = udev_device_get_devnode(udev_device);
char *sysname = str_sanitize(udev_device_get_sysname(udev_device));
_autofree_ char *sysname = str_sanitize(udev_device_get_sysname(udev_device));
if (!devnode) {
log_info(libinput, "%s: no device node associated\n", sysname);
@ -2415,8 +2415,7 @@ evdev_device_create(struct libinput_seat *seat,
goto err;
device = zalloc(sizeof *device);
device->sysname = sysname;
sysname = NULL;
device->sysname = steal(&sysname);
libinput_device_init(&device->base, seat);
libinput_seat_ref(seat);
@ -2490,8 +2489,6 @@ err:
}
}
free(sysname);
return unhandled_device ? EVDEV_UNHANDLED_DEVICE : NULL;
}