eal/windows: vfprintf build warning with clang
PATCH 1/1 eal/windows: vfprintf build warning with clang
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.
--- lib/librte_eal/windows/eal_lcore.c | 9 +++++++++ 1 file changed, 9 insertions(+)
lib/librte_eal/windows/eal_lcore.c +9 -0
@@ -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 ) {
Signature · 1 line
2.25.1
Review
Quoted 6 lines · Nick Connolly
[...]
(quoted diff) +4
-0+#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wformat-nonliteral" +#endif
How about a more safe approach?
lib/librte_eal/windows/eal_lcore.c +1 -0
@@ -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!
Quoted 21 lines · Dmitry Kozlyuk
Review
Quoted 6 lines · Nick Connolly
[...]
(quoted diff) +4
-0+#ifdef __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wformat-nonliteral" +#endifHow about a more safe approach?
lib/librte_eal/windows/eal_lcore.c +1
-0@@ -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 v2 1/1 eal/windows: vfprintf build warning with clang
In reply to Nick ConnollyWhen building with clang (11.0,--buildtype=debug), eal_lcore.c produces a -Wformat-nonliteral warning from the vfprintf call in log_early.
Add __rte_format_printf annotation.
---
v2:
* Use __rte_format_printf instead of disabling the warning
lib/librte_eal/windows/eal_lcore.c | 1 + 1 file changed, 1 insertion(+)
lib/librte_eal/windows/eal_lcore.c +1 -0
@@ -38,6 +38,7 @@ static struct cpu_map cpu_map = { 0 };/* eal_create_cpu_map() is called before logging is initialized */ static void +__rte_format_printf(1, 2) log_early(const char *format, ...) { va_list va;
Signature · 1 line
2.25.1
Quoted 23 lines · Nick Connolly
When building with clang (11.0,--buildtype=debug),
eal_lcore.cproduces a -Wformat-nonliteral warning from the vfprintf call inlog_early.Add
__rte_format_printfannotation.Fixes b8a36b086625 ("eal/windows: improve CPU and NUMA node detection")Signed-off-by Nick Connolly <[email protected]>Suggested-by Dmitry Kozlyuk <[email protected]>---
v2:
* Use__rte_format_printfinstead of disabling the warninglib/librte_eal/windows/eal_lcore.c | 1 + 1 file changed, 1 insertion(+)lib/librte_eal/windows/eal_lcore.c +0
-0
lib/librte_eal/windows/eal_lcore.c static struct cpu_map cpu_map = { 0 }; · line 44
Quoted 7 lines
lib/librte_eal/windows/eal_lcore.c +1
-0@@ -38,6 +38,7 @@ static struct cpu_map cpu_map = { 0 };/* eal_create_cpu_map() is called before logging is initialized */ static void +__rte_format_printf(1, 2) log_early(const char *format, ...) { va_list va;
Thomas Monjalon
Applied29/11/2020 14:42, Dmitry Kozlyuk:
Quoted 7 lines · Nick Connolly
Quoted 6 lines
When building with clang (11.0,--buildtype=debug),
eal_lcore.cproduces a -Wformat-nonliteral warning from the vfprintf call inlog_early.Add
__rte_format_printfannotation.
Quoted 7 lines
Quoted 5 lines
Fixes b8a36b086625 ("eal/windows: improve CPU and NUMA node detection")Signed-off-by Nick Connolly <[email protected]>Suggested-by Dmitry Kozlyuk <[email protected]>Acked-by Dmitry Kozlyuk <[email protected]>
Applied, thanks
Quoted 4 lines · Nick Connolly
When building with clang (11.0,--buildtype=debug),
eal_lcore.cproduces a -Wformat-nonliteral warning from the vfprintf call inlog_early.
Quoted 8 lines
Add
__rte_format_printfannotation.Fixes b8a36b086625 ("eal/windows: improve CPU and NUMA node detection")Signed-off-by Nick Connolly <[email protected]>Suggested-by Dmitry Kozlyuk <[email protected]>---