]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
process-util: trivial cleanup for read_errno()
authorMike Yuan <me@yhndnzj.com>
Fri, 28 Nov 2025 18:50:35 +0000 (19:50 +0100)
committerMike Yuan <me@yhndnzj.com>
Sat, 20 Dec 2025 12:45:22 +0000 (13:45 +0100)
src/basic/process-util.c

index 50fa34c2e5d2357d6597671b6caa396f493700dd..c52084f625bef5da517c122dae7a28c9edb91f45 100644 (file)
@@ -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);
 }