eal/windows: vfprintf build warning with clang
Checks
Commit Message
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
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, ...)
{
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, ...)
> {
@@ -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)
{