From: Mike Yuan Date: Fri, 28 Nov 2025 18:50:35 +0000 (+0100) Subject: process-util: trivial cleanup for read_errno() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3532691d72feb0b8861bf0320ec5aea442d67270;p=thirdparty%2Fsystemd.git process-util: trivial cleanup for read_errno() --- diff --git a/src/basic/process-util.c b/src/basic/process-util.c index 50fa34c2e5d..c52084f625b 100644 --- a/src/basic/process-util.c +++ b/src/basic/process-util.c @@ -2341,16 +2341,15 @@ int read_errno(int errno_fd) { log_debug_errno(n, "Failed to read errno: %m"); return -EIO; } - if (n == sizeof(r)) { - if (r == 0) - return 0; - if (r < 0) /* child process reported an error, return it */ - return log_debug_errno(r, "Child process failed with errno: %m"); - return log_debug_errno(SYNTHETIC_ERRNO(EIO), "Received an errno, but it's a positive value."); - } - if (n != 0) - return log_debug_errno(SYNTHETIC_ERRNO(EIO), "Received unexpected amount of bytes while reading errno."); + if (n == 0) /* the process exited without reporting an error, assuming success */ + return 0; + if (n != sizeof(r)) + return log_debug_errno(SYNTHETIC_ERRNO(EIO), "Received unexpected amount of bytes (%zi) while reading errno.", n); - /* the process exited without reporting an error, assuming success */ - return 0; + if (r == 0) + return 0; + if (r < 0) /* child process reported an error, return it */ + return log_debug_errno(r, "Child process failed with errno: %m"); + + return log_debug_errno(SYNTHETIC_ERRNO(EIO), "Received positive errno from child, refusing: %d", r); }