diff options
author | Thomas Hindoe Paaboel Andersen <phomes@gmail.com> | 2013-02-12 21:47:36 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-02-13 00:56:13 +0100 |
commit | 641906e9366891e0ad3e6e38b7396a427678c4cf (patch) | |
tree | 47f90e01b79c50ab0839f0a0a10a8fae81dd9a25 | |
parent | 8d6167101696a28b7ac61b48fd2c1920564c4e90 (diff) |
use strneq instead of strncmp
-rw-r--r-- | src/core/load-fragment.c | 8 | ||||
-rw-r--r-- | src/delta/delta.c | 12 | ||||
-rw-r--r-- | src/libudev/libudev-enumerate.c | 2 | ||||
-rw-r--r-- | src/locale/localed.c | 2 | ||||
-rw-r--r-- | src/login/logind-inhibit.c | 14 | ||||
-rw-r--r-- | src/login/sd-login.c | 2 | ||||
-rw-r--r-- | src/shared/cgroup-util.c | 2 | ||||
-rw-r--r-- | src/shared/env-util.c | 10 | ||||
-rw-r--r-- | src/shared/socket-util.c | 2 | ||||
-rw-r--r-- | src/shared/util.c | 2 | ||||
-rw-r--r-- | src/stdio-bridge/stdio-bridge.c | 6 | ||||
-rw-r--r-- | src/udev/scsi_id/scsi_id.c | 8 | ||||
-rw-r--r-- | src/udev/scsi_id/scsi_serial.c | 2 | ||||
-rw-r--r-- | src/udev/udev-builtin-net_id.c | 2 | ||||
-rw-r--r-- | src/udev/udev-rules.c | 2 |
15 files changed, 38 insertions, 38 deletions
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c index 44698d46e5..6e333aaf15 100644 --- a/src/core/load-fragment.c +++ b/src/core/load-fragment.c @@ -459,7 +459,7 @@ int config_parse_exec( k = 0; FOREACH_WORD_QUOTED(w, l, rvalue, state) { - if (strncmp(w, ";", MAX(l, 1U)) == 0) + if (strneq(w, ";", MAX(l, 1U))) break; k++; @@ -471,9 +471,9 @@ int config_parse_exec( k = 0; FOREACH_WORD_QUOTED(w, l, rvalue, state) { - if (strncmp(w, ";", MAX(l, 1U)) == 0) + if (strneq(w, ";", MAX(l, 1U))) break; - else if (strncmp(w, "\\;", MAX(l, 1U)) == 0) + else if (strneq(w, "\\;", MAX(l, 1U))) w ++; if (honour_argv0 && w == rvalue) { @@ -2670,7 +2670,7 @@ void unit_dump_config_items(FILE *f) { prefix_len = dot-i; if (dot) - if (!prev || strncmp(prev, i, prefix_len+1) != 0) { + if (!prev || !strneq(prev, i, prefix_len+1)) { if (prev) fputc('\n', f); diff --git a/src/delta/delta.c b/src/delta/delta.c index 9f20938516..16b10021b7 100644 --- a/src/delta/delta.c +++ b/src/delta/delta.c @@ -312,17 +312,17 @@ static int parse_flags(const char *flag_str, int flags) { size_t l; FOREACH_WORD(w, l, flag_str, state) { - if (strncmp("masked", w, l) == 0) + if (strneq("masked", w, l)) flags |= SHOW_MASKED; - else if (strncmp ("equivalent", w, l) == 0) + else if (strneq ("equivalent", w, l)) flags |= SHOW_EQUIVALENT; - else if (strncmp("redirected", w, l) == 0) + else if (strneq("redirected", w, l)) flags |= SHOW_REDIRECTED; - else if (strncmp("overridden", w, l) == 0) + else if (strneq("overridden", w, l)) flags |= SHOW_OVERRIDDEN; - else if (strncmp("unchanged", w, l) == 0) + else if (strneq("unchanged", w, l)) flags |= SHOW_UNCHANGED; - else if (strncmp("default", w, l) == 0) + else if (strneq("default", w, l)) flags |= SHOW_DEFAULTS; else return -EINVAL; diff --git a/src/libudev/libudev-enumerate.c b/src/libudev/libudev-enumerate.c index 2c1f7ab4ac..5ccaabdc6c 100644 --- a/src/libudev/libudev-enumerate.c +++ b/src/libudev/libudev-enumerate.c @@ -309,7 +309,7 @@ _public_ struct udev_list_entry *udev_enumerate_get_list_entry(struct udev_enume } if (move_later && - strncmp(entry->syspath, move_later->syspath, move_later_prefix) != 0) { + !strneq(entry->syspath, move_later->syspath, move_later_prefix)) { udev_list_entry_add(&udev_enumerate->devices_list, move_later->syspath, NULL); move_later = NULL; diff --git a/src/locale/localed.c b/src/locale/localed.c index 6b1a793d3b..fedcdfb373 100644 --- a/src/locale/localed.c +++ b/src/locale/localed.c @@ -854,7 +854,7 @@ static int convert_x11_to_vconsole(DBusConnection *connection) { * layout stripped off. */ if (x > 0 && strlen(a[1]) == x && - strncmp(state.x11_layout, a[1], x) == 0) + strneq(state.x11_layout, a[1], x)) matching = 5; else { size_t w; diff --git a/src/login/logind-inhibit.c b/src/login/logind-inhibit.c index f1b9cca834..2c1a412e55 100644 --- a/src/login/logind-inhibit.c +++ b/src/login/logind-inhibit.c @@ -439,19 +439,19 @@ InhibitWhat inhibit_what_from_string(const char *s) { size_t l; FOREACH_WORD_SEPARATOR(w, l, s, ":", state) { - if (l == 8 && strncmp(w, "shutdown", l) == 0) + if (l == 8 && strneq(w, "shutdown", l)) what |= INHIBIT_SHUTDOWN; - else if (l == 5 && strncmp(w, "sleep", l) == 0) + else if (l == 5 && strneq(w, "sleep", l)) what |= INHIBIT_SLEEP; - else if (l == 4 && strncmp(w, "idle", l) == 0) + else if (l == 4 && strneq(w, "idle", l)) what |= INHIBIT_IDLE; - else if (l == 16 && strncmp(w, "handle-power-key", l) == 0) + else if (l == 16 && strneq(w, "handle-power-key", l)) what |= INHIBIT_HANDLE_POWER_KEY; - else if (l == 18 && strncmp(w, "handle-suspend-key", l) == 0) + else if (l == 18 && strneq(w, "handle-suspend-key", l)) what |= INHIBIT_HANDLE_SUSPEND_KEY; - else if (l == 20 && strncmp(w, "handle-hibernate-key", l) == 0) + else if (l == 20 && strneq(w, "handle-hibernate-key", l)) what |= INHIBIT_HANDLE_HIBERNATE_KEY; - else if (l == 17 && strncmp(w, "handle-lid-switch", l) == 0) + else if (l == 17 && strneq(w, "handle-lid-switch", l)) what |= INHIBIT_HANDLE_LID_SWITCH; else return _INHIBIT_WHAT_INVALID; diff --git a/src/login/sd-login.c b/src/login/sd-login.c index 4bc51e71a2..b81dddf86b 100644 --- a/src/login/sd-login.c +++ b/src/login/sd-login.c @@ -196,7 +196,7 @@ _public_ int sd_uid_is_on_seat(uid_t uid, int require_active, const char *seat) } FOREACH_WORD(w, l, s, state) { - if (strncmp(t, w, l) == 0) { + if (strneq(t, w, l)) { free(s); free(t); diff --git a/src/shared/cgroup-util.c b/src/shared/cgroup-util.c index acace52bc8..7efbc2ed39 100644 --- a/src/shared/cgroup-util.c +++ b/src/shared/cgroup-util.c @@ -811,7 +811,7 @@ int cg_get_by_pid(const char *controller, pid_t pid, char **path) { continue; l++; - if (strncmp(l, controller, cs) != 0) + if (!strneq(l, controller, cs)) continue; if (l[cs] != ':') diff --git a/src/shared/env-util.c b/src/shared/env-util.c index 9a833d22e4..0f1ac9294b 100644 --- a/src/shared/env-util.c +++ b/src/shared/env-util.c @@ -128,7 +128,7 @@ bool strv_env_is_valid(char **e) { /* Check if there are duplicate assginments */ k = strcspn(*p, "="); STRV_FOREACH(q, p + 1) - if (strncmp(*p, *q, k) == 0 && (*q)[k] == '=') + if (strneq(*p, *q, k) && (*q)[k] == '=') return false; } @@ -171,7 +171,7 @@ static int env_append(char **r, char ***k, char **a) { n++; for (j = r; j < *k; j++) - if (strncmp(*j, *a, n) == 0) + if (strneq(*j, *a, n)) break; if (j >= *k) @@ -247,7 +247,7 @@ static bool env_match(const char *t, const char *pattern) { if (!strchr(pattern, '=')) { size_t l = strlen(pattern); - return strncmp(t, pattern, l) == 0 && t[l] == '='; + return strneq(t, pattern, l) && t[l] == '='; } return false; @@ -363,7 +363,7 @@ char *strv_env_get_n(char **l, const char *name, size_t k) { return NULL; STRV_FOREACH(i, l) - if (strncmp(*i, name, k) == 0 && + if (strneq(*i, name, k) && (*i)[k] == '=') return *i + k + 1; @@ -391,7 +391,7 @@ char **strv_env_clean(char **e) { n = strcspn(*p, "="); STRV_FOREACH(q, p + 1) - if (strncmp(*p, *q, n) == 0 && (*q)[n] == '=') { + if (strneq(*p, *q, n) && (*q)[n] == '=') { duplicate = true; break; } diff --git a/src/shared/socket-util.c b/src/shared/socket-util.c index 56ec99f442..39b6142e88 100644 --- a/src/shared/socket-util.c +++ b/src/shared/socket-util.c @@ -432,7 +432,7 @@ bool socket_address_equal(const SocketAddress *a, const SocketAddress *b) { return false; if (a->sockaddr.un.sun_path[0]) { - if (strncmp(a->sockaddr.un.sun_path, b->sockaddr.un.sun_path, sizeof(a->sockaddr.un.sun_path)) != 0) + if (!strneq(a->sockaddr.un.sun_path, b->sockaddr.un.sun_path, sizeof(a->sockaddr.un.sun_path))) return false; } else { if (memcmp(a->sockaddr.un.sun_path, b->sockaddr.un.sun_path, a->size) != 0) diff --git a/src/shared/util.c b/src/shared/util.c index 24f9e7ee58..8dceb82051 100644 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -720,7 +720,7 @@ int parse_env_file( value = va_arg(ap, char **); n = strlen(key); - if (strncmp(p, key, n) != 0 || + if (!strneq(p, key, n) || p[n] != '=') continue; diff --git a/src/stdio-bridge/stdio-bridge.c b/src/stdio-bridge/stdio-bridge.c index f926fe5538..adc692f1eb 100644 --- a/src/stdio-bridge/stdio-bridge.c +++ b/src/stdio-bridge/stdio-bridge.c @@ -69,16 +69,16 @@ static size_t patch_in_line(char *line, size_t l, size_t left) { } else r = 0; - if (l == 5 && strncmp(line, "BEGIN", 5) == 0) { + if (l == 5 && strneq(line, "BEGIN", 5)) { r += l; auth_over = true; - } else if (l == 17 && strncmp(line, "NEGOTIATE_UNIX_FD", 17) == 0) { + } else if (l == 17 && strneq(line, "NEGOTIATE_UNIX_FD", 17)) { memmove(line + 13, line + 17, left); memcpy(line, "NEGOTIATE_NOP", 13); r += 13; - } else if (l >= 14 && strncmp(line, "AUTH EXTERNAL ", 14) == 0) { + } else if (l >= 14 && strneq(line, "AUTH EXTERNAL ", 14)) { char uid[20*2 + 1]; size_t len; diff --git a/src/udev/scsi_id/scsi_id.c b/src/udev/scsi_id/scsi_id.c index fa0413c462..d664787fd9 100644 --- a/src/udev/scsi_id/scsi_id.c +++ b/src/udev/scsi_id/scsi_id.c @@ -267,10 +267,10 @@ static int get_file_options(struct udev *udev, if (vendor == NULL) { if (vendor_in == NULL) break; - } else if ((vendor_in && strncmp(vendor, vendor_in, - strlen(vendor_in)) == 0) && - (!model_in || (strncmp(model, model_in, - strlen(model_in)) == 0))) { + } else if ((vendor_in && strneq(vendor, vendor_in, + strlen(vendor_in))) && + (!model_in || (strneq(model, model_in, + strlen(model_in))))) { /* * Matched vendor and optionally model. * diff --git a/src/udev/scsi_id/scsi_serial.c b/src/udev/scsi_id/scsi_serial.c index 950b8adc0a..d522a23a08 100644 --- a/src/udev/scsi_id/scsi_serial.c +++ b/src/udev/scsi_id/scsi_serial.c @@ -436,7 +436,7 @@ static int do_scsi_page0_inquiry(struct udev *udev, * If the vendor id appears in the page assume the page is * invalid. */ - if (!strncmp((char *)&buffer[VENDOR_LENGTH], dev_scsi->vendor, VENDOR_LENGTH)) { + if (strneq((char *)&buffer[VENDOR_LENGTH], dev_scsi->vendor, VENDOR_LENGTH)) { log_debug("%s: invalid page0 data\n", dev_scsi->kernel); return 1; } diff --git a/src/udev/udev-builtin-net_id.c b/src/udev/udev-builtin-net_id.c index 7ffdaad73f..c55c34d614 100644 --- a/src/udev/udev-builtin-net_id.c +++ b/src/udev/udev-builtin-net_id.c @@ -223,7 +223,7 @@ static int dev_pci_slot(struct udev_device *dev, struct netnames *names) { snprintf(str, sizeof(str), "%s/%s/address", slots, dent->d_name); if (read_one_line_file(str, &address) >= 0) { /* match slot address with device by stripping the function */ - if (strncmp(address, udev_device_get_sysname(names->pcidev), strlen(address)) == 0) + if (strneq(address, udev_device_get_sysname(names->pcidev), strlen(address))) hotplug_slot = i; free(address); } diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c index a86f8c365a..d2810a01d8 100644 --- a/src/udev/udev-rules.c +++ b/src/udev/udev-rules.c @@ -1737,7 +1737,7 @@ static int match_key(struct udev_rules *rules, struct token *token, const char * if (next != NULL) { size_t matchlen = (size_t)(next - s); - match = (matchlen == len && strncmp(s, val, matchlen) == 0); + match = (matchlen == len && strneq(s, val, matchlen)); if (match) break; } else { |