if (!udev_device_new)
goto out;
- rc = strcmp(udev_device_get_syspath(udev_device_new),
+ rc = !streq(udev_device_get_syspath(udev_device_new),
udev_device_get_syspath(udev_device));
out:
if (udev_device_new)
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max(a, b) (((a) > (b)) ? (a) : (b))
+#define streq(s1, s2) (strcmp((s1), (s2)) == 0)
+#define strneq(s1, s2, n) (strncmp((s1), (s2), (n)) == 0)
#define LIBINPUT_EXPORT __attribute__ ((visibility("default")))
struct path_seat *seat;
list_for_each(seat, &input->base.seat_list, base.link) {
- if (strcmp(seat->base.physical_name, seat_name_physical) == 0 &&
- strcmp(seat->base.logical_name, seat_name_logical) == 0)
+ if (streq(seat->base.physical_name, seat_name_physical) &&
+ streq(seat->base.logical_name, seat_name_logical))
return seat;
}
if (!device_seat)
device_seat = default_seat;
- if (strcmp(device_seat, input->seat_id))
+ if (!streq(device_seat, input->seat_id))
return 0;
devnode = udev_device_get_devnode(udev_device);
list_for_each(seat, &input->base.seat_list, base.link) {
list_for_each_safe(device, next,
&seat->base.devices_list, base.link) {
- if (!strcmp(syspath,
- udev_device_get_syspath(device->udev_device))) {
+ if (streq(syspath,
+ udev_device_get_syspath(device->udev_device))) {
log_info(&input->base,
"input device %s, %s removed\n",
device->devname,
if (strncmp("event", udev_device_get_sysname(udev_device), 5) != 0)
goto out;
- if (!strcmp(action, "add"))
+ if (streq(action, "add"))
device_added(udev_device, input, NULL);
- else if (!strcmp(action, "remove"))
+ else if (streq(action, "remove"))
device_removed(udev_device, input);
out:
struct udev_seat *seat;
list_for_each(seat, &input->base.seat_list, base.link) {
- if (strcmp(seat->base.logical_name, seat_name) == 0)
+ if (streq(seat->base.logical_name, seat_name))
return seat;
}
const char *test_name = dev->shortname;
list_for_each(t, &suite->tests, node) {
- if (strcmp(t->name, test_name) != 0)
+ if (!streq(t->name, test_name))
continue;
if (range)
return;
list_for_each(t, &suite->tests, node) {
- if (strcmp(t->name, test_name) != 0)
+ if (!streq(t->name, test_name))
continue;
if (range)
list_init(&all_tests);
list_for_each(s, &all_tests, node) {
- if (strcmp(s->name, name) == 0)
+ if (streq(s->name, name))
return s;
}
#include <errno.h>
#include <fcntl.h>
#include <libinput.h>
+#include <libinput-util.h>
#include <libudev.h>
#include <unistd.h>
ck_assert(seat != NULL);
seat_name = libinput_seat_get_logical_name(seat);
- default_seat_found = !strcmp(seat_name, "default");
+ default_seat_found = streq(seat_name, "default");
libinput_event_destroy(event);
}
#include <libudev.h>
#include <libinput.h>
+#include <libinput-util.h>
#include <libinput-version.h>
#include "shared.h"
struct libinput_event *ev;
if (argc > 1) {
- if (strcmp(argv[1], "--help") == 0) {
+ if (streq(argv[1], "--help")) {
usage();
return 0;
- } else if (strcmp(argv[1], "--version") == 0) {
+ } else if (streq(argv[1], "--version")) {
printf("%s\n", LIBINPUT_VERSION);
return 0;
} else {
switch (c) {
case OPT_MODE:
- if (strcmp(optarg, "accel") == 0)
+ if (streq(optarg, "accel"))
print_accel = true;
- else if (strcmp(optarg, "motion") == 0)
+ else if (streq(optarg, "motion"))
print_motion = true;
- else if (strcmp(optarg, "delta") == 0)
+ else if (streq(optarg, "delta"))
print_delta = true;
- else if (strcmp(optarg, "sequence") == 0)
+ else if (streq(optarg, "sequence"))
print_sequence = true;
else {
usage();
#include <libudev.h>
#include <libevdev/libevdev.h>
+#include <libinput-util.h>
#include "shared.h"
tools_usage();
return 1;
}
- if (strcmp(optarg, "none") == 0) {
+ if (streq(optarg, "none")) {
options->click_method =
LIBINPUT_CONFIG_CLICK_METHOD_NONE;
- } else if (strcmp(optarg, "clickfinger") == 0) {
+ } else if (streq(optarg, "clickfinger")) {
options->click_method =
LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER;
- } else if (strcmp(optarg, "buttonareas") == 0) {
+ } else if (streq(optarg, "buttonareas")) {
options->click_method =
LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS;
} else {
tools_usage();
return 1;
}
- if (strcmp(optarg, "none") == 0) {
+ if (streq(optarg, "none")) {
options->scroll_method =
LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
- } else if (strcmp(optarg, "twofinger") == 0) {
+ } else if (streq(optarg, "twofinger")) {
options->scroll_method =
LIBINPUT_CONFIG_SCROLL_2FG;
- } else if (strcmp(optarg, "edge") == 0) {
+ } else if (streq(optarg, "edge")) {
options->scroll_method =
LIBINPUT_CONFIG_SCROLL_EDGE;
- } else if (strcmp(optarg, "button") == 0) {
+ } else if (streq(optarg, "button")) {
options->scroll_method =
LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN;
} else {