]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
bootctl: 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/boot/bootctl-status.c

index 0f2e9204b7a51428aea52b6cbf01f5203e0ca536..65f351031d733caaccf1e6e9a029fa289ece7dfe 100644 (file)
@@ -43,11 +43,12 @@ static int boot_config_load_and_select(
                 _cleanup_strv_free_ char **efi_entries = NULL;
 
                 r = efi_loader_get_entries(&efi_entries);
-                if (r == -ENOENT || ERRNO_IS_NOT_SUPPORTED(r))
-                        log_debug_errno(r, "Boot loader reported no entries.");
-                else if (r < 0)
-                        log_warning_errno(r, "Failed to determine entries reported by boot loader, ignoring: %m");
-                else
+                if (r < 0) {
+                        if (r == -ENOENT || ERRNO_IS_NOT_SUPPORTED(r))
+                                log_debug_errno(r, "Boot loader reported no entries.");
+                        else
+                                log_warning_errno(r, "Failed to determine entries reported by boot loader, ignoring: %m");
+                } else
                         (void) boot_config_augment_from_loader(config, efi_entries, /* only_auto= */ false);
         }