]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
logind: cleanup use of ERRNO_IS_NOT_SUPPORTED()
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_NOT_SUPPORTED() 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_NOT_SUPPORTED() is the
value returned by efi_loader_get_entries() which is not expected to
return any positive values, but let's be consistent anyway and move
the ERRNO_IS_NOT_SUPPORTED() invocation to the branch where
the return value is known to be negative.

src/login/logind-core.c

index af86e92c016ef9a6dd6b9cd3f2bbf798ef3c990e..e7f1d6c8e4eac98f918b37d52e4ed173f49c2a82 100644 (file)
@@ -828,13 +828,14 @@ int manager_read_efi_boot_loader_entries(Manager *m) {
                 return 0;
 
         r = efi_loader_get_entries(&m->efi_boot_loader_entries);
-        if (r == -ENOENT || ERRNO_IS_NOT_SUPPORTED(r)) {
-                log_debug_errno(r, "Boot loader reported no entries.");
-                m->efi_boot_loader_entries_set = true;
-                return 0;
-        }
-        if (r < 0)
+        if (r < 0) {
+                if (r == -ENOENT || ERRNO_IS_NOT_SUPPORTED(r)) {
+                        log_debug_errno(r, "Boot loader reported no entries.");
+                        m->efi_boot_loader_entries_set = true;
+                        return 0;
+                }
                 return log_error_errno(r, "Failed to determine entries reported by boot loader: %m");
+        }
 
         m->efi_boot_loader_entries_set = true;
         return 1;