eal/windows: vfprintf build warning with clang
diff mbox series

Message ID 20201127120711.15703-1-nick.connolly@mayadata.io
State Superseded
Delegated to: Thomas Monjalon
Headers show
Series
  • eal/windows: vfprintf build warning with clang
Related show

Checks

Context Check Description
ci/travis-robot success Travis build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Nick Connolly Nov. 27, 2020, 12:07 p.m. UTC
When building with clang (11.0,--buildtype=debug), eal_lcore.c
produces a -Wformat-nonliteral warning from the vfprintf call
in log_early.

Disable the warning for log_early when building with clang.
MinGW does not seem to detect the warning.

Fixes: b8a36b086625 ("eal/windows: improve CPU and NUMA node detection")
Cc: stable@dpdk.org

Signed-off-by: Nick Connolly <nick.connolly@mayadata.io>
---
 lib/librte_eal/windows/eal_lcore.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Dmitry Kozlyuk Nov. 28, 2020, 9:11 p.m. UTC | #1
On Fri, 27 Nov 2020 12:07:11 +0000, Nick Connolly wrote:
> [...]
> +#ifdef __clang__
> +#pragma clang diagnostic push
> +#pragma clang diagnostic ignored "-Wformat-nonliteral"
> +#endif
> [...]

How about a more safe approach?

diff --git a/lib/librte_eal/windows/eal_lcore.c b/lib/librte_eal/windows/eal_lcore.c
index d5ff721e0..ebcd3474e 100644
--- a/lib/librte_eal/windows/eal_lcore.c
+++ b/lib/librte_eal/windows/eal_lcore.c
@@ -37,6 +37,7 @@ struct cpu_map {
 static struct cpu_map cpu_map = { 0 };
 
 /* eal_create_cpu_map() is called before logging is initialized */
+__rte_format_printf(1, 2)
 static void
 log_early(const char *format, ...)
 {
Nick Connolly Nov. 28, 2020, 10:46 p.m. UTC | #2
Looks good to me!

On 28/11/2020 21:11, Dmitry Kozlyuk wrote:
> On Fri, 27 Nov 2020 12:07:11 +0000, Nick Connolly wrote:
>> [...]
>> +#ifdef __clang__
>> +#pragma clang diagnostic push
>> +#pragma clang diagnostic ignored "-Wformat-nonliteral"
>> +#endif
>> [...]
> How about a more safe approach?
>
> diff --git a/lib/librte_eal/windows/eal_lcore.c b/lib/librte_eal/windows/eal_lcore.c
> index d5ff721e0..ebcd3474e 100644
> --- a/lib/librte_eal/windows/eal_lcore.c
> +++ b/lib/librte_eal/windows/eal_lcore.c
> @@ -37,6 +37,7 @@ struct cpu_map {
>   static struct cpu_map cpu_map = { 0 };
>   
>   /* eal_create_cpu_map() is called before logging is initialized */
> +__rte_format_printf(1, 2)
>   static void
>   log_early(const char *format, ...)
>   {

Patch
diff mbox series

diff --git a/lib/librte_eal/windows/eal_lcore.c b/lib/librte_eal/windows/eal_lcore.c
index d5ff721e0..d996b4f89 100644
--- a/lib/librte_eal/windows/eal_lcore.c
+++ b/lib/librte_eal/windows/eal_lcore.c
@@ -36,6 +36,11 @@  struct cpu_map {
 
 static struct cpu_map cpu_map = { 0 };
 
+#ifdef __clang__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wformat-nonliteral"
+#endif
+
 /* eal_create_cpu_map() is called before logging is initialized */
 static void
 log_early(const char *format, ...)
@@ -47,6 +52,10 @@  log_early(const char *format, ...)
 	va_end(va);
 }
 
+#ifdef __clang__
+#pragma clang diagnostic pop
+#endif
+
 int
 eal_create_cpu_map(void)
 {