tree-wide: some automatic coccinelle fixes (#10463)
Nothing fancy, just coccinelle doing its work.
This commit is contained in:
parent
a4544f53c4
commit
490c5a37cb
|
@ -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();
|
||||
|
|
|
@ -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++;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue