diff options
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/ask-password-api.c | 2 | ||||
-rw-r--r-- | src/shared/condition.c | 2 | ||||
-rw-r--r-- | src/shared/dissect-image.c | 4 | ||||
-rw-r--r-- | src/shared/dns-domain.c | 9 | ||||
-rw-r--r-- | src/shared/firewall-util.c | 4 | ||||
-rw-r--r-- | src/shared/logs-show.c | 2 | ||||
-rw-r--r-- | src/shared/machine-image.c | 6 | ||||
-rw-r--r-- | src/shared/path-lookup.c | 4 |
8 files changed, 16 insertions, 17 deletions
diff --git a/src/shared/ask-password-api.c b/src/shared/ask-password-api.c index de3847adfd..e33d8b11cf 100644 --- a/src/shared/ask-password-api.c +++ b/src/shared/ask-password-api.c @@ -337,7 +337,7 @@ int ask_password_tty( backspace_chars(ttyfd, p); p = 0; - } else if (c == '\b' || c == 127) { + } else if (IN_SET(c, '\b', 127)) { if (p > 0) { diff --git a/src/shared/condition.c b/src/shared/condition.c index 103f8d2e39..74d5e854e1 100644 --- a/src/shared/condition.c +++ b/src/shared/condition.c @@ -131,7 +131,7 @@ static int condition_test_kernel_command_line(Condition *c) { const char *f; f = startswith(word, c->parameter); - found = f && (*f == '=' || *f == 0); + found = f && IN_SET(*f, 0, '='); } if (found) diff --git a/src/shared/dissect-image.c b/src/shared/dissect-image.c index 243a46f2e3..b782b05f88 100644 --- a/src/shared/dissect-image.c +++ b/src/shared/dissect-image.c @@ -57,7 +57,7 @@ _unused_ static int probe_filesystem(const char *node, char **ret_fstype) { errno = 0; r = blkid_do_safeprobe(b); - if (r == -2 || r == 1) { + if (IN_SET(r, -2, 1)) { log_debug("Failed to identify any partition type on partition %s", node); goto not_found; } @@ -156,7 +156,7 @@ int dissect_image(int fd, const void *root_hash, size_t root_hash_size, DissectI errno = 0; r = blkid_do_safeprobe(b); - if (r == -2 || r == 1) { + if (IN_SET(r, -2, 1)) { log_debug("Failed to identify any partition table."); return -ENOPKG; } diff --git a/src/shared/dns-domain.c b/src/shared/dns-domain.c index 139d286af8..d75abd8121 100644 --- a/src/shared/dns-domain.c +++ b/src/shared/dns-domain.c @@ -76,7 +76,7 @@ int dns_label_unescape(const char **name, char *dest, size_t sz) { /* Ending NUL */ return -EINVAL; - else if (*n == '\\' || *n == '.') { + else if (IN_SET(*n, '\\', '.')) { /* Escaped backslash or dot */ if (d) @@ -164,7 +164,7 @@ int dns_label_unescape_suffix(const char *name, const char **label_terminal, cha } terminal = *label_terminal; - assert(*terminal == '.' || *terminal == 0); + assert(IN_SET(*terminal, 0, '.')); /* Skip current terminal character (and accept domain names ending it ".") */ if (*terminal == 0) @@ -228,7 +228,7 @@ int dns_label_escape(const char *p, size_t l, char *dest, size_t sz) { q = dest; while (l > 0) { - if (*p == '.' || *p == '\\') { + if (IN_SET(*p, '.', '\\')) { /* Dot or backslash */ @@ -240,8 +240,7 @@ int dns_label_escape(const char *p, size_t l, char *dest, size_t sz) { sz -= 2; - } else if (*p == '_' || - *p == '-' || + } else if (IN_SET(*p, '_', '-') || (*p >= '0' && *p <= '9') || (*p >= 'a' && *p <= 'z') || (*p >= 'A' && *p <= 'Z')) { diff --git a/src/shared/firewall-util.c b/src/shared/firewall-util.c index 3a6e987ee1..6d295ea65b 100644 --- a/src/shared/firewall-util.c +++ b/src/shared/firewall-util.c @@ -110,7 +110,7 @@ int fw_add_masquerade( if (af != AF_INET) return -EOPNOTSUPP; - if (protocol != 0 && protocol != IPPROTO_TCP && protocol != IPPROTO_UDP) + if (!IN_SET(protocol, 0, IPPROTO_TCP, IPPROTO_UDP)) return -EOPNOTSUPP; h = iptc_init("nat"); @@ -194,7 +194,7 @@ int fw_add_local_dnat( if (af != AF_INET) return -EOPNOTSUPP; - if (protocol != IPPROTO_TCP && protocol != IPPROTO_UDP) + if (!IN_SET(protocol, IPPROTO_TCP, IPPROTO_UDP)) return -EOPNOTSUPP; if (local_port <= 0) diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c index 54516cfb96..0626d80b19 100644 --- a/src/shared/logs-show.c +++ b/src/shared/logs-show.c @@ -683,7 +683,7 @@ void json_escape( fputc('\"', f); while (l > 0) { - if (*p == '"' || *p == '\\') { + if (IN_SET(*p, '"', '\\')) { fputc('\\', f); fputc(*p, f); } else if (*p == '\n') diff --git a/src/shared/machine-image.c b/src/shared/machine-image.c index 32a4c67590..859e5ffc1a 100644 --- a/src/shared/machine-image.c +++ b/src/shared/machine-image.c @@ -313,7 +313,7 @@ int image_find(const char *name, Image **ret) { } r = image_make(NULL, dirfd(d), path, name, ret); - if (r == 0 || r == -ENOENT) { + if (IN_SET(r, 0, -ENOENT)) { _cleanup_free_ char *raw = NULL; raw = strappend(name, ".raw"); @@ -321,7 +321,7 @@ int image_find(const char *name, Image **ret) { return -ENOMEM; r = image_make(NULL, dirfd(d), path, raw, ret); - if (r == 0 || r == -ENOENT) + if (IN_SET(r, 0, -ENOENT)) continue; } if (r < 0) @@ -364,7 +364,7 @@ int image_discover(Hashmap *h) { continue; r = image_make(NULL, dirfd(d), path, de->d_name, &image); - if (r == 0 || r == -ENOENT) + if (IN_SET(r, 0, -ENOENT)) continue; if (r < 0) return r; diff --git a/src/shared/path-lookup.c b/src/shared/path-lookup.c index bf10acda94..e7a878ab50 100644 --- a/src/shared/path-lookup.c +++ b/src/shared/path-lookup.c @@ -514,13 +514,13 @@ int lookup_paths_init( /* Note: if XDG_RUNTIME_DIR is not set, this will fail completely with ENXIO */ r = acquire_generator_dirs(scope, tempdir, &generator, &generator_early, &generator_late); - if (r < 0 && r != -EOPNOTSUPP && r != -ENXIO) + if (r < 0 && !IN_SET(r, -EOPNOTSUPP, -ENXIO)) return r; } /* Note: if XDG_RUNTIME_DIR is not set, this will fail completely with ENXIO */ r = acquire_transient_dir(scope, tempdir, &transient); - if (r < 0 && r != -EOPNOTSUPP && r != -ENXIO) + if (r < 0 && !IN_SET(r, -EOPNOTSUPP, -ENXIO)) return r; /* Note: when XDG_RUNTIME_DIR is not set this will not return -ENXIO, but simply set runtime_control to NULL */ |