diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2017-10-04 23:01:32 +0900 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2017-10-04 16:01:32 +0200 |
commit | 4c701096002fff540d9ddb3b21398c551ac3af78 (patch) | |
tree | 537e654dc92baa5eed5b6ff69867114384ecfa47 /src/journal | |
parent | 6d0aa4db7b33c9ce71b820c76428a1cfd24fb56f (diff) | |
download | systemd-4c701096002fff540d9ddb3b21398c551ac3af78.tar.gz |
tree-wide: use IN_SET macro (#6977)
Diffstat (limited to 'src/journal')
-rw-r--r-- | src/journal/catalog.c | 4 | ||||
-rw-r--r-- | src/journal/compress.c | 6 | ||||
-rw-r--r-- | src/journal/journalctl.c | 4 | ||||
-rw-r--r-- | src/journal/journald-audit.c | 8 | ||||
-rw-r--r-- | src/journal/journald-native.c | 2 | ||||
-rw-r--r-- | src/journal/journald-server.c | 4 | ||||
-rw-r--r-- | src/journal/sd-journal.c | 2 | ||||
-rw-r--r-- | src/journal/test-compress.c | 2 |
8 files changed, 16 insertions, 16 deletions
diff --git a/src/journal/catalog.c b/src/journal/catalog.c index f42be0adf9..bf92da9f90 100644 --- a/src/journal/catalog.c +++ b/src/journal/catalog.c @@ -216,7 +216,7 @@ int catalog_file_lang(const char* filename, char **lang) { return 0; beg = end - 1; - while (beg > filename && *beg != '.' && *beg != '/' && end - beg < 32) + while (beg > filename && !IN_SET(*beg, '.', '/') && end - beg < 32) beg--; if (*beg != '.' || end <= beg + 1) @@ -312,7 +312,7 @@ int catalog_import_file(Hashmap *h, const char *path) { line[0] == '-' && line[1] == '-' && line[2] == ' ' && - (line[2+1+32] == ' ' || line[2+1+32] == '\0')) { + IN_SET(line[2+1+32], ' ', '\0')) { bool with_language; sd_id128_t jd; diff --git a/src/journal/compress.c b/src/journal/compress.c index 818a720ba8..7ad7dd519d 100644 --- a/src/journal/compress.c +++ b/src/journal/compress.c @@ -280,7 +280,7 @@ int decompress_startswith_xz(const void *src, uint64_t src_size, for (;;) { ret = lzma_code(&s, LZMA_FINISH); - if (ret != LZMA_STREAM_END && ret != LZMA_OK) + if (!IN_SET(ret, LZMA_OK, LZMA_STREAM_END)) return -EBADMSG; if (*buffer_size - s.avail_out >= prefix_len + 1) @@ -417,7 +417,7 @@ int compress_stream_xz(int fdf, int fdt, uint64_t max_bytes) { } ret = lzma_code(&s, action); - if (ret != LZMA_OK && ret != LZMA_STREAM_END) { + if (!IN_SET(ret, LZMA_OK, LZMA_STREAM_END)) { log_error("Compression failed: code %u", ret); return -EBADMSG; } @@ -579,7 +579,7 @@ int decompress_stream_xz(int fdf, int fdt, uint64_t max_bytes) { } ret = lzma_code(&s, action); - if (ret != LZMA_OK && ret != LZMA_STREAM_END) { + if (!IN_SET(ret, LZMA_OK, LZMA_STREAM_END)) { log_debug("Decompression failed: code %u", ret); return -EBADMSG; } diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c index 3dcfb0e97a..641b9afa34 100644 --- a/src/journal/journalctl.c +++ b/src/journal/journalctl.c @@ -248,7 +248,7 @@ static int parse_boot_descriptor(const char *x, sd_id128_t *boot_id, int *offset if (r >= 0) x += 32; - if (*x != '-' && *x != '+' && *x != 0) + if (!IN_SET(*x, 0, '-', '+')) return -EINVAL; if (*x != 0) { @@ -1572,7 +1572,7 @@ static int setup_keys(void) { struct stat st; r = stat("/var/log/journal", &st); - if (r < 0 && errno != ENOENT && errno != ENOTDIR) + if (r < 0 && !IN_SET(errno, ENOENT, ENOTDIR)) return log_error_errno(errno, "stat(\"%s\") failed: %m", "/var/log/journal"); if (r < 0 || !S_ISDIR(st.st_mode)) { diff --git a/src/journal/journald-audit.c b/src/journal/journald-audit.c index b20e7ab129..3334418f33 100644 --- a/src/journal/journald-audit.c +++ b/src/journal/journald-audit.c @@ -49,7 +49,7 @@ static int map_simple_field(const char *field, const char **p, struct iovec **io return -ENOMEM; memcpy(c, field, l); - for (e = *p; *e != ' ' && *e != 0; e++) { + for (e = *p; !IN_SET(*e, 0, ' '); e++) { if (!GREEDY_REALLOC(c, allocated, l+2)) return -ENOMEM; @@ -110,7 +110,7 @@ static int map_string_field_internal(const char *field, const char **p, struct i return -ENOMEM; memcpy(c, field, l); - for (e = *p; *e != ' ' && *e != 0; e += 2) { + for (e = *p; !IN_SET(*e, 0, ' '); e += 2) { int a, b; uint8_t x; @@ -167,7 +167,7 @@ static int map_generic_field(const char *prefix, const char **p, struct iovec ** for (e = *p; e < *p + 16; e++) { - if (*e == 0 || *e == ' ') + if (IN_SET(*e, 0, ' ')) return 0; if (*e == '=') @@ -176,7 +176,7 @@ static int map_generic_field(const char *prefix, const char **p, struct iovec ** if (!((*e >= 'a' && *e <= 'z') || (*e >= 'A' && *e <= 'Z') || (*e >= '0' && *e <= '9') || - *e == '_' || *e == '-')) + IN_SET(*e, '_', '-'))) return 0; } diff --git a/src/journal/journald-native.c b/src/journal/journald-native.c index 554f91460d..8a2962335c 100644 --- a/src/journal/journald-native.c +++ b/src/journal/journald-native.c @@ -183,7 +183,7 @@ static int server_process_entry( break; } - if (*p == '.' || *p == '#') { + if (IN_SET(*p, '.', '#')) { /* Ignore control commands for now, and * comments too. */ *remaining -= (e - p) + 1; diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c index de643c9149..463a8dd97c 100644 --- a/src/journal/journald-server.c +++ b/src/journal/journald-server.c @@ -317,7 +317,7 @@ static int system_journal_open(Server *s, bool flush_requested) { (void) cache_space_refresh(s, &s->system_storage); patch_min_use(&s->system_storage); } else if (r < 0) { - if (r != -ENOENT && r != -EROFS) + if (!IN_SET(r, -ENOENT, -EROFS)) log_warning_errno(r, "Failed to open system journal: %m"); r = 0; @@ -1620,7 +1620,7 @@ static int server_connect_notify(Server *s) { if (!e) return 0; - if ((e[0] != '@' && e[0] != '/') || e[1] == 0) { + if (!IN_SET(e[0], '@', '/') || e[1] == 0) { log_error("NOTIFY_SOCKET set to an invalid value: %s", e); return -EINVAL; } diff --git a/src/journal/sd-journal.c b/src/journal/sd-journal.c index fb7269e510..a47bd122b9 100644 --- a/src/journal/sd-journal.c +++ b/src/journal/sd-journal.c @@ -450,7 +450,7 @@ _pure_ static int compare_with_location(JournalFile *f, Location *l) { assert(f); assert(l); assert(f->location_type == LOCATION_SEEK); - assert(l->type == LOCATION_DISCRETE || l->type == LOCATION_SEEK); + assert(IN_SET(l->type, LOCATION_DISCRETE, LOCATION_SEEK)); if (l->monotonic_set && sd_id128_equal(f->current_boot_id, l->boot_id) && diff --git a/src/journal/test-compress.c b/src/journal/test-compress.c index 92108a84b3..bd0ffaffbf 100644 --- a/src/journal/test-compress.c +++ b/src/journal/test-compress.c @@ -194,7 +194,7 @@ static void test_compress_stream(int compression, assert_se(lseek(dst, 1, SEEK_SET) == 1); r = decompress(dst, dst2, st.st_size); - assert_se(r == -EBADMSG || r == 0); + assert_se(IN_SET(r, 0, -EBADMSG)); assert_se(lseek(dst, 0, SEEK_SET) == 0); assert_se(lseek(dst2, 0, SEEK_SET) == 0); |