From patchwork Fri Sep 9 15:17:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1676111 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=KvlqxTdt; 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 ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MPKQk74Jhz1yhP for ; Sat, 10 Sep 2022 01:19:10 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3251684B77; Fri, 9 Sep 2022 17:18:52 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org 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=chromium.org header.i=@chromium.org header.b="KvlqxTdt"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 859C584B82; Fri, 9 Sep 2022 17:18:47 +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,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-oa1-x2c.google.com (mail-oa1-x2c.google.com [IPv6:2001:4860:4864:20::2c]) (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 5E8ED84B3D for ; Fri, 9 Sep 2022 17:18:43 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-oa1-x2c.google.com with SMTP id 586e51a60fabf-1225219ee46so4730017fac.2 for ; Fri, 09 Sep 2022 08:18:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=VNe4tmjEGFXaGzBnvHV94dSSr/8AwTj558ksztO0f24=; b=KvlqxTdtryBGu7Swk+0C/4WgWIlxFJ4t6UiZR17HDSJLUwqlZp1a5wC2450DAmKlgu ozJE/rVzwXq3+HWSDUUkeNCEXULHG1MFJEGBcrkcFAOQpYiWJ3CXOZ2LYh90f9D5DBGA CVjCQtWjV2YooH7KrAzVmqDGRdUK4sWr4W4NY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=VNe4tmjEGFXaGzBnvHV94dSSr/8AwTj558ksztO0f24=; b=cCiDv8N5W9eTefICbGZ8WfRTzn2F9iSFu6rRYmaDIqkRTwhwAzgD0L4yLk9PzLuUNl XvfhBkrsEwyWa0Ks1dHVfl1StwZV+ERPLHMnFi3oH45+CKdL3jkIXlLn0QU+gd3u61MN Z08wUezQ7no/7rMMXlVfMZwVnFMRmkBbC1WvncQmoW7hDWxAemP8JLR57+VTOI+kfTgj s0VEkz/JK1P0ShWgELtArNLsy3D8F0QSfD20ptj+/7lh07TSEmzTFH/lSfPvPiegT8gW WlvGfhbjSQ9DuD6QjFdVfHhFhjE5ot3YvJY0u0tFaOkNhQbXekr6fVj5DJNn1YpRnhtq 8NKQ== X-Gm-Message-State: ACgBeo2m8ufvMtf9Z/YkIdwF0n6HG91X/XHorhTd0mro96hVmylAt33I 47lK8A2xfm4NyxdUOertqBTWEpzNK2Mj9g== X-Google-Smtp-Source: AA6agR6ukAbCc4nk9QtpyEZfZur9n9UGbb7TUTwAplzVZdjvHft3jhM+ZSV93xrTSIqdtM9VjrUukA== X-Received: by 2002:a05:6808:bce:b0:344:f245:8a22 with SMTP id o14-20020a0568080bce00b00344f2458a22mr3957682oik.203.1662736721594; Fri, 09 Sep 2022 08:18:41 -0700 (PDT) Received: from sjg1.roam.corp.google.com (c-67-190-102-125.hsd1.co.comcast.net. [67.190.102.125]) by smtp.gmail.com with ESMTPSA id eq22-20020a056870a91600b0012779ba00fesm591977oab.2.2022.09.09.08.18.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Sep 2022 08:18:41 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Simon Glass , Patrick Delaunay , Philippe Reynes , Stefan Roese Subject: [PATCH 03/14] bootm: Avoid returning error codes from command Date: Fri, 9 Sep 2022 09:17:50 -0600 Message-Id: <20220909151801.336551-4-sjg@chromium.org> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog In-Reply-To: <20220909151801.336551-1-sjg@chromium.org> References: <20220909151801.336551-1-sjg@chromium.org> MIME-Version: 1.0 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.6 at phobos.denx.de X-Virus-Status: Clean Functions which implement commands must return a CMD_RET_... error code. At present bootm can return a negative errno value in some cases, thus causing strange behaviour such as trying to exit the shell and printing usage information. Fix this by returning the correct value. Signed-off-by: Simon Glass --- cmd/bootm.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cmd/bootm.c b/cmd/bootm.c index d764a27002d..f09b41c2c16 100644 --- a/cmd/bootm.c +++ b/cmd/bootm.c @@ -111,7 +111,7 @@ static int do_bootm_subcommand(struct cmd_tbl *cmdtp, int flag, int argc, bootm_get_addr(argc, argv) + image_load_offset); #endif - return ret; + return ret ? CMD_RET_FAILURE : 0; } /*******************************************************************/ @@ -120,6 +120,8 @@ static int do_bootm_subcommand(struct cmd_tbl *cmdtp, int flag, int argc, int do_bootm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { + int ret; + #ifdef CONFIG_NEEDS_MANUAL_RELOC static int relocated = 0; @@ -152,7 +154,7 @@ int do_bootm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) return do_bootm_subcommand(cmdtp, flag, argc, argv); } - return do_bootm_states(cmdtp, flag, argc, argv, BOOTM_STATE_START | + ret = do_bootm_states(cmdtp, flag, argc, argv, BOOTM_STATE_START | BOOTM_STATE_FINDOS | BOOTM_STATE_PRE_LOAD | BOOTM_STATE_FINDOTHER | BOOTM_STATE_LOADOS | #ifdef CONFIG_SYS_BOOT_RAMDISK_HIGH @@ -163,6 +165,8 @@ int do_bootm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) #endif BOOTM_STATE_OS_PREP | BOOTM_STATE_OS_FAKE_GO | BOOTM_STATE_OS_GO, &images, 1); + + return ret ? CMD_RET_FAILURE : 0; } int bootm_maybe_autostart(struct cmd_tbl *cmdtp, const char *cmd)