]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
varlink: cleanup use of ERRNO_IS_DISCONNECT()
authorDmitry V. Levin <ldv@strace.io>
Fri, 14 Jul 2023 08:00:00 +0000 (08:00 +0000)
committerDmitry V. Levin <ldv@strace.io>
Fri, 28 Jul 2023 12:28:35 +0000 (12:28 +0000)
Given that ERRNO_IS_DISCONNECT() 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_DISCONNECT() is the
value returned by varlink_connect_address() which is not expected to
return any positive values, but let's be consistent anyway and move
the ERRNO_IS_DISCONNECT() invocation to the branch where
the return value is known to be negative.

src/core/core-varlink.c

index aa4c047418ce676c21aedad8425fd0c9ec9b83ed..1ff4a93ccedfe3e5ec44ba4eca1334cca1bfdb80 100644 (file)
@@ -561,12 +561,13 @@ static int manager_varlink_init_user(Manager *m) {
                 return 0;
 
         r = varlink_connect_address(&link, VARLINK_ADDR_PATH_MANAGED_OOM_USER);
-        if (r == -ENOENT || ERRNO_IS_DISCONNECT(r)) {
-                log_debug("systemd-oomd varlink unix socket not found, skipping user manager varlink setup");
-                return 0;
-        }
-        if (r < 0)
+        if (r < 0) {
+                if (r == -ENOENT || ERRNO_IS_DISCONNECT(r)) {
+                        log_debug("systemd-oomd varlink unix socket not found, skipping user manager varlink setup");
+                        return 0;
+                }
                 return log_error_errno(r, "Failed to connect to %s: %m", VARLINK_ADDR_PATH_MANAGED_OOM_USER);
+        }
 
         varlink_set_userdata(link, m);