From f5d6b78666ad6013a4903956fb81a435659e7914 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Fri, 14 Jul 2023 08:00:00 +0000 Subject: [PATCH] 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. --- src/coredump/coredumpctl.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/coredump/coredumpctl.c b/src/coredump/coredumpctl.c index e34d74765e5..16abb8f62ae 100644 --- a/src/coredump/coredumpctl.c +++ b/src/coredump/coredumpctl.c @@ -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; -- 2.47.3