use streq instead of strcmp

This commit is contained in:
Thomas Hindoe Paaboel Andersen 2013-02-13 18:13:22 +01:00
parent b05105f0a8
commit 090be86534
22 changed files with 66 additions and 66 deletions

View File

@ -121,7 +121,7 @@ int boot_loader_find_active_entry(struct boot_info *info, const char *loader_act
return -ENOMEM;
for (i = 0; i < info->loader_entries_count; i++) {
if (strcmp(fn, info->loader_entries[i].path) == 0) {
if (streq(fn, info->loader_entries[i].path)) {
info->loader_entry_active = i;
break;
}

View File

@ -31,8 +31,8 @@ static void test_syslog_parse_identifier(const char* str,
ret2 = syslog_parse_identifier(&buf, &ident2, &pid2);
assert(ret == ret2);
assert(ident==ident2 || !strcmp(ident, ident2));
assert(pid==pid2 || !strcmp(pid, pid2));
assert(ident==ident2 || streq(ident, ident2));
assert(pid==pid2 || streq(pid, pid2));
}
int main(void) {

View File

@ -115,9 +115,9 @@ struct udev_monitor *udev_monitor_new_from_netlink_fd(struct udev *udev, const c
if (name == NULL)
group = UDEV_MONITOR_NONE;
else if (strcmp(name, "udev") == 0)
else if (streq(name, "udev"))
group = UDEV_MONITOR_UDEV;
else if (strcmp(name, "kernel") == 0)
else if (streq(name, "kernel"))
group = UDEV_MONITOR_KERNEL;
else
return NULL;
@ -467,7 +467,7 @@ static int passes_filter(struct udev_monitor *udev_monitor, struct udev_device *
const char *devtype;
const char *ddevtype;
if (strcmp(dsubsys, subsys) != 0)
if (!streq(dsubsys, subsys))
continue;
devtype = udev_list_entry_get_value(list_entry);
@ -476,7 +476,7 @@ static int passes_filter(struct udev_monitor *udev_monitor, struct udev_device *
ddevtype = udev_device_get_devtype(udev_device);
if (ddevtype == NULL)
continue;
if (strcmp(ddevtype, devtype) == 0)
if (streq(ddevtype, devtype))
goto tag;
}
return 0;

View File

@ -467,7 +467,7 @@ _public_ struct udev_list_entry *udev_queue_get_queued_list_entry(struct udev_qu
udev_list_entry_add(&udev_queue->queue_list, syspath, seqnum_str);
} else {
udev_list_entry_foreach(list_entry, udev_list_get_entry(&udev_queue->queue_list)) {
if (strcmp(seqnum_str, udev_list_entry_get_value(list_entry)) == 0) {
if (streq(seqnum_str, udev_list_entry_get_value(list_entry))) {
udev_list_entry_delete(list_entry);
break;
}

View File

@ -83,7 +83,7 @@ uid_t util_lookup_user(struct udev *udev, const char *user)
size_t buflen = sysconf(_SC_GETPW_R_SIZE_MAX);
char *buf = alloca(buflen);
if (strcmp(user, "root") == 0)
if (streq(user, "root"))
return 0;
uid = strtoul(user, &endptr, 10);
if (endptr[0] == '\0')
@ -108,7 +108,7 @@ gid_t util_lookup_group(struct udev *udev, const char *group)
size_t buflen = sysconf(_SC_GETPW_R_SIZE_MAX);
char *buf = NULL;
if (strcmp(group, "root") == 0)
if (streq(group, "root"))
return 0;
gid = strtoul(group, &endptr, 10);
if (endptr[0] == '\0')

View File

@ -191,7 +191,7 @@ _public_ struct udev *udev_new(void)
val++;
}
if (strcmp(key, "udev_log") == 0) {
if (streq(key, "udev_log")) {
udev_set_log_priority(udev, util_log_priority(val));
continue;
}

View File

@ -140,12 +140,12 @@ int main(int argc, char *argv[])
if (udev_device_get_devnode(dev) != NULL) {
mode_t mode = 0600;
if (strcmp(udev_device_get_subsystem(dev), "block") == 0)
if (streq(udev_device_get_subsystem(dev), "block"))
mode |= S_IFBLK;
else
mode |= S_IFCHR;
if (strcmp(action, "remove") != 0) {
if (!streq(action, "remove")) {
mkdir_parents_label(udev_device_get_devnode(dev), 0755);
mknod(udev_device_get_devnode(dev), mode, udev_device_get_devnum(dev));
} else {

View File

@ -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;

View File

@ -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) {

View File

@ -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);

View File

@ -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;
}

View File

@ -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);

View File

@ -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");
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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;

View File

@ -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);
}

View File

@ -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");

View File

@ -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");

View File

@ -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);

View File

@ -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 */

View File

@ -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");