summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDmitry V. Levin <ldv@strace.io>2023-07-14 10:00:00 +0200
committerDmitry V. Levin <ldv@strace.io>2023-07-28 14:28:35 +0200
commit7a0b6d312b42b488b79117066fc3859bea4e8164 (patch)
tree2d884b15128c49e88b2f2c7b6a79a8b30f3e6538 /src
parentcoredumpctl: cleanup use of ERRNO_IS_PRIVILEGE() (diff)
downloadsystemd-7a0b6d312b42b488b79117066fc3859bea4e8164.tar.xz
systemd-7a0b6d312b42b488b79117066fc3859bea4e8164.zip
userdb: cleanup use of ERRNO_IS_PRIVILEGE()
Given that ERRNO_IS_PRIVILEGE() also matches positive values, make sure this macro is not called with arguments that do not have errno semantics. In this case the argument passed to ERRNO_IS_PRIVILEGE() is the value returned by json_parse_file() which is not expected to return any positive values, but let's be consistent anyway and move the ERRNO_IS_PRIVILEGE() invocation to the branch where the return value is known to be negative.
Diffstat (limited to '')
-rw-r--r--src/shared/userdb-dropin.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/shared/userdb-dropin.c b/src/shared/userdb-dropin.c
index 5d79f4688a..309f33b5b5 100644
--- a/src/shared/userdb-dropin.c
+++ b/src/shared/userdb-dropin.c
@@ -57,13 +57,14 @@ static int load_user(
}
r = json_parse_file(NULL, j, JSON_PARSE_SENSITIVE, &privileged_v, NULL, NULL);
- if (ERRNO_IS_PRIVILEGE(r))
- have_privileged = false;
- else if (r == -ENOENT)
- have_privileged = true; /* if the privileged file doesn't exist, we are complete */
- else if (r < 0)
- return r;
- else {
+ if (r < 0) {
+ if (ERRNO_IS_PRIVILEGE(r))
+ have_privileged = false;
+ else if (r == -ENOENT)
+ have_privileged = true; /* if the privileged file doesn't exist, we are complete */
+ else
+ return r;
+ } else {
r = json_variant_merge(&v, privileged_v);
if (r < 0)
return r;
@@ -201,13 +202,14 @@ static int load_group(
}
r = json_parse_file(NULL, j, JSON_PARSE_SENSITIVE, &privileged_v, NULL, NULL);
- if (ERRNO_IS_PRIVILEGE(r))
- have_privileged = false;
- else if (r == -ENOENT)
- have_privileged = true; /* if the privileged file doesn't exist, we are complete */
- else if (r < 0)
- return r;
- else {
+ if (r < 0) {
+ if (ERRNO_IS_PRIVILEGE(r))
+ have_privileged = false;
+ else if (r == -ENOENT)
+ have_privileged = true; /* if the privileged file doesn't exist, we are complete */
+ else
+ return r;
+ } else {
r = json_variant_merge(&v, privileged_v);
if (r < 0)
return r;