From patchwork Wed Feb 4 00:09:47 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1797 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=1770163831; bh=eS5JbmmEuuJjNUM9mY7nYwRBnAFJFYEbhLOvafhy1vs=; 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=vcxa8WPxMSzxC2KNgcBBBaozSN8UvtLs2DdYMyFUiiLQwW/+/326isAjcvTLbjAtm MnGr0fw/9+99bEzxpQKhQBFlaA7/7H0ZkE8d2IzgtX8gVy8a9Os6tqx6l6tj5ET8de TsOFVak9mKsrj433e0U8zqrHZkubKM+ECl3rWr5hHdT6EIKrTW7BQhZCv0iKHI/mVK kGUH9Ok1pKqcCuyBjVCEsUQTml3xtxi3yHbFRjfD71f4OrTGwPXYK5lwhEMXNaoXbK GEGswBkYJGeO/nU52WdhAZJhPRX90KWRlCXdmVFRvEkeC1GsixlCXhzpQezOFL6cbL /IbXt6BTTampg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CC2276991C for ; Tue, 3 Feb 2026 17:10: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 6QDyDHDRXjPm for ; Tue, 3 Feb 2026 17:10:31 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163831; bh=eS5JbmmEuuJjNUM9mY7nYwRBnAFJFYEbhLOvafhy1vs=; 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=vcxa8WPxMSzxC2KNgcBBBaozSN8UvtLs2DdYMyFUiiLQwW/+/326isAjcvTLbjAtm MnGr0fw/9+99bEzxpQKhQBFlaA7/7H0ZkE8d2IzgtX8gVy8a9Os6tqx6l6tj5ET8de TsOFVak9mKsrj433e0U8zqrHZkubKM+ECl3rWr5hHdT6EIKrTW7BQhZCv0iKHI/mVK kGUH9Ok1pKqcCuyBjVCEsUQTml3xtxi3yHbFRjfD71f4OrTGwPXYK5lwhEMXNaoXbK GEGswBkYJGeO/nU52WdhAZJhPRX90KWRlCXdmVFRvEkeC1GsixlCXhzpQezOFL6cbL /IbXt6BTTampg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id BBDF369911 for ; Tue, 3 Feb 2026 17:10:31 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163829; bh=weWBGBOUleNlM23R4zAHTj9CEuUd6GK7JlrXXdhz6pI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jg8UDnMVEw2XuTJGsIyan/5PzPG1Fh/g1vxbGnUWTg932yZtpKYvAfRvf2WcV5L4i tOFh1TmZ6vT7F/0p/BPlYzN6CsGuQd66Pghm3pob2XYIR7VxH4e09RoekjWPkxZpa+ gTW//nAsSjIfw6+1RodrhV5TB1kPGqhRsltErxI3h+93xxfioMTQtCjnvvIv5OKZT0 sPahhWoV9qbwaSkoR6sMXVR59UCOJBlslPbRyQvvvcjd4VADlGEFoKF1K8nwj5MVsQ u6uGkebLx9pfOINuLKvZ+aIlB2t46k6BpFnb4xQgV8eMNue3/jcpdJ9wHGxhFuPgyL XJlVvpJnA7wbw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 93F2C69868; Tue, 3 Feb 2026 17:10:29 -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 escAFRaM8nbo; Tue, 3 Feb 2026 17:10:29 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1770163825; bh=gRdQHD+TRJVOT6p8ydWZG3Ov/qCaRXLwBAX/2uPesyA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dicbreWjm+GZ868ZqJ/jEz6CER6snGjNSNmEIb0Z62IXwVrKBNQxctwvDkxntfA47 s8iZHTJbT3NOe0vGvul1iByKyrVGK+qjREFdrYi146MvYA9sjE1USNXmorrVnu/u+1 0BLRLEtUwfCfja4GBYQhycWQke4R85utqeyCypybRdN1T/6c8iWd6k9CetFvbQS8w1 106mfWkPFSlQ024GuqGp7QCxVsRnhFN4QT38r5XsumhowNABtdXd39EzW4102B4LLm 8lekeMl6y7+bRkIEc+pURnWXCk0XEgsz1SqKh7rFVPXyOCDKCMVUQqQrqWRZ0pJ4ys 7qeQB4uxaf8bg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 4A58669909; Tue, 3 Feb 2026 17:10:25 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 3 Feb 2026 17:09:47 -0700 Message-ID: <20260204001002.2638622-4-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260204001002.2638622-1-sjg@u-boot.org> References: <20260204001002.2638622-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 5ASO3NIGZFK7SN3L56BC3XFDKQIWSNJF X-Message-ID-Hash: 5ASO3NIGZFK7SN3L56BC3XFDKQIWSNJF 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 Sonnet 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 03/13] console: Add length-based console-recording support 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 Console recording uses membuf_put() which already supports length-based writes. Add console_record_putsn() to accept a length parameter directly instead of calling strlen() internally. Refactor console_record_puts() to use console_record_putsn() to reduce code duplication. Since console recording is a size-increasing feature for testing, this refactoring is appropriate. This provides the foundation for a public putsn() API that can output strings without requiring nul-termination. Co-developed-by: Claude Sonnet 4.5 Signed-off-by: Simon Glass --- common/console.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/common/console.c b/common/console.c index 6ce2c4d361d..581c383ce5e 100644 --- a/common/console.c +++ b/common/console.c @@ -43,12 +43,11 @@ static void console_record_putc(const char c) } } -static void console_record_puts(const char *s) +static void console_record_putsn(const char *s, int len) { if (!(gd->flags & GD_FLG_RECORD)) return; if (gd->console_out.start) { - int len = strlen(s); int written; written = membuf_put((struct membuf *)&gd->console_out, s, len); @@ -59,6 +58,11 @@ static void console_record_puts(const char *s) } } +static void console_record_puts(const char *s) +{ + console_record_putsn(s, strlen(s)); +} + static int console_record_getc(void) { if (!(gd->flags & GD_FLG_RECORD)) @@ -84,6 +88,10 @@ static void console_record_putc(char c) { } +static void __maybe_unused console_record_putsn(const char *s, int len) +{ +} + static void console_record_puts(const char *s) { }