From patchwork Fri May 8 05:51:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 245303 List-Id: U-Boot discussion From: takahiro.akashi at linaro.org (AKASHI Takahiro) Date: Fri, 8 May 2020 14:51:45 +0900 Subject: [PATCH] cmd: env: fix unreachable statements Message-ID: <20200508055145.7621-1-takahiro.akashi@linaro.org> C's switch statement takes an integer value for switching. As efi_status_t is defined as unsigned long and each error code has the top bit set, all "cases" cannot be reachable. Signed-off-by: AKASHI Takahiro Reported-by: Coverity (CID 300335) --- cmd/nvedit_efi.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/cmd/nvedit_efi.c b/cmd/nvedit_efi.c index 837e39e02179..84cba0c7324b 100644 --- a/cmd/nvedit_efi.c +++ b/cmd/nvedit_efi.c @@ -597,26 +597,18 @@ int do_env_set_efi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } else { const char *msg; - switch (ret) { - case EFI_NOT_FOUND: + if (ret == EFI_NOT_FOUND) msg = " (not found)"; - break; - case EFI_WRITE_PROTECTED: + else if (ret == EFI_WRITE_PROTECTED) msg = " (read only)"; - break; - case EFI_INVALID_PARAMETER: + else if (ret == EFI_INVALID_PARAMETER) msg = " (invalid parameter)"; - break; - case EFI_SECURITY_VIOLATION: + else if (ret == EFI_SECURITY_VIOLATION) msg = " (validation failed)"; - break; - case EFI_OUT_OF_RESOURCES: + else if (ret == EFI_OUT_OF_RESOURCES) msg = " (out of memory)"; - break; - default: + else msg = ""; - break; - } printf("## Failed to set EFI variable%s\n", msg); ret = CMD_RET_FAILURE; }