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.
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)
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;