summaryrefslogtreecommitdiff
path: root/src/udev
diff options
context:
space:
mode:
authorThomas Hindoe Paaboel Andersen <phomes@gmail.com>2013-02-13 18:13:22 +0100
committerThomas Hindoe Paaboel Andersen <phomes@gmail.com>2013-02-13 18:14:20 +0100
commit090be8653471e1abe3f1cdd32eaad0fbd65f85cd (patch)
tree760849764326e78d458ff7019ac8b3f2d88245d8 /src/udev
parentb05105f0a80bcf2f2d18e9e33f740d7d04fca633 (diff)
use streq instead of strcmp
Diffstat (limited to 'src/udev')
-rw-r--r--src/udev/accelerometer/accelerometer.c2
-rw-r--r--src/udev/collect/collect.c6
-rw-r--r--src/udev/scsi_id/scsi_id.c12
-rw-r--r--src/udev/udev-builtin-kmod.c2
-rw-r--r--src/udev/udev-builtin-net_id.c2
-rw-r--r--src/udev/udev-builtin-path_id.c28
-rw-r--r--src/udev/udev-builtin-usb_id.c2
-rw-r--r--src/udev/udev-builtin.c2
-rw-r--r--src/udev/udev-event.c6
-rw-r--r--src/udev/udev-node.c12
-rw-r--r--src/udev/udevadm-info.c12
-rw-r--r--src/udev/udevadm-test.c6
-rw-r--r--src/udev/udevadm-trigger.c4
-rw-r--r--src/udev/udevadm.c2
-rw-r--r--src/udev/udevd.c8
15 files changed, 53 insertions, 53 deletions
diff --git a/src/udev/accelerometer/accelerometer.c b/src/udev/accelerometer/accelerometer.c
index 2fea3889c7..f50db71a76 100644
--- a/src/udev/accelerometer/accelerometer.c
+++ b/src/udev/accelerometer/accelerometer.c
@@ -122,7 +122,7 @@ string_to_orientation (const char *orientation)
if (orientation == NULL)
return ORIENTATION_UNDEFINED;
for (i = 0; orientations[i] != NULL; i++) {
- if (strcmp (orientation, orientations[i]) == 0)
+ if (streq (orientation, orientations[i]))
return i;
}
return ORIENTATION_UNDEFINED;
diff --git a/src/udev/collect/collect.c b/src/udev/collect/collect.c
index f594814dbe..7850cfa418 100644
--- a/src/udev/collect/collect.c
+++ b/src/udev/collect/collect.c
@@ -213,7 +213,7 @@ static void invite(char *us)
udev_list_node_foreach(him_node, &bunch) {
struct _mate *him = node_to_mate(him_node);
- if (!strcmp(him->name, us)) {
+ if (streq(him->name, us)) {
him->state = STATE_CONFIRMED;
who = him;
}
@@ -241,7 +241,7 @@ static void reject(char *us)
udev_list_node_foreach(him_node, &bunch) {
struct _mate *him = node_to_mate(him_node);
- if (!strcmp(him->name, us)) {
+ if (streq(him->name, us)) {
him->state = STATE_NONE;
who = him;
}
@@ -434,7 +434,7 @@ int main(int argc, char **argv)
udev_list_node_foreach(him_node, &bunch) {
struct _mate *him = node_to_mate(him_node);
- if (!strcmp(him->name, argv[i]))
+ if (streq(him->name, argv[i]))
who = him;
}
if (!who) {
diff --git a/src/udev/scsi_id/scsi_id.c b/src/udev/scsi_id/scsi_id.c
index dcf03eefac..ab7c54c3f2 100644
--- a/src/udev/scsi_id/scsi_id.c
+++ b/src/udev/scsi_id/scsi_id.c
@@ -372,11 +372,11 @@ static int set_options(struct udev *udev,
exit(0);
case 'p':
- if (strcmp(optarg, "0x80") == 0) {
+ if (streq(optarg, "0x80")) {
default_page_code = PAGE_80;
- } else if (strcmp(optarg, "0x83") == 0) {
+ } else if (streq(optarg, "0x83")) {
default_page_code = PAGE_83;
- } else if (strcmp(optarg, "pre-spc3-83") == 0) {
+ } else if (streq(optarg, "pre-spc3-83")) {
default_page_code = PAGE_83_PRE_SPC3;
} else {
log_error("Unknown page code '%s'\n", optarg);
@@ -449,11 +449,11 @@ static int per_dev_options(struct udev *udev,
break;
case 'p':
- if (strcmp(optarg, "0x80") == 0) {
+ if (streq(optarg, "0x80")) {
*page_code = PAGE_80;
- } else if (strcmp(optarg, "0x83") == 0) {
+ } else if (streq(optarg, "0x83")) {
*page_code = PAGE_83;
- } else if (strcmp(optarg, "pre-spc3-83") == 0) {
+ } else if (streq(optarg, "pre-spc3-83")) {
*page_code = PAGE_83_PRE_SPC3;
} else {
log_error("Unknown page code '%s'\n", optarg);
diff --git a/src/udev/udev-builtin-kmod.c b/src/udev/udev-builtin-kmod.c
index 17aca2944d..fc28121267 100644
--- a/src/udev/udev-builtin-kmod.c
+++ b/src/udev/udev-builtin-kmod.c
@@ -78,7 +78,7 @@ static int builtin_kmod(struct udev_device *dev, int argc, char *argv[], bool te
if (!ctx)
return 0;
- if (argc < 3 || strcmp(argv[1], "load")) {
+ if (argc < 3 || !streq(argv[1], "load")) {
log_error("expect: %s load <module>\n", argv[0]);
return EXIT_FAILURE;
}
diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c
index c55c34d614..57674bf278 100644
--- a/src/udev/udev-builtin-net_id.c
+++ b/src/udev/udev-builtin-net_id.c
@@ -413,7 +413,7 @@ static int builtin_net_id(struct udev_device *dev, int argc, char *argv[], bool
p = udev_device_get_sysattr_value(dev, "iflink");
if (!p)
return EXIT_FAILURE;
- if (strcmp(s, p) != 0)
+ if (!streq(s, p))
return 0;
devtype = udev_device_get_devtype(dev);
diff --git a/src/udev/udev-builtin-path_id.c b/src/udev/udev-builtin-path_id.c
index d6b3736aee..da0273197b 100644
--- a/src/udev/udev-builtin-path_id.c
+++ b/src/udev/udev-builtin-path_id.c
@@ -83,7 +83,7 @@ static struct udev_device *skip_subsystem(struct udev_device *dev, const char *s
const char *subsystem;
subsystem = udev_device_get_subsystem(parent);
- if (subsystem == NULL || strcmp(subsystem, subsys) != 0)
+ if (subsystem == NULL || !streq(subsystem, subsys))
break;
dev = parent;
parent = udev_device_get_parent(parent);
@@ -345,7 +345,7 @@ static struct udev_device *handle_scsi(struct udev_device *parent, char **path)
const char *id;
devtype = udev_device_get_devtype(parent);
- if (devtype == NULL || strcmp(devtype, "scsi_device") != 0)
+ if (devtype == NULL || !streq(devtype, "scsi_device"))
return parent;
/* firewire */
@@ -438,7 +438,7 @@ static struct udev_device *handle_usb(struct udev_device *parent, char **path)
devtype = udev_device_get_devtype(parent);
if (devtype == NULL)
return parent;
- if (strcmp(devtype, "usb_interface") != 0 && strcmp(devtype, "usb_device") != 0)
+ if (!streq(devtype, "usb_interface") && !streq(devtype, "usb_device"))
return parent;
str = udev_device_get_sysname(parent);
@@ -498,37 +498,37 @@ static int builtin_path_id(struct udev_device *dev, int argc, char *argv[], bool
subsys = udev_device_get_subsystem(parent);
if (subsys == NULL) {
;
- } else if (strcmp(subsys, "scsi_tape") == 0) {
+ } else if (streq(subsys, "scsi_tape")) {
handle_scsi_tape(parent, &path);
- } else if (strcmp(subsys, "scsi") == 0) {
+ } else if (streq(subsys, "scsi")) {
parent = handle_scsi(parent, &path);
some_transport = true;
- } else if (strcmp(subsys, "cciss") == 0) {
+ } else if (streq(subsys, "cciss")) {
parent = handle_cciss(parent, &path);
some_transport = true;
- } else if (strcmp(subsys, "usb") == 0) {
+ } else if (streq(subsys, "usb")) {
parent = handle_usb(parent, &path);
some_transport = true;
- } else if (strcmp(subsys, "serio") == 0) {
+ } else if (streq(subsys, "serio")) {
path_prepend(&path, "serio-%s", udev_device_get_sysnum(parent));
parent = skip_subsystem(parent, "serio");
- } else if (strcmp(subsys, "pci") == 0) {
+ } else if (streq(subsys, "pci")) {
path_prepend(&path, "pci-%s", udev_device_get_sysname(parent));
parent = skip_subsystem(parent, "pci");
- } else if (strcmp(subsys, "platform") == 0) {
+ } else if (streq(subsys, "platform")) {
path_prepend(&path, "platform-%s", udev_device_get_sysname(parent));
parent = skip_subsystem(parent, "platform");
some_transport = true;
- } else if (strcmp(subsys, "acpi") == 0) {
+ } else if (streq(subsys, "acpi")) {
path_prepend(&path, "acpi-%s", udev_device_get_sysname(parent));
parent = skip_subsystem(parent, "acpi");
- } else if (strcmp(subsys, "xen") == 0) {
+ } else if (streq(subsys, "xen")) {
path_prepend(&path, "xen-%s", udev_device_get_sysname(parent));
parent = skip_subsystem(parent, "xen");
- } else if (strcmp(subsys, "virtio") == 0) {
+ } else if (streq(subsys, "virtio")) {
path_prepend(&path, "virtio-pci-%s", udev_device_get_sysname(parent));
parent = skip_subsystem(parent, "virtio");
- } else if (strcmp(subsys, "scm") == 0) {
+ } else if (streq(subsys, "scm")) {
path_prepend(&path, "scm-%s", udev_device_get_sysname(parent));
parent = skip_subsystem(parent, "scm");
}
diff --git a/src/udev/udev-builtin-usb_id.c b/src/udev/udev-builtin-usb_id.c
index 7ce401d152..01e42ca7b1 100644
--- a/src/udev/udev-builtin-usb_id.c
+++ b/src/udev/udev-builtin-usb_id.c
@@ -273,7 +273,7 @@ static int builtin_usb_id(struct udev_device *dev, int argc, char *argv[], bool
instance_str[0] = '\0';
/* shortcut, if we are called directly for a "usb_device" type */
- if (udev_device_get_devtype(dev) != NULL && strcmp(udev_device_get_devtype(dev), "usb_device") == 0) {
+ if (udev_device_get_devtype(dev) != NULL && streq(udev_device_get_devtype(dev), "usb_device")) {
dev_if_packed_info(dev, packed_if_str, sizeof(packed_if_str));
dev_usb = dev;
goto fallback;
diff --git a/src/udev/udev-builtin.c b/src/udev/udev-builtin.c
index 0651ae2ff0..57d75a13e4 100644
--- a/src/udev/udev-builtin.c
+++ b/src/udev/udev-builtin.c
@@ -115,7 +115,7 @@ enum udev_builtin_cmd udev_builtin_lookup(const char *command)
if (pos)
pos[0] = '\0';
for (i = 0; i < ELEMENTSOF(builtins); i++)
- if (strcmp(builtins[i]->name, name) == 0)
+ if (streq(builtins[i]->name, name))
return i;
return UDEV_BUILTIN_MAX;
}
diff --git a/src/udev/udev-event.c b/src/udev/udev-event.c
index ef9fc61c64..efd9b6d71d 100644
--- a/src/udev/udev-event.c
+++ b/src/udev/udev-event.c
@@ -784,7 +784,7 @@ int udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules,
if (udev_device_get_subsystem(dev) == NULL)
return -1;
- if (strcmp(udev_device_get_action(dev), "remove") == 0) {
+ if (streq(udev_device_get_action(dev), "remove")) {
udev_device_read_db(dev, NULL);
udev_device_delete_db(dev);
udev_device_tag_index(dev, NULL, false);
@@ -812,8 +812,8 @@ int udev_event_execute_rules(struct udev_event *event, struct udev_rules *rules,
udev_rules_apply_to_event(rules, event, sigmask);
/* rename a new network interface, if needed */
- if (udev_device_get_ifindex(dev) > 0 && strcmp(udev_device_get_action(dev), "add") == 0 &&
- event->name != NULL && strcmp(event->name, udev_device_get_sysname(dev)) != 0) {
+ if (udev_device_get_ifindex(dev) > 0 && streq(udev_device_get_action(dev), "add") &&
+ event->name != NULL && !streq(event->name, udev_device_get_sysname(dev))) {
char syspath[UTIL_PATH_SIZE];
char *pos;
diff --git a/src/udev/udev-node.c b/src/udev/udev-node.c
index 363cee1d1c..1148a1529c 100644
--- a/src/udev/udev-node.c
+++ b/src/udev/udev-node.c
@@ -74,7 +74,7 @@ static int node_symlink(struct udev_device *dev, const char *node, const char *s
len = readlink(slink, buf, sizeof(buf));
if (len > 0 && len < (int)sizeof(buf)) {
buf[len] = '\0';
- if (strcmp(target, buf) == 0) {
+ if (streq(target, buf)) {
log_debug("preserve already existing symlink '%s' to '%s'\n", slink, target);
label_fix(slink, true, false);
utimensat(AT_FDCWD, slink, NULL, AT_SYMLINK_NOFOLLOW);
@@ -154,7 +154,7 @@ static const char *link_find_prioritized(struct udev_device *dev, bool add, cons
log_debug("found '%s' claiming '%s'\n", dent->d_name, stackdir);
/* did we find ourself? */
- if (strcmp(dent->d_name, udev_device_get_id_filename(dev)) == 0)
+ if (streq(dent->d_name, udev_device_get_id_filename(dev)))
continue;
dev_db = udev_device_new_from_device_id(udev, dent->d_name);
@@ -238,7 +238,7 @@ void udev_node_update_old_links(struct udev_device *dev, struct udev_device *dev
udev_list_entry_foreach(list_entry_current, udev_device_get_devlinks_list_entry(dev)) {
const char *name_current = udev_list_entry_get_name(list_entry_current);
- if (strcmp(name, name_current) == 0) {
+ if (streq(name, name_current)) {
found = 1;
break;
}
@@ -259,7 +259,7 @@ static int node_permissions_apply(struct udev_device *dev, bool apply, mode_t mo
struct stat stats;
int err = 0;
- if (strcmp(udev_device_get_subsystem(dev), "block") == 0)
+ if (streq(udev_device_get_subsystem(dev), "block"))
mode |= S_IFBLK;
else
mode |= S_IFCHR;
@@ -307,7 +307,7 @@ void udev_node_add(struct udev_device *dev, bool apply, mode_t mode, uid_t uid,
/* always add /dev/{block,char}/$major:$minor */
snprintf(filename, sizeof(filename), "/dev/%s/%u:%u",
- strcmp(udev_device_get_subsystem(dev), "block") == 0 ? "block" : "char",
+ streq(udev_device_get_subsystem(dev), "block") ? "block" : "char",
major(udev_device_get_devnum(dev)), minor(udev_device_get_devnum(dev)));
node_symlink(dev, udev_device_get_devnode(dev), filename);
@@ -327,7 +327,7 @@ void udev_node_remove(struct udev_device *dev)
/* remove /dev/{block,char}/$major:$minor */
snprintf(filename, sizeof(filename), "/dev/%s/%u:%u",
- strcmp(udev_device_get_subsystem(dev), "block") == 0 ? "block" : "char",
+ streq(udev_device_get_subsystem(dev), "block") ? "block" : "char",
major(udev_device_get_devnum(dev)), minor(udev_device_get_devnum(dev)));
unlink(filename);
}
diff --git a/src/udev/udevadm-info.c b/src/udev/udevadm-info.c
index d6f82869b1..0f4565eda8 100644
--- a/src/udev/udevadm-info.c
+++ b/src/udev/udevadm-info.c
@@ -45,7 +45,7 @@ static bool skip_attribute(const char *name)
unsigned int i;
for (i = 0; i < ELEMENTSOF(skip); i++)
- if (strcmp(name, skip[i]) == 0)
+ if (streq(name, skip[i]))
return true;
return false;
}
@@ -393,15 +393,15 @@ static int uinfo(struct udev *udev, int argc, char *argv[])
break;
case 'q':
action = ACTION_QUERY;
- if (strcmp(optarg, "property") == 0 || strcmp(optarg, "env") == 0) {
+ if (streq(optarg, "property") || streq(optarg, "env")) {
query = QUERY_PROPERTY;
- } else if (strcmp(optarg, "name") == 0) {
+ } else if (streq(optarg, "name")) {
query = QUERY_NAME;
- } else if (strcmp(optarg, "symlink") == 0) {
+ } else if (streq(optarg, "symlink")) {
query = QUERY_SYMLINK;
- } else if (strcmp(optarg, "path") == 0) {
+ } else if (streq(optarg, "path")) {
query = QUERY_PATH;
- } else if (strcmp(optarg, "all") == 0) {
+ } else if (streq(optarg, "all")) {
query = QUERY_ALL;
} else {
fprintf(stderr, "unknown query type\n");
diff --git a/src/udev/udevadm-test.c b/src/udev/udevadm-test.c
index f22a2c32cc..df1409bff6 100644
--- a/src/udev/udevadm-test.c
+++ b/src/udev/udevadm-test.c
@@ -66,11 +66,11 @@ static int adm_test(struct udev *udev, int argc, char *argv[])
action = optarg;
break;
case 'N':
- if (strcmp (optarg, "early") == 0) {
+ if (streq (optarg, "early")) {
resolve_names = 1;
- } else if (strcmp (optarg, "late") == 0) {
+ } else if (streq (optarg, "late")) {
resolve_names = 0;
- } else if (strcmp (optarg, "never") == 0) {
+ } else if (streq (optarg, "never")) {
resolve_names = -1;
} else {
fprintf(stderr, "resolve-names must be early, late or never\n");
diff --git a/src/udev/udevadm-trigger.c b/src/udev/udevadm-trigger.c
index 4d96a786c3..9624c66fba 100644
--- a/src/udev/udevadm-trigger.c
+++ b/src/udev/udevadm-trigger.c
@@ -122,9 +122,9 @@ static int adm_trigger(struct udev *udev, int argc, char *argv[])
dry_run = 1;
break;
case 't':
- if (strcmp(optarg, "devices") == 0) {
+ if (streq(optarg, "devices")) {
device_type = TYPE_DEVICES;
- } else if (strcmp(optarg, "subsystems") == 0) {
+ } else if (streq(optarg, "subsystems")) {
device_type = TYPE_SUBSYSTEMS;
} else {
log_error("unknown type --type=%s\n", optarg);
diff --git a/src/udev/udevadm.c b/src/udev/udevadm.c
index 53419ffa62..e14b3ca27c 100644
--- a/src/udev/udevadm.c
+++ b/src/udev/udevadm.c
@@ -131,7 +131,7 @@ int main(int argc, char *argv[])
if (command != NULL)
for (i = 0; i < ELEMENTSOF(udevadm_cmds); i++) {
- if (strcmp(udevadm_cmds[i]->name, command) == 0) {
+ if (streq(udevadm_cmds[i]->name, command)) {
argc -= optind;
argv += optind;
/* we need '0' here to reset the internal state */
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index 9f184621ae..088a89f470 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -499,7 +499,7 @@ static bool is_devpath_busy(struct event *event)
return true;
/* check our old name */
- if (event->devpath_old != NULL && strcmp(loop_event->devpath, event->devpath_old) == 0) {
+ if (event->devpath_old != NULL && streq(loop_event->devpath, event->devpath_old)) {
event->delaying_seqnum = loop_event->seqnum;
return true;
}
@@ -1117,11 +1117,11 @@ int main(int argc, char *argv[])
udev_set_log_priority(udev, LOG_DEBUG);
break;
case 'N':
- if (strcmp (optarg, "early") == 0) {
+ if (streq(optarg, "early")) {
resolve_names = 1;
- } else if (strcmp (optarg, "late") == 0) {
+ } else if (streq(optarg, "late")) {
resolve_names = 0;
- } else if (strcmp (optarg, "never") == 0) {
+ } else if (streq(optarg, "never")) {
resolve_names = -1;
} else {
fprintf(stderr, "resolve-names must be early, late or never\n");