coredumpctl: 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 access_fd() 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:
Dmitry V. Levin
2023-07-28 12:28:35 +00:00
parent 5cf4c468a4
commit f5d6b78666
+8 -7
View File
@@ -483,14 +483,15 @@ static void analyze_coredump_file(
r = -errno;
} else
r = access_fd(fd, R_OK);
if (ERRNO_IS_PRIVILEGE(r)) {
*ret_state = "inaccessible";
*ret_color = ansi_highlight_yellow();
*ret_size = UINT64_MAX;
return;
}
if (r < 0)
if (r < 0) {
if (ERRNO_IS_PRIVILEGE(r)) {
*ret_state = "inaccessible";
*ret_color = ansi_highlight_yellow();
*ret_size = UINT64_MAX;
return;
}
goto error;
}
if (fstat(fd, &st) < 0)
goto error;