Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 447D4C76196 for ; Thu, 6 Apr 2023 14:03:46 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C5F3286027; Thu, 6 Apr 2023 16:03:43 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=konsulko.com header.i=@konsulko.com header.b="smd/WRE6"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7B9BB8603F; Thu, 6 Apr 2023 16:03:42 +0200 (CEST) Received: from mail-yw1-x1132.google.com (mail-yw1-x1132.google.com [IPv6:2607:f8b0:4864:20::1132]) (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 3D2D780A29 for ; Thu, 6 Apr 2023 16:03:36 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=konsulko.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=trini@konsulko.com Received: by mail-yw1-x1132.google.com with SMTP id 00721157ae682-54bfa5e698eso74924937b3.13 for ; Thu, 06 Apr 2023 07:03:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=konsulko.com; s=google; t=1680789815; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=1rN6RLxyVevYkcx0aBGvDOpyKGHKUcEde7ujffe80xc=; b=smd/WRE6fEdEDUQ5KV+D4LgU/a39fC7UGah10U5Gr8qXS55k+5psRqNci8EHd3oc/R 6gFk2Xo7+rYPQHYF8ln1qDN3ef8c+uq/i7ekStM++nzZQoMVdJQSzGVXTlt+0A4L4mRh r93g6a5pLAxj7GBPL61PheZ3xD1Dm/DUqsJSk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680789815; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=1rN6RLxyVevYkcx0aBGvDOpyKGHKUcEde7ujffe80xc=; b=R89cYPvBGnVTXxTA6ALGcBkTPKahxbhr3L97yUbAZafp/JNrdUboBBYyFwFBDi8u6E IfOa8BiFCEklOHQlq2s0xsqikwPUWcR+Sz8PZl3PePRvRAZjNbkelVQaa+qKkhwltV/i P1pXJIpKGAmEl1kk+ezhBfQaiJx0CJfqXtSreepMZ1wrf0aEJ2+4MtFCfZB18wAWY15Q Aa7J7PY632nRb8iEPLUpc9ipm7Q6IVRWcNxYYCIm/b9I3oP6J9YMsWFAD5JSLKBCif4P 4fo0DEwTurovngiGxTNCsHlW8wYswYwsN+K29zV9LEJh0mPKShcAI09PXoS80WS9t148 LwQA== X-Gm-Message-State: AAQBX9dfMidPEz1Sn+Y3N0eGjVYTVBHrPb5+kjs4/Snq2aa/sV1AeQ/c 0GOaJio5+cfrw2n5i/lx/42ks/dr59+Tx1pT5WXqdA== X-Google-Smtp-Source: AKy350YrKQ/HZbiRgOdJUcd6W84GdzERzJym399qs9Ei1dNGJIGK+FKrlO6S87UZl/hdmI8THEMQUQ== X-Received: by 2002:a81:7cc1:0:b0:54c:1e9e:9033 with SMTP id x184-20020a817cc1000000b0054c1e9e9033mr551862ywc.22.1680789814847; Thu, 06 Apr 2023 07:03:34 -0700 (PDT) Received: from bill-the-cat.lan (2603-6081-7b00-6400-acff-1005-f218-7c24.res6.spectrum.com. [2603:6081:7b00:6400:acff:1005:f218:7c24]) by smtp.gmail.com with ESMTPSA id bg27-20020a05690c031b00b005460251b0d9sm82527ywb.82.2023.04.06.07.03.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Apr 2023 07:03:34 -0700 (PDT) From: Tom Rini To: u-boot@lists.denx.de Cc: Simon Glass Subject: [PATCH] bootflow: Rework do_bootflow_menu() slightly Date: Thu, 6 Apr 2023 10:03:33 -0400 Message-Id: <20230406140333.1529863-1-trini@konsulko.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean When building this with clang, we get a warning such as: cmd/bootflow.c:412:27: warning: variable 'bflow' is uninitialized when used here [-Wuninitialized] printf("Selected: %s\n", bflow->os_name ? bflow->os_name : bflow->name); ^~~~~ And a suggestion to just initialize bflow to NULL. This would however would be ensuring a bad dereference. Instead, looking at the function we rework things so that when CONFIG_EXPO is not enabled (and so, no UI) we error early and would never reach this point in the code. Simplify the rest slightly as well while at this. Signed-off-by: Tom Rini --- Cc: Simon Glass --- cmd/bootflow.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/cmd/bootflow.c b/cmd/bootflow.c index 42f6e14a4370..2c3889a6f0de 100644 --- a/cmd/bootflow.c +++ b/cmd/bootflow.c @@ -387,6 +387,11 @@ static int do_bootflow_menu(struct cmd_tbl *cmdtp, int flag, int argc, bool text_mode = false; int ret; + if (!IS_ENABLED(CONFIG_EXPO)) { + printf("Menu not supported\n"); + return CMD_RET_FAILURE; + } + if (argc > 1 && *argv[1] == '-') text_mode = strchr(argv[1], 't'); @@ -394,20 +399,15 @@ static int do_bootflow_menu(struct cmd_tbl *cmdtp, int flag, int argc, if (ret) return CMD_RET_FAILURE; - if (IS_ENABLED(CONFIG_EXPO)) { - ret = bootflow_menu_run(std, text_mode, &bflow); - if (ret) { - if (ret == -EAGAIN) - printf("Nothing chosen\n"); - else - printf("Menu failed (err=%d)\n", ret); + ret = bootflow_menu_run(std, text_mode, &bflow); + if (ret) { + if (ret == -EAGAIN) + printf("Nothing chosen\n"); + else { + printf("Menu failed (err=%d)\n", ret); + return CMD_RET_FAILURE; } - } else { - printf("Menu not supported\n"); - ret = -ENOSYS; } - if (ret) - return CMD_RET_FAILURE; printf("Selected: %s\n", bflow->os_name ? bflow->os_name : bflow->name); std->cur_bootflow = bflow; -- 2.34.1