From patchwork Thu Apr 28 08:09:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahisa Kojima X-Patchwork-Id: 567128 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:6886:0:0:0:0 with SMTP id m6csp5232552map; Thu, 28 Apr 2022 01:11:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9eSJjBhZG/0oJQGaKU5NGoGlDMq4ztxgJXUpt6UFoXmMK4+xtapqbwRLe3+ycawJCZpVF X-Received: by 2002:a17:907:94cd:b0:6f3:ce51:af98 with SMTP id dn13-20020a17090794cd00b006f3ce51af98mr5698136ejc.510.1651133493399; Thu, 28 Apr 2022 01:11:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651133493; cv=none; d=google.com; s=arc-20160816; b=LFzZykcARI6umdKzFnIASZuFviRLLwEuJwfM48btvUQUom41bL2Yo7/IfN+oUV4aXN 1B5EwCxvBxzaZfCiK4w9rkVFzhspsp+4Iz2a6YqgmWFdfGeh7gy72/r5Trv/sb8noWaK /zaYxf9AHlhabNFDWW1GtaraLQm1vBh5FsUlwOUwGKJjPe7J6nQNsTPs4C0I9R91MvaZ yq/xKj96gE/vxVFUNHm9lEFAH+NrIuOHUYKUAC6q0viYETlcBnObRkyq3B8YAfIQDkDX dYu68Kcb0qeZ0xTN8vbE0JuSJdFi0HIEdLVHO+O01b8UTpmRqofTwUiqZwStl5EFIb6O w3GQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=OWv4MTlDdTk2oATpKOKyZfwRbxZoAD1cLmsNm+lGX6Y=; b=hY0sk4/cEeAtqEU6HQHSmBJyoF7lDxl8kHeiKQd7rMqq+TjN/u7TdrnzqubXdkYgnK FFqBRH6XS/7RXfgLeTbJzNrCWREY8y0HVsHNDvo9efGhXm/X12hTIqlW9IVJ2UeCfHKp 76zFSNo6oZRfV5mzYDWAZ2VCfHuD9Xfxu9OQjgQ85wuk/ZfFochQM8ZIEzZmzbRaSc06 WqrUOUBm6696Q51CKLQTClIuqH6uVsLBpC3UKjzEObF74VhpAFGXFRS5R2QowENpZVo1 uYyWw/M2b6IOCvtvod6kGLw08Jnl4hHoB8q94faXct3gG73cs98ohBvvIqRb6fLoGxl8 dhHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="liw/ljnn"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id i25-20020a170906115900b006e86c3056c2si3214830eja.33.2022.04.28.01.11.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Apr 2022 01:11:33 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="liw/ljnn"; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id D77028393F; Thu, 28 Apr 2022 10:11:16 +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="liw/ljnn"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AA004802EF; Thu, 28 Apr 2022 10:10:52 +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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) (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 9C665802EF for ; Thu, 28 Apr 2022 10:10:48 +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=masahisa.kojima@linaro.org Received: by mail-pg1-x536.google.com with SMTP id z21so3393134pgj.1 for ; Thu, 28 Apr 2022 01:10:48 -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:in-reply-to:references; bh=OWv4MTlDdTk2oATpKOKyZfwRbxZoAD1cLmsNm+lGX6Y=; b=liw/ljnnmet52AvXUNyc1xxGmzsFsAxW1Dj7Fnd7LggnNtR5qlUAeYlegCPw6KJEbX kblIO6oXTuYUZr9IE5XdBZXEGzUMO9WqLQXlJZ/1/cs5rRFeEy3yiY+VbMBmWV78vNfD e10v2BM5I7dEqXc75i1yxFgbmLe0FpTYR3ajXgsdV5HUeAMkPNjCuarpQdbLGj6VHtaa dK4GZA19I/glcg5ZnoV69NTI1zpdJzbinGIxStcJGETvF4a4YKltSjS+yg1f0zpI82iX 3mSKUygDRXV5oEhaA6HnJK7S08aIuSr+JJPXLFrvtrNiUaCovhuc2sD/Aw1ZdwGZBPNB OX4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=OWv4MTlDdTk2oATpKOKyZfwRbxZoAD1cLmsNm+lGX6Y=; b=U7RoWOUYeYTB0h26yzMvWuGCCVferz3iYvvUKrvQP7dFSweFVFMVsLtGw/r9ceca5y h1HMEY3ux8sV1bd+IBj8Kck9E2rMtxH74id1bfJQuSfV6SqOhoT0EFCIFVJ3zzvTS3qN x3Jpk1UNQ14nMuwMsUPEgT0QZKQ7X+yzi5NBHj+tqBDykuIcC8r5moTkk/6sXJTrPMY7 664CblI7ufZZkMhlQeQVNRm9X5LSCorPExhoXgzTV15Cc9lB15Gn4ts4zblHtOH2bO2N +Mr2u5ypN7Hp+fBgyqZzLRr9VUD6Rhq5uxK5dISZWGSfxZkGjiaxH/u8z01AoHM0eH3/ HFZA== X-Gm-Message-State: AOAM531gdvPen2bJLraMt4qL6R77KV9XoGf+w/UL2DB2s9r4bP2I2LUT YOG2tYmFoySGi5ug7OxlZfT1uTq2ljfnPw== X-Received: by 2002:a63:2bc4:0:b0:3ab:1d76:64db with SMTP id r187-20020a632bc4000000b003ab1d7664dbmr18438212pgr.508.1651133446943; Thu, 28 Apr 2022 01:10:46 -0700 (PDT) Received: from localhost.localdomain ([240d:1a:cf7:5800:82fa:5bff:fe4b:26b1]) by smtp.gmail.com with ESMTPSA id b15-20020a17090a7acf00b001cd4989ff5fsm5684259pjl.38.2022.04.28.01.10.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Apr 2022 01:10:46 -0700 (PDT) From: Masahisa Kojima To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Takahiro Akashi , Francois Ozog , Mark Kettenis , Masahisa Kojima Subject: [PATCH v5 04/17] menu: menu_get_choice() return -ENOENT if menu item is empty Date: Thu, 28 Apr 2022 17:09:37 +0900 Message-Id: <20220428080950.23509-5-masahisa.kojima@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220428080950.23509-1-masahisa.kojima@linaro.org> References: <20220428080950.23509-1-masahisa.kojima@linaro.org> 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.5 at phobos.denx.de X-Virus-Status: Clean menu_get_choice() needs to handle the case that menu item is empty. In this case, menu_get_choice() returns -ENOENT. Signed-off-by: Masahisa Kojima --- Newly created in v5 common/menu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/menu.c b/common/menu.c index b577d80b4f..4118c6dc3c 100644 --- a/common/menu.c +++ b/common/menu.c @@ -271,6 +271,9 @@ int menu_get_choice(struct menu *m, void **choice) if (!m || !choice) return -EINVAL; + if (m->item_cnt == 0) + return -ENOENT; + if (!m->prompt) return menu_default_choice(m, choice);