diff mbox series

[v2,4/4] include: Move snprintf to stdio.h

Message ID 20240515123213.1701691-5-raymond.mao@linaro.org
State Changes Requested
Delegated to: Tom Rini
Headers show
Series Clean-up patch set for MbedTLS integration | expand

Commit Message

Raymond Mao May 15, 2024, 12:31 p.m. UTC
Move snprintf to stdio.h since it is needed by exteranl libraries.

Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
---
Changes in v2
- New patch.

 arch/arc/lib/cpu.c             |  2 +-
 board/Synology/common/legacy.c |  1 +
 board/ti/common/fdt_ops.c      |  2 +-
 cmd/part.c                     |  2 +-
 common/button_cmd.c            |  2 +-
 drivers/cpu/mpc83xx_cpu.c      |  2 +-
 include/stdio.h                |  1 +
 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, 13 insertions(+), 25 deletions(-)

Comments

Tom Rini May 15, 2024, 2:37 p.m. UTC | #1
On Wed, May 15, 2024 at 05:31:59AM -0700, Raymond Mao wrote:

> Move snprintf to stdio.h since it is needed by exteranl libraries.
> 
> Signed-off-by: Raymond Mao <raymond.mao@linaro.org>

Thanks for doing the work. One problem:

> diff --git a/include/stdio.h b/include/stdio.h
> index 3241e2d493f..ecd0f996efb 100644
> --- a/include/stdio.h
> +++ b/include/stdio.h
> @@ -45,6 +45,7 @@ static inline int vprintf(const char *fmt, va_list args)
>  	return 0;
>  }
>  #endif
> +int snprintf(char *buf, size_t size, const char *fmt, ...);
>  
>  /*
>   * 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
>   *

Please move the whole thing, comment and attributes over not just the
basic prototype, thanks.
diff mbox series

Patch

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 <clock_legacy.h>
 #include <init.h>
 #include <malloc.h>
-#include <vsprintf.h>
+#include <stdio.h>
 #include <asm/arcregs.h>
 #include <asm/cache.h>
 #include <asm/global_data.h>
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 <config.h>
+#include <stdio.h>
 #include <vsprintf.h>
 #include <env.h>
 #include <net.h>
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 <env.h>
-#include <vsprintf.h>
+#include <stdio.h>
 #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 c75f85acd52..b1c06064ad5 100644
--- a/cmd/part.c
+++ b/cmd/part.c
@@ -20,7 +20,7 @@ 
 #include <command.h>
 #include <env.h>
 #include <part.h>
-#include <vsprintf.h>
+#include <stdio.h>
 
 enum cmd_part_info {
 	CMD_PART_INFO_START = 0,
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 <command.h>
 #include <env.h>
 #include <log.h>
-#include <vsprintf.h>
+#include <stdio.h>
 
 /* 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 e451c11116a..5b2d0485258 100644
--- a/drivers/cpu/mpc83xx_cpu.c
+++ b/drivers/cpu/mpc83xx_cpu.c
@@ -10,7 +10,7 @@ 
 #include <cpu.h>
 #include <dm.h>
 #include <log.h>
-#include <vsprintf.h>
+#include <stdio.h>
 #include <linux/bitops.h>
 
 #include "mpc83xx_cpu.h"
diff --git a/include/stdio.h b/include/stdio.h
index 3241e2d493f..ecd0f996efb 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -45,6 +45,7 @@  static inline int vprintf(const char *fmt, va_list args)
 	return 0;
 }
 #endif
+int snprintf(char *buf, size_t size, const char *fmt, ...);
 
 /*
  * 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 <linux/ctype.h>
 #include <linux/kernel.h>
 #include <asm/io.h>
+#include <stdio.h>
 #include <vsprintf.h>
 
 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 <malloc.h>
 #include <mtd.h>
 #include <uuid.h>
-#include <vsprintf.h>
+#include <stdio.h>
 
 #include <dm/ofnode.h>
 
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 <hexdump.h>
 #include <mapmem.h>
-#include <vsprintf.h>
+#include <stdio.h>
 #include <linux/ctype.h>
 #include <linux/compat.h>
 #include <linux/log2.h>
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 <hexdump.h>
 #include <stdarg.h>
 #include <uuid.h>
+#include <stdio.h>
 #include <vsprintf.h>
 #include <linux/ctype.h>
 #include <linux/err.h>
diff --git a/test/dm/scmi.c b/test/dm/scmi.c
index adf36ffaab1..a03824ab653 100644
--- a/test/dm/scmi.c
+++ b/test/dm/scmi.c
@@ -19,7 +19,7 @@ 
 #include <scmi_agent.h>
 #include <scmi_agent-uclass.h>
 #include <scmi_protocols.h>
-#include <vsprintf.h>
+#include <stdio.h>
 #include <asm/scmi_test.h>
 #include <dm/device-internal.h>
 #include <dm/test.h>
diff --git a/test/print_ut.c b/test/print_ut.c
index bb844d2542b..a0d6a551203 100644
--- a/test/print_ut.c
+++ b/test/print_ut.c
@@ -10,6 +10,7 @@ 
 #include <log.h>
 #include <mapmem.h>
 #include <version_string.h>
+#include <stdio.h>
 #include <vsprintf.h>
 #include <test/suites.h>
 #include <test/test.h>