From patchwork Sun Dec 14 17:54:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 898 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=1765734921; bh=FPnBp/IpqoWKYzORi1WQN/+Gea82aYivjxpMPe/0G6g=; 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=RpGc/8IRrus6CSB194eo0Z5d9Lk9zZhsuVul1fE6juBtKuna6gxBWK37ST0gqhlxY 0KD2B6NoQcCzueUuWkQCnPlbbpEMltCqIrUh2uJSegLXdyZSe1zVbg3zCYxwaCjnQR W5NSCZzOkcd0x7NDKsj1T11viddQ1udU2/RTd3aJNpC/sPOpc7le8Fd/qS3aqBHwIw tWfnXaJ/W25XLfUPUHh+gXat4q8uh+kv4OwsIAh8YV9f8IYu+6VfOFoBJBdNAtsrYH He+LCPNQmmT3vYNiRFJB6gwzUSt5+GT1uS0rd25f7Mmk0F89Q3Foz+I54byNvNxehu C4yAvu6vgOtcw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C2D8568B0D for ; Sun, 14 Dec 2025 10:55:21 -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 qMaZLoqyAOx8 for ; Sun, 14 Dec 2025 10:55:21 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1765734919; bh=FPnBp/IpqoWKYzORi1WQN/+Gea82aYivjxpMPe/0G6g=; 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=Lnv1VfjY+ZixB7Uj/+LieZp7O/maecoUpVZPas7rLvcGhzhDEBrSpn1pITihps7m1 dCP845bu7uFgjL1J2apGNO09LiL8MtY42ePlSCUqg0L3PudceEKFUEOsX3T+x+mPZE h5YMwfHnK75RTWLFfDqfYK/YodCn6deHM7KkAKjJ5NMPJPkdfB5FZ/eq3OYtiHruPx m6br9vaLO3fduwcpyMmcaFZI+Q6l6MQD7vmCivCF0dRteWnUqdgC3K2TnS+GqaUcz0 +qKNTbavvhMmto7R9HJryFUpyhJWyb6akx0gWF/HPXNdVbWlvk5Xzr33uBmqm+2jV8 tabrZ5QJZmEcA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id BD3A668A89 for ; Sun, 14 Dec 2025 10:55:19 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1765734917; bh=zPT3aAXMWdnAy141YyXIDYVVv+e+Dxc7KKLc+aXnwHs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qjbei5KxMH9wyXcQSOuLNpFiNVnoPT0B5f2M5If3+5AL/pzHvQSA6lgIRDN4NgYzu 3NReqksgRY+I/rgw0Yvv7oPTuKer4NXAAMCClG5yVFfQg4Yb/mivXgMwLs43iuvVg2 bmPcgnwdscrtcCA2CiTMkYJKV2cOK1ujfXL2LBfpvxiuHentLszLBmnDw/oVWKUvce B7EQFSOwJi5+wGbcYLjH65HWSPI0T/ky+0JTEc66xdS5eKbRS36bRov2/YewKV1cQh UxhPcY6bJKxRZiaGZtSZXjnvJwqEzAEC42wisKsrhxgG5I/GORvlg7vAVsymoK+9lF y2R6X7zI2kiTg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CC50868AC0; Sun, 14 Dec 2025 10:55:17 -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 7mVuemQNAdob; Sun, 14 Dec 2025 10:55:17 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1765734912; bh=ba32JAVc0a3QNxPqYWzjXrAqD6PMJiSZmpGiBuKgGL8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JKjRO+lOCSi1rAKRVpa5zSNBhwYh+KAuw1P6ksfhN+POfBb1N4DvXk0DS6VjUk0Di T3dlX61VdHnKBHjrv+PGMA81LJPYfSGCRT8xUamQYWT0HdR5KZjXdPwb8Yf+oe2+rZ i7wnFCuPoESGDNiyA1RtvycyZip/l9+k16YUi3HE7QjPiskVXdLlVOWfq8Dos/tXhi CKJ32kVPuakFGDPByM3BZQV95nahbXKxUSajrA7zecYb/pZNyeLnbkxQENw1SwIXji 38cLu1VQJFx1fSE5GLYnc68AL2R4QPin+36UYgwzVqL7D+snFBuTzttyaLQO9Y6+EO SNpFjyBKQW0iA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 8566568A96; Sun, 14 Dec 2025 10:55:12 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sun, 14 Dec 2025 10:54:26 -0700 Message-ID: <20251214175449.3799539-5-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251214175449.3799539-1-sjg@u-boot.org> References: <20251214175449.3799539-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: NBMZRCV2FYWIW5LWKKRQIJUSDANIU5XZ X-Message-ID-Hash: NBMZRCV2FYWIW5LWKKRQIJUSDANIU5XZ 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 , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 04/21] doc: Expand printf documentation 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 Expand the printf format documentation to include information on all printf-style functions. Mention CONFIG depencies as well. Co-developed-by: Claude Signed-off-by: Simon Glass --- doc/develop/printf.rst | 80 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 70 insertions(+), 10 deletions(-) diff --git a/doc/develop/printf.rst b/doc/develop/printf.rst index 99d05061b14..4a0f054aae1 100644 --- a/doc/develop/printf.rst +++ b/doc/develop/printf.rst @@ -1,7 +1,62 @@ .. SPDX-License-Identifier: GPL-2.0+ -Printf() format codes -===================== +Printf-style Functions +====================== + +U-Boot provides a family of printf-style functions for formatted output. + +Functions +--------- + +printf() + Prints formatted output to the console. + + .. code-block:: c + + int printf(const char *fmt, ...); + +vprintf() + Like printf() but takes a va_list argument. + + .. code-block:: c + + int vprintf(const char *fmt, va_list args); + +sprintf() + Prints formatted output to a string buffer. The buffer must be large + enough to hold the output. + + .. code-block:: c + + int sprintf(char *buf, const char *fmt, ...); + +vsprintf() + Like sprintf() but takes a va_list argument. + + .. code-block:: c + + int vsprintf(char *buf, const char *fmt, va_list args); + +snprintf() + Prints formatted output to a string buffer with a size limit. At most + size-1 characters are written, and the buffer is always null-terminated. + Returns the number of characters that would have been written if the + buffer were large enough. + + .. code-block:: c + + int snprintf(char *buf, size_t size, const char *fmt, ...); + +vsnprintf() + Like snprintf() but takes a va_list argument. + + .. code-block:: c + + int vsnprintf(char *buf, size_t size, const char *fmt, va_list args); + + +Format Specification +-------------------- Each conversion specification consists of: @@ -166,10 +221,15 @@ Pointers * resource_size_t %pD - prints a UEFI device path + prints a UEFI device path (requires CONFIG_EFI_DEVICE_PATH_TO_TEXT) %pi4, %pI4 - prints IPv4 address, e.g. '192.168.0.1' + prints IPv4 address, e.g. '192.168.0.1'. Lower case (%pi4) omits the + dot separators. + +%pi6, %pI6 + prints IPv6 address (requires CONFIG_IPV6). Lower case (%pi6) omits the + colon separators. %pm prints MAC address without separators, e.g. '001122334455' @@ -178,22 +238,22 @@ Pointers print MAC address colon separated, e.g. '00:01:02:03:04:05' %pUb - prints GUID big endian, lower case + prints GUID big endian, lower case (requires CONFIG_LIB_UUID) e.g. '00112233-4455-6677-8899-aabbccddeeff' %pUB - prints GUID big endian, upper case + prints GUID big endian, upper case (requires CONFIG_LIB_UUID) e.g. '00112233-4455-6677-8899-AABBCCDDEEFF' %pUl - prints GUID little endian, lower case + prints GUID little endian, lower case (requires CONFIG_LIB_UUID) e.g. '33221100-5544-7766-8899-aabbccddeeff' %pUL - prints GUID little endian, upper case + prints GUID little endian, upper case (requires CONFIG_LIB_UUID) e.g. '33221100-5544-7766-8899-AABBCCDDEEFF' %pUs prints text description of a GUID or if such is not known little endian, - lower case, e.g. 'system' for a GUID identifying an EFI system - partition. + lower case (requires CONFIG_LIB_UUID), e.g. 'system' for a GUID + identifying an EFI system partition.