Commit d724dc06 authored by Peter Hutterer's avatar Peter Hutterer

Replace strneq() with strstartswith() for variable prefixes

Leaving in-place all those where we know the length of the prefix, but
replacing all those where we were calling strlen on the prefix.
Signed-off-by: Peter Hutterer's avatarPeter Hutterer <peter.hutterer@who-t.net>
parent bd1fcb9c
......@@ -978,15 +978,7 @@ out:
static int
is_data_file(const struct dirent *dir) {
const char *suffix = ".quirks";
const int slen = strlen(suffix);
int offset;
offset = strlen(dir->d_name) - slen;
if (offset <= 0)
return 0;
return strneq(&dir->d_name[offset], suffix, slen);
return strendswith(dir->d_name, ".quirks");
}
static inline bool
......
......@@ -309,7 +309,7 @@ parse_evcode_string(const char *s, int *type_out, int *code_out)
bool found = false;
ARRAY_FOR_EACH(map, m) {
if (!strneq(s, m->str, strlen(m->str)))
if (!strstartswith(s, m->str))
continue;
type = m->type;
......
......@@ -396,7 +396,7 @@ get_suite(const char *name)
bool found = false;
ARRAY_FOR_EACH(allowed_suites, allowed) {
if (strneq(name, *allowed, strlen(*allowed))) {
if (strstartswith(name, *allowed)) {
found = true;
break;
}
......@@ -1412,7 +1412,7 @@ litest_install_source_quirks(struct list *created_files_list,
char dest[PATH_MAX];
char src[PATH_MAX];
litest_assert(strneq(*q, quirksdir, strlen(quirksdir)));
litest_assert(strstartswith(*q, quirksdir));
filename = &(*q)[strlen(quirksdir)];
snprintf(src, sizeof(src), "%s/%s",
......@@ -1795,9 +1795,7 @@ udev_wait_for_device_event(struct udev_monitor *udev_monitor,
}
udev_syspath = udev_device_get_syspath(udev_device);
if (udev_syspath && strneq(udev_syspath,
syspath,
strlen(syspath)))
if (udev_syspath && strstartswith(udev_syspath, syspath))
break;
udev_device_unref(udev_device);
......
......@@ -1733,7 +1733,7 @@ print_hid_report_descriptor(struct record_context *ctx,
report_descriptor is available in sysfs and two devices up from
our device. 2 digits for the event number should be enough.
This approach won't work for /dev/input/by-id devices. */
if (!strneq(dev->devnode, prefix, strlen(prefix)) ||
if (!strstartswith(dev->devnode, prefix) ||
strlen(dev->devnode) > strlen(prefix) + 2)
return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment