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: 1285832 X-Patchwork-Delegate: xypron.glpk@gmx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=AnmKKhBh; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49JKGR2jhkz9sRY for ; Fri, 8 May 2020 15:51:59 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B4F1981D1A; Fri, 8 May 2020 07:51:56 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="AnmKKhBh"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1BBD381D24; Fri, 8 May 2020 07:51:55 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,SPF_HELO_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 7082281CD3 for ; Fri, 8 May 2020 07:51:52 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=takahiro.akashi@linaro.org Received: by mail-pj1-x1043.google.com with SMTP id js4so1718889pjb.5 for ; Thu, 07 May 2020 22:51:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=iEky+eaNpBpPdDQ2o0NVvAB11vCLvofsP0lEXyUiLTw=; b=AnmKKhBhZSaJhpwu0HQPOICuI9GMsdcvl1p6i61dKwQzm4aKQE8rlqJsCOXgUKsliF t7T7CoP+G+sJj/ARvxOw5xTxsQXmE4rNOde8bVmoXvFIAUkPp10T/bENeR2jR1M7r8S0 4H0zvNjFy/Fv9QgBkrs/iCgG2ApcI0gk3fH31afFKElFelwnLh4y7O6GN5dcf/GDu1T+ xlLNnl8bsfaAOdp+qocipukMeE4+mjDz1/8IrS1DveDjUkR/WzymW7alXmAFAaP47dcA nPZ1CXRYBjngTVyagQh8X5BaaguQmrdsPr4hqjqN+kk1YOBjPxK2b2VctTKcEp1Mjbgl ns3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=iEky+eaNpBpPdDQ2o0NVvAB11vCLvofsP0lEXyUiLTw=; b=oybbGwRZtYCL3Y0l61SBl61lokpKNzudvRLIlIY+tR8QpnU3S06YvXufMYGjyrCfOQ PAoaSH0cJsASj6o4xj+XF65wI0Ry18V+1du5L0bYlI+ZSH949KGmVQbqAoxGAZmJF4G1 EGbAmjlR1ahMAUSoVHJZd6voq07uS6AfGJlGwU5N4gz3O6gahbblt7tMAH2De6Q32Sis BDw2wVUSt5ZxoCWV5QyKJqT8C06Jq/LGWl4fxp/saFU3sO1Nbcs9ajBmMYWbLlbdObP9 VaKruG7+3dlohzucWxSmQ09WZsb9DAnX3zkKVzxu6pbqzHt2Kj0RNbTyXD6t+YTozyYa QJpg== X-Gm-Message-State: AGi0PuYu2oDVogbYXCAhJBHD8bMbzNTxzGQgJPyafa7+SEw4ogDPJrTZ V5F2puD+b8by+lH2/VBsRt+VsvpQQD4= X-Google-Smtp-Source: APiQypKPrVTda5ZKgNY780FRpDzOPoqXvfUJd5JsVVBVhvMIwar9FedNCxUFomO6RnaAIphhzHX7uA== X-Received: by 2002:a17:90b:b07:: with SMTP id bf7mr4200239pjb.231.1588917111016; Thu, 07 May 2020 22:51:51 -0700 (PDT) Received: from localhost.localdomain (p784a560f.tkyea130.ap.so-net.ne.jp. [120.74.86.15]) by smtp.gmail.com with ESMTPSA id v7sm573368pfm.146.2020.05.07.22.51.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2020 22:51:50 -0700 (PDT) From: AKASHI Takahiro To: xypron.glpk@gmx.de, agraf@csgraf.de, trini@konsulko.com Cc: u-boot@lists.denx.de, AKASHI Takahiro Subject: [PATCH] cmd: env: fix unreachable statements Date: Fri, 8 May 2020 14:51:45 +0900 Message-Id: <20200508055145.7621-1-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.25.2 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean 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; }