examples/rxtx_callbacks: fix port ID format specifier
PATCH 1/1 examples/rxtx_callbacks: fix port ID format specifier
Use "%u" and a cast as in other places when port ID is formatted. This fixes -Wformat warning with clang 10.0.0 on Windows.
--- examples/rxtx_callbacks/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
examples/rxtx_callbacks/main.c +2 -2
@@ -329,8 +329,8 @@ main(int argc, char *argv[])/* initialize all ports */ RTE_ETH_FOREACH_DEV(portid) if (port_init(portid, mbuf_pool) != 0) - rte_exit(EXIT_FAILURE, "Cannot init port %"PRIu8"\n", - portid); + rte_exit(EXIT_FAILURE, "Cannot init port %u\n", + (unsigned int)portid);if (rte_lcore_count () >1 ) printf("\nWARNING: Too much enabled lcores - "
Signature · 1 line
2.29.3
Quoted 16 lines · Dmitry Kozlyuk
Use "%u" and a cast as in other places when port ID is formatted. This fixes -Wformat warning with clang 10.0.0 on Windows.
Fixes f8244c6399d9 ("ethdev: increase port id range")Signed-off-by Dmitry Kozlyuk <[email protected]>--- examples/rxtx_callbacks/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)examples/rxtx_callbacks/main.c +0
-0
examples/rxtx_callbacks/main.c main(int argc, char *argv[]) · line 333
Quoted 5 lines
examples/rxtx_callbacks/main.c +0
-2@@ -329,8 +329,8 @@ main(int argc, char *argv[])/* initialize all ports */ RTE_ETH_FOREACH_DEV (portid) if (port_init(portid, mbuf_pool) != 0) - rte_exit(EXIT_FAILURE, "Cannot init port %"PRIu8"\n", - portid);
how come not just `% " PRIu16 "\n"' ?
what was the -Wformat clang on windows complaint?
2021-05-03 17:11 (UTC-0700), Tyler Retzlaff:
Quoted 25 lines · Dmitry Kozlyuk
Quoted 16 lines
Use "%u" and a cast as in other places when port ID is formatted. This fixes -Wformat warning with clang 10.0.0 on Windows.
Fixes f8244c6399d9 ("ethdev: increase port id range")Signed-off-by Dmitry Kozlyuk <[email protected]>--- examples/rxtx_callbacks/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)examples/rxtx_callbacks/main.c +0
-0examples/rxtx_callbacks/main.c main(int argc, char *argv[]) · line 333
Quoted 5 lines
examples/rxtx_callbacks/main.c +0
-2@@ -329,8 +329,8 @@ main(int argc, char *argv[])/* initialize all ports */ RTE_ETH_FOREACH_DEV (portid) if (port_init(portid, mbuf_pool) != 0) - rte_exit(EXIT_FAILURE, "Cannot init port %"PRIu8"\n", - portid);how come not just `% " PRIu16 "\n"' ?
Quoted 1 line
what was the -Wformat clang on windows complaint?
PRIx16 would work, but I noticed that in other places where port ID is printed, the pattern above is used. IMO uniform approach is better.
Tyler Retzlaff
Acked-byQuoted 26 lines · Dmitry Kozlyuk
2021-05-03 17:11 (UTC-0700), Tyler Retzlaff:
Quoted 25 lines · Dmitry Kozlyuk
Quoted 16 lines
Use "%u" and a cast as in other places when port ID is formatted. This fixes -Wformat warning with clang 10.0.0 on Windows.
Fixes f8244c6399d9 ("ethdev: increase port id range")Signed-off-by Dmitry Kozlyuk <[email protected]>--- examples/rxtx_callbacks/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)examples/rxtx_callbacks/main.c +0
-0examples/rxtx_callbacks/main.c main(int argc, char *argv[]) · line 333
Quoted 5 lines
examples/rxtx_callbacks/main.c +0
-2@@ -329,8 +329,8 @@ main(int argc, char *argv[])/* initialize all ports */ RTE_ETH_FOREACH_DEV (portid) if (port_init(portid, mbuf_pool) != 0) - rte_exit(EXIT_FAILURE, "Cannot init port %"PRIu8"\n", - portid);how come not just `% " PRIu16 "\n"' ?
Quoted 4 lines
Quoted 1 line
what was the -Wformat clang on windows complaint?
PRIx16 would work, but I noticed that in other places where port ID is printed, the pattern above is used. IMO uniform approach is better.
ah, consistency. yes i'll have some of that. maybe one day in the future we can change them all in one shot, but not today.
05/05/2021 18:00, Tyler Retzlaff:
Quoted 10 lines · Dmitry Kozlyuk
Quoted 9 lines
2021-05-03 17:11 (UTC-0700), Tyler Retzlaff:
Quoted 8 lines · Dmitry Kozlyuk
Quoted 7 lines
Use "%u" and a cast as in other places when port ID is formatted. This fixes -Wformat warning with clang 10.0.0 on Windows.
Fixes f8244c6399d9 ("ethdev: increase port id range")Signed-off-by Dmitry Kozlyuk <[email protected]>
[...]
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
examples/rxtx_callbacks/main.c main(int argc, char *argv[]) · line 333
Quoted 2 lines
examples/rxtx_callbacks/main.c +0
-2-rte_exit (EXIT_FAILURE ,"Cannot init port %" PRIu8"\n" , - portid);how come not just `% " PRIu16 "\n"' ?
what was the -Wformat clang on windows complaint?
Quoted 7 lines
Quoted 2 lines
PRIx16 would work, but I noticed that in other places where port ID is printed, the pattern above is used. IMO uniform approach is better.
ah, consistency. yes i'll have some of that. maybe one day in the future we can change them all in one shot, but not today.
Acked-by Tyler Retzlaff <[email protected]>
I think PRIu16 is more appropriate. Consistency doesn't matter if an approach is better.
Quoted 8 lines · Thomas Monjalon
05/05/2021 18:00, Tyler Retzlaff:
Quoted 7 lines · Dmitry Kozlyuk
Quoted 5 lines
Quoted 2 lines
what was the -Wformat clang on windows complaint?
PRIx16 would work, but I noticed that in other places where port ID is printed, the pattern above is used. IMO uniform approach is better.
Quoted 6 lines
Quoted 4 lines
ah, consistency. yes i'll have some of that. maybe one day in the future we can change them all in one shot, but not today.
Acked-by Tyler Retzlaff <[email protected]>I think PRIu16 is more appropriate.
works for me.
Quoted 1 line
Consistency doesn't matter if an approach is better.
well, there is some value in having consistency even if it is something sub-optimal if we intend to do a mechanical change of all instances in the future.
as a side question, what is the projects stance on getting more warnings clean? there are a few not enabled that i'd really like to see e.g. format, conversion, truncation etc..
i looked at lib/eal previously and there are... hundreds? of instances so it's a non-trivial task. the problem i see is somehow getting to a warnings clean state where we can enable -Werror in the CI pipeline but at the same time figuring out how to prevent new instances from appearing until we do.
06/05/2021 00:45, Tyler Retzlaff:
Quoted 9 lines
as a side question, what is the projects stance on getting more warnings clean? there are a few not enabled that i'd really like to see e.g. format, conversion, truncation etc..
i looked at lib/eal previously and there are... hundreds? of instances so it's a non-trivial task. the problem i see is somehow getting to a warnings clean state where we can enable -Werror in the CI pipeline but at the same time figuring out how to prevent new instances from appearing until we do.
I don't understand the question.
We are already supposed to be warning-free, and -werror should be enabled in all CI labs. What are the gaps?
Quoted 11 lines · Thomas Monjalon
06/05/2021 00:45, Tyler Retzlaff:
Quoted 9 lines
as a side question, what is the projects stance on getting more warnings clean? there are a few not enabled that i'd really like to see e.g. format, conversion, truncation etc..
i looked at lib/eal previously and there are... hundreds? of instances so it's a non-trivial task. the problem i see is somehow getting to a warnings clean state where we can enable -Werror in the CI pipeline but at the same time figuring out how to prevent new instances from appearing until we do.
Quoted 4 lines
I don't understand the question.
We are already supposed to be warning-free, and -werror should be enabled in all CI labs. What are the gaps?
with the warnings we have enabled -Werror passes, but we don't have all the warnings we could have that are of value. it would be great to see -Wconversion -Wsign-compare -Wsign-conversion passing clean.
i admit it is a lot of work though.
12/05/2021 00:34, Tyler Retzlaff:
Quoted 17 lines · Thomas Monjalon
Quoted 11 lines
06/05/2021 00:45, Tyler Retzlaff:
Quoted 9 lines
as a side question, what is the projects stance on getting more warnings clean? there are a few not enabled that i'd really like to see e.g. format, conversion, truncation etc..
i looked at lib/eal previously and there are... hundreds? of instances so it's a non-trivial task. the problem i see is somehow getting to a warnings clean state where we can enable -Werror in the CI pipeline but at the same time figuring out how to prevent new instances from appearing until we do.
Quoted 4 lines
I don't understand the question.
We are already supposed to be warning-free, and -werror should be enabled in all CI labs. What are the gaps?
Quoted 5 lines
with the warnings we have enabled -Werror passes, but we don't have all the warnings we could have that are of value. it would be great to see -Wconversion -Wsign-compare -Wsign-conversion passing clean.
i admit it is a lot of work though.
-Wsign-compare is enabled for sure, look at config/meson.build. For the conversion warnings, I don't know.
Do not hesitate to propose new warnings enablement with a list of warnings it is generating in its current state, so we can decide whether to enable (and fix) or not.
PATCH v2 1/1 examples/rxtx_callbacks: fix port ID format specifier
In reply to Dmitry KozlyukThis fixes -Wformat warning with clang 10.0.0 on Windows.
---
v2: use PRIx16 instead of %u and a cast (Tyler, Thomas).
examples/rxtx_callbacks/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
examples/rxtx_callbacks/main.c +1 -1
@@ -329,7 +329,7 @@ main(int argc, char *argv[])/* initialize all ports */ RTE_ETH_FOREACH_DEV(portid) if (port_init(portid, mbuf_pool) != 0) - rte_exit(EXIT_FAILURE, "Cannot init port %"PRIu8"\n", + rte_exit(EXIT_FAILURE, "Cannot init port %"PRIx16"\n", portid);if (rte_lcore_count () >1 )
Signature · 1 line
2.29.3
PATCH v3 1/1 examples/rxtx_callbacks: fix port ID format specifier
This fixes -Wformat warning with clang 10.0.0 on Windows.
---
v3: PRIx16 -> PRIu16
v2: u% and a cast -> PRIx16 (Tyler, Thomas)
examples/rxtx_callbacks/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
examples/rxtx_callbacks/main.c +1 -1
@@ -329,7 +329,7 @@ main(int argc, char *argv[])/* initialize all ports */ RTE_ETH_FOREACH_DEV(portid) if (port_init(portid, mbuf_pool) != 0) - rte_exit(EXIT_FAILURE, "Cannot init port %"PRIu8"\n", + rte_exit(EXIT_FAILURE, "Cannot init port %"PRIu16"\n", portid);if (rte_lcore_count () >1 )
Signature · 1 line
2.29.3
Quoted 18 lines · On Thu, 6 May 2021 00:54:35 +0300 Dmitry Kozlyuk <[email protected]>…
This fixes -Wformat warning with clang 10.0.0 on Windows.
Fixes f8244c6399d9 ("ethdev: increase port id range")Signed-off-by Dmitry Kozlyuk <[email protected]>Acked-by Tyler Retzlaff <[email protected]>---
v3: PRIx16 -> PRIu16
v2: u% and a cast -> PRIx16 (Tyler, Thomas)examples/rxtx_callbacks/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)examples/rxtx_callbacks/main.c +0
-0
examples/rxtx_callbacks/main.c main(int argc, char *argv[]) · line 333
Quoted 6 lines
examples/rxtx_callbacks/main.c +1
-1@@ -329,7 +329,7 @@ main(int argc, char *argv[])/* initialize all ports */ RTE_ETH_FOREACH_DEV(portid) if (port_init(portid, mbuf_pool) != 0) - rte_exit(EXIT_FAILURE, "Cannot init port %"PRIu8"\n", + rte_exit(EXIT_FAILURE, "Cannot init port %"PRIu16"\n", portid)
Ok, that matches what is used in rte_ethdev.h
Thomas Monjalon
Applied06/05/2021 04:56, Stephen Hemminger:
Quoted 30 lines
Quoted 18 lines · On Thu, 6 May 2021 00:54:35 +0300 Dmitry Kozlyuk <[email protected]>…
This fixes -Wformat warning with clang 10.0.0 on Windows.
Fixes f8244c6399d9 ("ethdev: increase port id range")Signed-off-by Dmitry Kozlyuk <[email protected]>Acked-by Tyler Retzlaff <[email protected]>---
v3: PRIx16 -> PRIu16
v2: u% and a cast -> PRIx16 (Tyler, Thomas)examples/rxtx_callbacks/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)examples/rxtx_callbacks/main.c +0
-0examples/rxtx_callbacks/main.c main(int argc, char *argv[]) · line 333
Quoted 6 lines
examples/rxtx_callbacks/main.c +1
-1@@ -329,7 +329,7 @@ main(int argc, char *argv[])/* initialize all ports */ RTE_ETH_FOREACH_DEV(portid) if (port_init(portid, mbuf_pool) != 0) - rte_exit(EXIT_FAILURE, "Cannot init port %"PRIu8"\n", + rte_exit(EXIT_FAILURE, "Cannot init port %"PRIu16"\n", portid)Ok, that matches what is used in
rte_ethdev.h
Quoted 1 line
Applied, thanks
Quoted 18 lines · On Thu, 6 May 2021 00:51:33 +0300 Dmitry Kozlyuk <[email protected]>…
This fixes -Wformat warning with clang 10.0.0 on Windows.
Fixes f8244c6399d9 ("ethdev: increase port id range")Signed-off-by Dmitry Kozlyuk <[email protected]>Acked-by Tyler Retzlaff <[email protected]>---
v2: use PRIx16 instead of %u and a cast (Tyler, Thomas).examples/rxtx_callbacks/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)examples/rxtx_callbacks/main.c +0
-0
examples/rxtx_callbacks/main.c main(int argc, char *argv[]) · line 335
Quoted 8 lines
examples/rxtx_callbacks/main.c +1
-1@@ -329,7 +329,7 @@ main(int argc, char *argv[])/* initialize all ports */ RTE_ETH_FOREACH_DEV(portid) if (port_init(portid, mbuf_pool) != 0) - rte_exit(EXIT_FAILURE, "Cannot init port %"PRIu8"\n", + rte_exit(EXIT_FAILURE, "Cannot init port %"PRIx16"\n", portid);if (rte_lcore_count () >1 )
NAK
Just use %u it works for uint16. Don't start using hex, no other places in DPDK print port number in hex.