From: Dmitry V. Levin Date: Fri, 14 Jul 2023 08:00:00 +0000 (+0000) Subject: repart: cleanup use of ERRNO_IS_NOT_SUPPORTED() X-Git-Tag: v255-rc1~886^2~7 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6ce691c309644234e01541260e0ba3f87bd8ba4c;p=thirdparty%2Fsystemd.git repart: cleanup use of ERRNO_IS_NOT_SUPPORTED() 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. --- diff --git a/src/partition/repart.c b/src/partition/repart.c index f68918a7315..6c39ee804c2 100644 --- a/src/partition/repart.c +++ b/src/partition/repart.c @@ -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;