diff options
-rw-r--r-- | src/basic/cgroup-util.c | 2 | ||||
-rw-r--r-- | src/basic/json.c | 5 | ||||
-rw-r--r-- | src/basic/time-util.c | 6 | ||||
-rw-r--r-- | src/core/cgroup.c | 8 | ||||
-rw-r--r-- | src/journal/journald-syslog.c | 4 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/sd-bus.c | 8 | ||||
-rw-r--r-- | src/test/test-hexdecoct.c | 2 |
7 files changed, 16 insertions, 19 deletions
diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c index e010fc7b5a..19723d3084 100644 --- a/src/basic/cgroup-util.c +++ b/src/basic/cgroup-util.c @@ -2123,7 +2123,7 @@ int cg_create_everywhere(CGroupMask supported, CGroupMask mask, const char *path r = cg_create(SYSTEMD_CGROUP_CONTROLLER, path); if (r < 0) return r; - created = !!r; + created = r; /* If we are in the unified hierarchy, we are done now */ r = cg_all_unified(); diff --git a/src/basic/json.c b/src/basic/json.c index 426ed0328e..7590ca9883 100644 --- a/src/basic/json.c +++ b/src/basic/json.c @@ -1763,8 +1763,7 @@ static int json_parse_string(const char **p, char **ret) { *p = c + 1; - *ret = s; - s = NULL; + *ret = TAKE_PTR(s); return JSON_TOKEN_STRING; } @@ -1919,7 +1918,7 @@ static int json_parse_number(const char **p, JsonValue *ret) { } while (strchr("0123456789", *c) && *c != 0); } - if (*c == 'e' || *c == 'E') { + if (IN_SET(*c, 'e', 'E')) { is_real = true; c++; diff --git a/src/basic/time-util.c b/src/basic/time-util.c index 158e4aaf93..9115c3bf27 100644 --- a/src/basic/time-util.c +++ b/src/basic/time-util.c @@ -280,7 +280,7 @@ static char *format_timestamp_internal( /* Let's not format times with years > 9999 */ if (t > USEC_TIMESTAMP_FORMATTABLE_MAX) { - assert(l >= strlen("--- XXXX-XX-XX XX:XX:XX") + 1); + assert(l >= STRLEN("--- XXXX-XX-XX XX:XX:XX") + 1); strcpy(buf, "--- XXXX-XX-XX XX:XX:XX"); return buf; } @@ -1026,7 +1026,7 @@ int parse_time(const char *t, usec_t *usec, usec_t default_unit) { char *b = e + 1; /* Don't allow "0.-0", "3.+1" or "3. 1" */ - if (*b == '-' || *b == '+' || isspace(*b)) + if (IN_SET(*b, '-', '+') || isspace(*b)) return -EINVAL; errno = 0; @@ -1164,7 +1164,7 @@ int parse_nsec(const char *t, nsec_t *nsec) { if (*e == '.') { char *b = e + 1; - if (*b == '-' || *b == '+' || isspace(*b)) + if (IN_SET(*b, '-', '+') || isspace(*b)) return -EINVAL; errno = 0; diff --git a/src/core/cgroup.c b/src/core/cgroup.c index 1e5b564e17..e4341c6245 100644 --- a/src/core/cgroup.c +++ b/src/core/cgroup.c @@ -343,9 +343,9 @@ int cgroup_add_device_allow(CGroupContext *c, const char *dev, const char *mode) *a = (CGroupDeviceAllow) { .path = TAKE_PTR(d), - .r = isempty(mode) || !!strchr(mode, 'r'), - .w = isempty(mode) || !!strchr(mode, 'w'), - .m = isempty(mode) || !!strchr(mode, 'm'), + .r = isempty(mode) || strchr(mode, 'r'), + .w = isempty(mode) || strchr(mode, 'w'), + .m = isempty(mode) || strchr(mode, 'm'), }; LIST_PREPEND(device_allow, c->device_allow, a); @@ -1579,7 +1579,7 @@ static int unit_create_cgroup( r = cg_create_everywhere(u->manager->cgroup_supported, target_mask, u->cgroup_path); if (r < 0) return log_unit_error_errno(u, r, "Failed to create cgroup %s: %m", u->cgroup_path); - created = !!r; + created = r; /* Start watching it */ (void) unit_watch_cgroup(u); diff --git a/src/journal/journald-syslog.c b/src/journal/journald-syslog.c index 4dbf42c53b..a60a259bc4 100644 --- a/src/journal/journald-syslog.c +++ b/src/journal/journald-syslog.c @@ -407,7 +407,7 @@ void server_process_syslog_message( } if (syslog_ts_len > 0) { - const size_t hlen = strlen("SYSLOG_TIMESTAMP="); + const size_t hlen = STRLEN("SYSLOG_TIMESTAMP="); t = newa(char, hlen + syslog_ts_len); memcpy(t, "SYSLOG_TIMESTAMP=", hlen); @@ -424,7 +424,7 @@ void server_process_syslog_message( iovec[n++] = IOVEC_MAKE_STRING(msg_msg); if (store_raw) { - const size_t hlen = strlen("SYSLOG_RAW="); + const size_t hlen = STRLEN("SYSLOG_RAW="); msg_raw = new(char, hlen + raw_len); if (!msg_raw) { diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c index 85558d9c05..bc7d00c3d0 100644 --- a/src/libsystemd/sd-bus/sd-bus.c +++ b/src/libsystemd/sd-bus/sd-bus.c @@ -1419,11 +1419,9 @@ int bus_set_address_system_remote(sd_bus *b, const char *host) { if (!in_charset(p, "0123456789") || *p == '\0') { if (!machine_name_is_valid(p) || got_forward_slash) return -EINVAL; - else { - m = p; - p = NULL; - goto interpret_port_as_machine_old_syntax; - } + + m = TAKE_PTR(p); + goto interpret_port_as_machine_old_syntax; } } diff --git a/src/test/test-hexdecoct.c b/src/test/test-hexdecoct.c index a972ddcef7..6e9b94b933 100644 --- a/src/test/test-hexdecoct.c +++ b/src/test/test-hexdecoct.c @@ -84,7 +84,7 @@ static void test_unhexmem_one(const char *s, size_t l, int retval) { l = strlen(s); assert_se(hex = hexmem(mem, len)); - answer = strndupa(s ?: "", l); + answer = strndupa(strempty(s), l); assert_se(streq(delete_chars(answer, WHITESPACE), hex)); } } |