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 /src/shared | |
parent | 8d6167101696a28b7ac61b48fd2c1920564c4e90 (diff) |
use strneq instead of strncmp
Diffstat (limited to 'src/shared')
-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 |
4 files changed, 8 insertions, 8 deletions
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; |