summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFrantisek Sumsal <frantisek@sumsal.cz>2021-07-09 13:15:01 +0200
committerLuca Boccassi <luca.boccassi@gmail.com>2021-07-09 20:54:22 +0100
commit2f0927626abf6ac6c99a42c1c7fa159063bfc8ee (patch)
tree5ae1a49a9023f7e4e00177f390c9c4a25b06858e /src
parent0de0ba573b9c0070b0280300c42111a5b0d7e655 (diff)
downloadsystemd-2f0927626abf6ac6c99a42c1c7fa159063bfc8ee.tar.gz
tree-wide: coccinelle fixes
Yet another batch of Coccinelle fixes.
Diffstat (limited to 'src')
-rw-r--r--src/basic/efivars.c2
-rw-r--r--src/basic/time-util.c4
-rw-r--r--src/creds/creds.c6
-rw-r--r--src/libsystemd-network/sd-dhcp-client.c2
-rw-r--r--src/nspawn/nspawn-bind-user.c4
-rw-r--r--src/nspawn/nspawn.c2
-rw-r--r--src/portable/portable.c6
7 files changed, 11 insertions, 15 deletions
diff --git a/src/basic/efivars.c b/src/basic/efivars.c
index 032ae6f9a1..77d969c635 100644
--- a/src/basic/efivars.c
+++ b/src/basic/efivars.c
@@ -382,7 +382,7 @@ int systemd_efi_options_efivarfs_if_newer(char **line) {
return log_debug_errno(errno, "Failed to stat EFI variable SystemdOptions: %m");
if (stat(EFIVAR_CACHE_PATH(EFI_SYSTEMD_VARIABLE(SystemdOptions)), &b) < 0) {
- if (errno != -ENOENT)
+ if (errno != ENOENT)
log_debug_errno(errno, "Failed to stat "EFIVAR_CACHE_PATH(EFI_SYSTEMD_VARIABLE(SystemdOptions))": %m");
} else if (compare_stat_mtime(&a, &b) > 0)
log_debug("Variable SystemdOptions in evifarfs is newer than in cache.");
diff --git a/src/basic/time-util.c b/src/basic/time-util.c
index 5d162e8ffe..0a4fcdcd13 100644
--- a/src/basic/time-util.c
+++ b/src/basic/time-util.c
@@ -1334,10 +1334,10 @@ static int get_timezones_from_tzdata_zi(char ***ret) {
continue;
char *tz;
- if (*type == 'Z' || *type == 'z')
+ if (IN_SET(*type, 'Z', 'z'))
/* Zone lines have timezone in field 1. */
tz = f1;
- else if (*type == 'L' || *type == 'l')
+ else if (IN_SET(*type, 'L', 'l'))
/* Link lines have timezone in field 2. */
tz = f2;
else
diff --git a/src/creds/creds.c b/src/creds/creds.c
index 50de685cd4..b58faf6589 100644
--- a/src/creds/creds.c
+++ b/src/creds/creds.c
@@ -362,7 +362,7 @@ static int verb_encrypt(int argc, char **argv, void *userdata) {
assert(argc == 3);
- input_path = (isempty(argv[1]) || streq(argv[1], "-")) ? NULL : argv[1];
+ input_path = empty_or_dash(argv[1]) ? NULL : argv[1];
if (input_path)
r = read_full_file_full(AT_FDCWD, input_path, UINT64_MAX, CREDENTIAL_SIZE_MAX, READ_FULL_FILE_SECURE|READ_FULL_FILE_FAIL_WHEN_LARGER, NULL, &plaintext, &plaintext_size);
@@ -373,7 +373,7 @@ static int verb_encrypt(int argc, char **argv, void *userdata) {
if (r < 0)
return log_error_errno(r, "Failed to read plaintext: %m");
- output_path = (isempty(argv[2]) || streq(argv[2], "-")) ? NULL : argv[2];
+ output_path = empty_or_dash(argv[2]) ? NULL : argv[2];
if (arg_name_any)
name = NULL;
@@ -455,7 +455,7 @@ static int verb_decrypt(int argc, char **argv, void *userdata) {
assert(IN_SET(argc, 2, 3));
- input_path = (isempty(argv[1]) || streq(argv[1], "-")) ? NULL : argv[1];
+ input_path = empty_or_dash(argv[1]) ? NULL : argv[1];
if (input_path)
r = read_full_file_full(AT_FDCWD, argv[1], UINT64_MAX, CREDENTIAL_ENCRYPTED_SIZE_MAX, READ_FULL_FILE_UNBASE64|READ_FULL_FILE_FAIL_WHEN_LARGER, NULL, &input, &input_size);
diff --git a/src/libsystemd-network/sd-dhcp-client.c b/src/libsystemd-network/sd-dhcp-client.c
index dc8ff19d1a..3c8c440771 100644
--- a/src/libsystemd-network/sd-dhcp-client.c
+++ b/src/libsystemd-network/sd-dhcp-client.c
@@ -238,7 +238,7 @@ int sd_dhcp_client_set_callback(
int sd_dhcp_client_set_request_broadcast(sd_dhcp_client *client, int broadcast) {
assert_return(client, -EINVAL);
- client->request_broadcast = !!broadcast;
+ client->request_broadcast = broadcast;
return 0;
}
diff --git a/src/nspawn/nspawn-bind-user.c b/src/nspawn/nspawn-bind-user.c
index 6852125b9d..3250cd9768 100644
--- a/src/nspawn/nspawn-bind-user.c
+++ b/src/nspawn/nspawn-bind-user.c
@@ -171,10 +171,8 @@ static int find_free_uid(const char *directory, uid_t max_uid, uid_t *current_ui
/* We want to use the UID also as GID, hence check for it in /etc/group too */
r = check_etc_group_collisions(directory, NULL, (gid_t) *current_uid);
- if (r < 0)
+ if (r <= 0)
return r;
- if (r == 0) /* free! yay! */
- return 0;
}
}
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index 04685fecba..3cc028b55b 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -4091,7 +4091,7 @@ static int make_uid_map_string(
int r;
assert(n_bind_user_uid == 0 || bind_user_uid);
- assert(offset == 0 || offset == 2); /* used to switch between UID and GID map */
+ assert(IN_SET(offset, 0, 2)); /* used to switch between UID and GID map */
assert(ret);
/* The bind_user_uid[] array is a series of 4 uid_t values, for each --bind-user= entry one
diff --git a/src/portable/portable.c b/src/portable/portable.c
index 4cf5fb4f0a..5afb008bb8 100644
--- a/src/portable/portable.c
+++ b/src/portable/portable.c
@@ -86,10 +86,8 @@ static PortableMetadata *portable_metadata_new(const char *name, const char *pat
/* In case of a layered attach, we want to remember which image the unit came from */
if (path) {
m->image_path = strdup(path);
- if (!m->image_path) {
- free(m);
- return NULL;
- }
+ if (!m->image_path)
+ return mfree(m);
}
strcpy(m->name, name);