]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
repart: 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 arguments passed to ERRNO_IS_NOT_SUPPORTED() are the
values returned by efi_get_variable_string() and efi_set_variable()
which are not expected to return any positive values, but let's be
consistent anyway and move ERRNO_IS_NOT_SUPPORTED() invocations
to the branches where the return values are known to be negative.

src/partition/repart.c

index f68918a7315497da65816dcee539e549fc230473..6c39ee804c200734c82e9d22e49a54f1d2cb785d 100644 (file)
@@ -6484,10 +6484,11 @@ static int parse_efi_variable_factory_reset(void) {
                 return 0;
 
         r = efi_get_variable_string(EFI_SYSTEMD_VARIABLE(FactoryReset), &value);
-        if (r == -ENOENT || ERRNO_IS_NOT_SUPPORTED(r))
-                return 0;
-        if (r < 0)
+        if (r < 0) {
+                if (r == -ENOENT || ERRNO_IS_NOT_SUPPORTED(r))
+                        return 0;
                 return log_error_errno(r, "Failed to read EFI variable FactoryReset: %m");
+        }
 
         r = parse_boolean(value);
         if (r < 0)
@@ -6504,10 +6505,11 @@ static int remove_efi_variable_factory_reset(void) {
         int r;
 
         r = efi_set_variable(EFI_SYSTEMD_VARIABLE(FactoryReset), NULL, 0);
-        if (r == -ENOENT || ERRNO_IS_NOT_SUPPORTED(r))
-                return 0;
-        if (r < 0)
+        if (r < 0) {
+                if (r == -ENOENT || ERRNO_IS_NOT_SUPPORTED(r))
+                        return 0;
                 return log_error_errno(r, "Failed to remove EFI variable FactoryReset: %m");
+        }
 
         log_info("Successfully unset EFI variable FactoryReset.");
         return 0;