replace strncmp with strneq for safety-check

Signed-off-by: weizhixiang <weizhixiang@uniontech.com>
This commit is contained in:
weizhixiang 2021-03-07 14:39:56 +08:00 committed by Peter Hutterer
parent 5e69c5f9ae
commit c00c5cb691
4 changed files with 5 additions and 5 deletions

View file

@ -184,7 +184,7 @@ udev_input_add_devices(struct udev_input *input, struct udev *udev)
continue;
sysname = udev_device_get_sysname(device);
if (strncmp("event", sysname, 5) != 0) {
if (!strneq("event", sysname, 5)) {
udev_device_unref(device);
continue;
}
@ -228,7 +228,7 @@ evdev_udev_handler(void *data)
if (!action)
goto out;
if (strncmp("event", udev_device_get_sysname(udev_device), 5) != 0)
if (!strneq("event", udev_device_get_sysname(udev_device), 5))
goto out;
if (streq(action, "add"))

View file

@ -494,7 +494,7 @@ START_TEST(path_device_sysname)
ck_assert_notnull(sysname);
ck_assert_int_gt(strlen(sysname), 1);
ck_assert(strchr(sysname, '/') == NULL);
ck_assert_int_eq(strncmp(sysname, "event", 5), 0);
ck_assert(strneq(sysname, "event", 5));
libinput_event_destroy(ev);
}

View file

@ -489,7 +489,7 @@ START_TEST(udev_device_sysname)
ck_assert_notnull(sysname);
ck_assert_int_gt(strlen(sysname), 1);
ck_assert(strchr(sysname, '/') == NULL);
ck_assert_int_eq(strncmp(sysname, "event", 5), 0);
ck_assert(strneq(sysname, "event", 5));
libinput_event_destroy(ev);
}

View file

@ -485,7 +485,7 @@ find_device(const char *udev_tag)
continue;
sysname = udev_device_get_sysname(device);
if (strncmp("event", sysname, 5) != 0) {
if (!strneq("event", sysname, 5)) {
udev_device_unref(device);
continue;
}