From patchwork Mon Aug 25 16:27:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 134 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756139277; bh=i3vjmQQ3LRBIcGyr85IQEr1BwrUVaHoIDt/POA2Br84=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=BeHxzsh+kUzSEtVPz0y5b2wNfGXLoB62wQ6KrztogvoyUYMbQGXWIRiNqmCcA1SdO l4ALm4wn45SU4U7Anj+2VlfYZR1cWovbjOBD9UBre4JppnZ02v+TKbzawW3HLkPzG0 ZaN/zetrjWKSqJKGpadiOhwWh5JvHH8ocpn0s0h+2HAKymA9kWmYcI+X4usBuG1dvf LDYa1Tq0kupBOWwMMkTHV6a4OmgaNnhmiNy30kvE5hA2j7IoL1AbETW/60xM05Lwg5 Mjhi54h3lrJ6zux1QHTQ4e63x3f2mZsFO8zm1jdVLrLzn69t+uhiLqrzThM+8O3QNU MLxxbxKRviwIg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8D14A67787 for ; Mon, 25 Aug 2025 10:27:57 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id KuDzpvyz8f0n for ; Mon, 25 Aug 2025 10:27:57 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756139275; bh=i3vjmQQ3LRBIcGyr85IQEr1BwrUVaHoIDt/POA2Br84=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=sNNO36+xsbBTRMMMO/dPrJ/arGHlx7iU++pWX+vLGBfTTv1UfM1Bg3ERcKuCsIkJv VSJCgf0s/R0l87Fg80K6WHHcx9u2kL7NHUwDHAjBjm5pT6CHjshQPwiivVtvpgcZxv UEsHtGdb9iE3ja+i9rG7wZ8KjxJCqV+BWoM61A2t7gV+li0Hyj/7phxeKOCK+sIH71 vxc1kASZXrRwzFmfQB4xcpMC3fx+oMQ79d4ojxN3TNbVLPYLviG48crR7F6KpmbDkX iSgNz63Fswj6kC5znbTtGFwNv7iifAVxEz/CM2KdncyjAHRf1IdFhvipPk2GqpULPR e4rtKGIXaf97Q== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 910DA67797 for ; Mon, 25 Aug 2025 10:27:55 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756139274; bh=4F4AHenRyjfietUgw5++60rDpnc+2I9s3bq5aIzg3mQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aoy94orOpo4+Q+SVCYMlNg8Mrk+tXfjOMw4/rUCNb0SAO1mK/cvA0Tgg6HsLLeaOm 1MjDtgyWtPfDD/0umXwxFZOCokPKxfXKHRipNb5JEYNrcBzMzjBZA3IQyWYzYSswji TxpSocNy+DZOZdTQvgG077RCEBVNHB9JTikGhRq39BphE0dERRSmel52TgEGqbj9au WBRrtHzf4HsFqPVCnPOtnM7xQd2SNrTT8+EzMkov02S6JONgGOu1akQJfPsIsLO7If BgUgPLtqViajdyF0q5RpHBmLpEt6Fh7N62HvHEXPF8G55lmZarLWl7O/QxJsBYXcGu tnK1+08s+NtMw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 37CAF677AB; Mon, 25 Aug 2025 10:27:54 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id kKKAE2u9kdKh; Mon, 25 Aug 2025 10:27:54 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1756139269; bh=krnolbIxkZabNFG3p8c7i7dojqG4WX+yYL5VUY+lq/Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AY9no7fKLnIXaPMTDDirpubwuworO5/M0gB4kpySj0UMkICjfYA44jOfujrhdrV9a OJlRwYJpCQKpxIe8U4OTu2F89HiW7ARwwAJE/7RdSJzi4LCJPXjl+8ugs0OEHqPf1Z BssThbyi3mqNyPyTYY+HCjU7DPsjsXiveKR7Fs4p0QU/s5UEI/Xdz4njGnqr7R2k/m RSCDfXnZ57YvGHruZ1faziitGUnchtkNlNg2GzxsFr+fUWraOs6kDorrXHvR0UN7+d 2YOSRnEq8J9MNoEgFFhnYxQiAgdSG3uDLf9yQB5ZM7OvMgj8d0pFOCfjQB6CWlDiub ESYKdaBvq9Qng== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 03AC967797; Mon, 25 Aug 2025 10:27:48 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 25 Aug 2025 10:27:16 -0600 Message-ID: <20250825162727.3185381-14-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250825162727.3185381-1-sjg@u-boot.org> References: <20250825162727.3185381-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: DP2TQSHH5Q6ZHS2QVTL56NUKMVBEKPNW X-Message-ID-Hash: DP2TQSHH5Q6ZHS2QVTL56NUKMVBEKPNW X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH v2 13/16] console: Refactor handling of the result in on_console() List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass This function has lots of return statements in a switch statement. Move them out so we can (later) do something else in this function. Signed-off-by: Simon Glass --- Changes in v2: - Add new patch to refactor handling of the result in on_console() common/console.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/common/console.c b/common/console.c index 51f646d9fd4..e986fa0f3e5 100644 --- a/common/console.c +++ b/common/console.c @@ -1040,6 +1040,7 @@ static int on_console(const char *name, const char *value, enum env_op op, int flags) { int console = -1; + int result = 0; /* Check for console redirection */ if (strcmp(name, "stdin") == 0) @@ -1056,26 +1057,25 @@ static int on_console(const char *name, const char *value, enum env_op op, switch (op) { case env_op_create: case env_op_overwrite: - if (CONFIG_IS_ENABLED(CONSOLE_MUX)) { if (iomux_doenv(console, value)) - return 1; + result = 1; } else { /* Try assigning specified device */ if (console_assign(console, value) < 0) - return 1; + result = 1; } - - return 0; - + break; case env_op_delete: if ((flags & H_FORCE) == 0) printf("Can't delete \"%s\"\n", name); - return 1; - + result = 1; + break; default: - return 0; + break; } + + return result; } U_BOOT_ENV_CALLBACK(console, on_console);