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.
This commit is contained in:
+16
-14
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user