From: Dmitry V. Levin Date: Fri, 14 Jul 2023 08:00:00 +0000 (+0000) Subject: coredumpctl: cleanup use of ERRNO_IS_PRIVILEGE() X-Git-Tag: v255-rc1~886^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f5d6b78666ad6013a4903956fb81a435659e7914;p=thirdparty%2Fsystemd.git 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. --- 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;