From patchwork Sun Jan 18 20:42:42 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1594 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=1768769011; bh=GPrYKAOcHzuZzLwe1ypejuje0mP1OOWbYcFbUCNalZM=; 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=eUfsd+Czte+KpLExr2Leaf7HDtQcJsSixwpoxjjTnc75EAFgc4F3DLwK+41ooUR15 9eweHuS4Lc2wYnfbJ02jbGHiqizk9xGrPHIUWzaXvT5XNt+nieZ0xQpK2kGApBCyr+ BefmmOGNi9dlzADrpKExJKuoqMgGuIK3baJIEzyYkCDKPDPhdPH980XHvV69Kjzfah 6pXDT4cwuUECcl1OwCyu+ZuLB5iVFhcPsVSs909mnpNqSpytYhCMsfDk0/NObwIS+c kSZ9nXMPHDs5vrJnPu/zFrg7L/pXD9KT64eX5fTBMSBgqVZFz4pKCCgEOG8e+fHsWw p+rEI2qaewBrA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A511B69494 for ; Sun, 18 Jan 2026 13:43:31 -0700 (MST) 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 9MEuBZXt7F9v for ; Sun, 18 Jan 2026 13:43:31 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769011; bh=GPrYKAOcHzuZzLwe1ypejuje0mP1OOWbYcFbUCNalZM=; 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=eUfsd+Czte+KpLExr2Leaf7HDtQcJsSixwpoxjjTnc75EAFgc4F3DLwK+41ooUR15 9eweHuS4Lc2wYnfbJ02jbGHiqizk9xGrPHIUWzaXvT5XNt+nieZ0xQpK2kGApBCyr+ BefmmOGNi9dlzADrpKExJKuoqMgGuIK3baJIEzyYkCDKPDPhdPH980XHvV69Kjzfah 6pXDT4cwuUECcl1OwCyu+ZuLB5iVFhcPsVSs909mnpNqSpytYhCMsfDk0/NObwIS+c kSZ9nXMPHDs5vrJnPu/zFrg7L/pXD9KT64eX5fTBMSBgqVZFz4pKCCgEOG8e+fHsWw p+rEI2qaewBrA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9525B6948C for ; Sun, 18 Jan 2026 13:43:31 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769010; bh=B36VLoSvw92uzsyUr32DyBGqWOoe/+fkUUoO0CqGSeQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kPEuizCklMI8Qoy8EWIdWZ8VsOH9wUmc+egMDx1h+9NEAwGOxhZ2+L7WlAewF1kl4 Yh/cUepeWJOZ8Jdig5Z31KWc+Xq9LR+8yeOAYJb8ns5azTdc9RSFOYaipouKcEikjo W8No7rGjDTycZLycFZvOqi+wUy/69hcl2IXgIYpZEujLP573yHrtZjUEWTv0VmNpXb wbh/bRPYYBwRdecYj+aoPtxLY49bF6ZZ/70Lqjfajn41nf4au0lD0vTxh43hG4smIz 6VJWHcbpnmhmh2JBO//7ZT9ctynmB9GSmGY6LRQhAXZOQBqXWwGiODmMaZZ9zIt2bK U7azs6NHP5Wxg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9FF046948C; Sun, 18 Jan 2026 13:43:30 -0700 (MST) 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 JRSErmgAEyPn; Sun, 18 Jan 2026 13:43:30 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768769006; bh=p2r0S4f0pzDBFwPTU/3+s83nCLu3gADvx4iidP9n240=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IRDo7oRRGn2HW8Zdy4HS5uyf+DC8g02C0qmTZsz3iKPPPnp5YpOzlKjjYvbfMaaAf 2EJoOVuJChBDuvn0iTQuLJIA26LD1jDNNWaSS8FIYmqID7ejePGlsidIzxTRNEr68Y n+Ur2EJZnE+q8+RBYqAt/vTN957AggT79Hz5QdFaXAVBt8MoCZSTqpVzSYbhAPVxKb Q8hWrUolFaEYX4GBn98YmH2tFqs5p9556t57ec0ppiG0WjqjGEkLDRL8pDR32StKF6 79NZw+cZ0GbwiisTrvSrINSLpSjc1eRQ7oo4nBPpqN0kg8U+pw73WzqdPcGxKFR6rE wrYdAry1Tb3RA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id B04EB69394; Sun, 18 Jan 2026 13:43:25 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sun, 18 Jan 2026 13:42:42 -0700 Message-ID: <20260118204303.1982533-4-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260118204303.1982533-1-sjg@u-boot.org> References: <20260118204303.1982533-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 44KH5FV546CF4Y6ODZ675KAG6ZTDB6NP X-Message-ID-Hash: 44KH5FV546CF4Y6ODZ675KAG6ZTDB6NP 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: Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 03/16] cli: Convert ERASE_TO_EOL macro to a function 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 Convert the ERASE_TO_EOL macro to cread_erase_to_eol() function. This reduces code size by 71 bytes since the function is called from three places. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- common/cli_readline.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/common/cli_readline.c b/common/cli_readline.c index 81b0688da38..2e41aa5afef 100644 --- a/common/cli_readline.c +++ b/common/cli_readline.c @@ -232,13 +232,14 @@ void cread_print_hist_list(void) } \ } -#define ERASE_TO_EOL() { \ - if (cls->num < cls->eol_num) { \ - printf("%*s", (int)(cls->eol_num - cls->num), ""); \ - do { \ - cls_putch(cls, CTL_BACKSPACE); \ - } while (--cls->eol_num > cls->num); \ - } \ +static void cread_erase_to_eol(struct cli_line_state *cls) +{ + if (cls->num < cls->eol_num) { + printf("%*s", (int)(cls->eol_num - cls->num), ""); + do { + cls_putch(cls, CTL_BACKSPACE); + } while (--cls->eol_num > cls->num); + } } #define REFRESH_TO_EOL() { \ @@ -344,7 +345,7 @@ int cread_line_process_ch(struct cli_line_state *cls, char ichar) } break; case CTL_CH('k'): - ERASE_TO_EOL(); + cread_erase_to_eol(cls); break; case CTL_CH('e'): REFRESH_TO_EOL(); @@ -378,7 +379,7 @@ int cread_line_process_ch(struct cli_line_state *cls, char ichar) case CTL_CH('x'): case CTL_CH('u'): BEGINNING_OF_LINE(); - ERASE_TO_EOL(); + cread_erase_to_eol(cls); break; case DEL: case DEL7: @@ -418,7 +419,7 @@ int cread_line_process_ch(struct cli_line_state *cls, char ichar) BEGINNING_OF_LINE(); /* erase to end of line */ - ERASE_TO_EOL(); + cread_erase_to_eol(cls); /* copy new line into place and display */ strcpy(buf, hline);