From patchwork Thu May 16 21:11:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raymond Mao X-Patchwork-Id: 1936239 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; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=iMTTFsIX; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=patchwork.ozlabs.org) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VgN8v6w8Kz1ydW for ; Fri, 17 May 2024 07:12:47 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 01B2688485; Thu, 16 May 2024 23:12:44 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="iMTTFsIX"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 921B388481; Thu, 16 May 2024 23:12:42 +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,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) (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 605DB88483 for ; Thu, 16 May 2024 23:12:40 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=raymond.mao@linaro.org Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-5231efd80f2so1390889e87.2 for ; Thu, 16 May 2024 14:12:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1715893959; x=1716498759; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=BMLf5bzg1N4Kj7IW38T7Dw42nwEJ/O5BQjE5lMoLsZA=; b=iMTTFsIXA3ZqTsjlI/e/qo3NICgR2fobAyravUR+MCdn5joza3KHO2vunIG4uMw9GH f1f8m6tyUfiwTnxoERugUmX/T7N0eFVGWIUktxyw4r+Kx2WlySp7mIV9wkiwzVDy3zWx FFjGo2N8lO+xTqZZAoELs5vRQ0KkVqzuFAq02Tl9SdD5X1kaLTqxUfi3lN/xtl2y45CT EXcaowcmyLympi37ljLFdlx9gbr+S7cfdxyZyR/K5Zp2MEcnuoDBwpZf8RhxKhbk/Hdo bPT7p7T0Zhf9kdf/vfiIxFNY29VL1gOGDebUXs6y4XfxJQ5AQTfBDQAhImwESxLXvddv CbLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715893959; x=1716498759; 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:message-id:reply-to; bh=BMLf5bzg1N4Kj7IW38T7Dw42nwEJ/O5BQjE5lMoLsZA=; b=buk46PgVWbcEEiXP8/0xMBKrezc0XnpZtsRFH80fnJDOiUBV/kPKpTILLDDeuYRFRs fRMdABvDZnALF/4vevKSiIyzLuxfuXWzq2hW4XtcDwoezSv2eYIsY9uHJ0UxhFymV08X lvFBr8Ct8LB75O4BVEVxMdDTs5DbnD2R7frdPOn+4RhYrBPfP5DHH54OAD/IRQfFQM+e f1SkD5VLMzlTUiLEiOPvK1uYyuxICniRWv7vab0SoojRNxeApce1hezK2vKYnJ3g1i4X o8oFdc0P1iXiHrJsKATRTv5I4aMOYaKN3v6KWsYEyhf6shAIOQLVGwndzPyzDJL2df3d HL3A== X-Gm-Message-State: AOJu0YyxwljKd2r7CCFiLTGf6h5g+ulD1j+ClAu3gBeAmrEZTW4U0avY ejyb7wyHvZuuuifS0msyw6kqueqb9DsSQL4nR6DcSTkcMSLD7M8iehKj5tYGp+JqIAazQp+pR/J U X-Google-Smtp-Source: AGHT+IGkFGCjYIdTiPKVv/kVQJOvMuRk3aGra7JDR1cZe0CQppmLZGi0612V7xcAe5D5fqFPpnmTjg== X-Received: by 2002:a05:6512:3605:b0:51f:b781:729d with SMTP id 2adb3069b0e04-5220fd7acf5mr10817034e87.38.1715893959254; Thu, 16 May 2024 14:12:39 -0700 (PDT) Received: from ubuntu.localdomain ([149.14.240.163]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a5a179c7d09sm1021582266b.107.2024.05.16.14.12.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 May 2024 14:12:38 -0700 (PDT) From: Raymond Mao To: u-boot@lists.denx.de Cc: Raymond Mao , Alexey Brodkin , Eugeniy Paltsev , Tom Rini , Phil Sutter , Walter Schweizer , Tony Dinh , Mario Six , Heinrich Schuchardt , Ilias Apalodimas , Simon Glass , Jonathan Humphreys , Nishanth Menon , Roger Quadros , Igor Opaniuk , Marek Vasut , Bin Meng , Caleb Connolly , Masahisa Kojima , Eddie James , Jassi Brar , Michal Simek , Masami Hiramatsu , AKASHI Takahiro , Etienne Carriere , uboot-snps-arc@synopsys.com Subject: [PATCH v3 4/4] include: Move snprintf to stdio.h Date: Thu, 16 May 2024 14:11:52 -0700 Message-Id: <20240516211156.1819939-5-raymond.mao@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240516211156.1819939-1-raymond.mao@linaro.org> References: <20240516211156.1819939-1-raymond.mao@linaro.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.8 at phobos.denx.de X-Virus-Status: Clean Move snprintf to stdio.h since it is needed by exteranl libraries. Signed-off-by: Raymond Mao Reviewed-by: Tom Rini Reviewed-by: Ilias Apalodimas --- Changes in v2 - New patch. Changes in v3 - Move comments and attributes of snprintf. arch/arc/lib/cpu.c | 2 +- board/Synology/common/legacy.c | 1 + board/ti/common/fdt_ops.c | 2 +- cmd/part.c | 1 + common/button_cmd.c | 2 +- drivers/cpu/mpc83xx_cpu.c | 2 +- include/stdio.h | 17 +++++++++++++++++ include/vsprintf.h | 17 ----------------- lib/display_options.c | 1 + lib/fwu_updates/fwu_mtd.c | 2 +- lib/hexdump.c | 2 +- lib/vsprintf.c | 1 + test/dm/scmi.c | 2 +- test/print_ut.c | 1 + 14 files changed, 29 insertions(+), 24 deletions(-) diff --git a/arch/arc/lib/cpu.c b/arch/arc/lib/cpu.c index 593950449f2..269b4dbdd15 100644 --- a/arch/arc/lib/cpu.c +++ b/arch/arc/lib/cpu.c @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/board/Synology/common/legacy.c b/board/Synology/common/legacy.c index a0bace7b46c..2e3aa660eaa 100644 --- a/board/Synology/common/legacy.c +++ b/board/Synology/common/legacy.c @@ -6,6 +6,7 @@ */ #include +#include #include #include #include diff --git a/board/ti/common/fdt_ops.c b/board/ti/common/fdt_ops.c index eb917be9e0d..8a3300993ed 100644 --- a/board/ti/common/fdt_ops.c +++ b/board/ti/common/fdt_ops.c @@ -6,7 +6,7 @@ */ #include -#include +#include #include "fdt_ops.h" void ti_set_fdt_env(const char *board_name, struct ti_fdt_map *fdt_map) diff --git a/cmd/part.c b/cmd/part.c index d140a1eddb9..db7bc5819c0 100644 --- a/cmd/part.c +++ b/cmd/part.c @@ -19,6 +19,7 @@ #include #include #include +#include #include enum cmd_part_info { diff --git a/common/button_cmd.c b/common/button_cmd.c index 8642c26735c..72dac1f9ef6 100644 --- a/common/button_cmd.c +++ b/common/button_cmd.c @@ -8,7 +8,7 @@ #include #include #include -#include +#include /* Some sane limit "just in case" */ #define MAX_BTN_CMDS 32 diff --git a/drivers/cpu/mpc83xx_cpu.c b/drivers/cpu/mpc83xx_cpu.c index 9a7b5fd7c42..127d3c3af08 100644 --- a/drivers/cpu/mpc83xx_cpu.c +++ b/drivers/cpu/mpc83xx_cpu.c @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include "mpc83xx_cpu.h" diff --git a/include/stdio.h b/include/stdio.h index 3241e2d493f..7b999a519ba 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -46,6 +46,23 @@ static inline int vprintf(const char *fmt, va_list args) } #endif +/** + * Format a string and place it in a buffer + * + * @buf: The buffer to place the result into + * @size: The size of the buffer, including the trailing null space + * @fmt: The format string to use + * @...: Arguments for the format string + * Return: the number of characters which would be + * generated for the given input, excluding the trailing null, + * as per ISO C99. If the return is greater than or equal to + * @size, the resulting string is truncated. + * + * See the vsprintf() documentation for format string extensions over C99. + */ +int snprintf(char *buf, size_t size, const char *fmt, ...) + __attribute__ ((format (__printf__, 3, 4))); + /* * FILE based functions (can only be used AFTER relocation!) */ diff --git a/include/vsprintf.h b/include/vsprintf.h index ed8a060ee17..fe951471426 100644 --- a/include/vsprintf.h +++ b/include/vsprintf.h @@ -218,23 +218,6 @@ char *simple_itoa(ulong val); */ char *simple_xtoa(ulong num); -/** - * Format a string and place it in a buffer - * - * @buf: The buffer to place the result into - * @size: The size of the buffer, including the trailing null space - * @fmt: The format string to use - * @...: Arguments for the format string - * Return: the number of characters which would be - * generated for the given input, excluding the trailing null, - * as per ISO C99. If the return is greater than or equal to - * @size, the resulting string is truncated. - * - * See the vsprintf() documentation for format string extensions over C99. - */ -int snprintf(char *buf, size_t size, const char *fmt, ...) - __attribute__ ((format (__printf__, 3, 4))); - /** * Format a string and place it in a buffer * diff --git a/lib/display_options.c b/lib/display_options.c index d6b93553dcb..d5df53ab15f 100644 --- a/lib/display_options.c +++ b/lib/display_options.c @@ -12,6 +12,7 @@ #include #include #include +#include #include char *display_options_get_banner_priv(bool newlines, const char *build_tag, diff --git a/lib/fwu_updates/fwu_mtd.c b/lib/fwu_updates/fwu_mtd.c index 69cd3d7001f..4a52834b61a 100644 --- a/lib/fwu_updates/fwu_mtd.c +++ b/lib/fwu_updates/fwu_mtd.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include diff --git a/lib/hexdump.c b/lib/hexdump.c index 33e3e6e5182..2bc508ff504 100644 --- a/lib/hexdump.c +++ b/lib/hexdump.c @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include #include diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 27ea9c907a3..cfd1f1914ed 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include diff --git a/test/dm/scmi.c b/test/dm/scmi.c index 69fc900e342..c9a03523184 100644 --- a/test/dm/scmi.c +++ b/test/dm/scmi.c @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/test/print_ut.c b/test/print_ut.c index bded2b6ebe5..53d3354ea69 100644 --- a/test/print_ut.c +++ b/test/print_ut.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include