[PATCH] examples: Fix the wrong format specifier

Zhu Jun posted 1 patch 1 year, 5 months ago
tools/net/ynl/samples/page-pool.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] examples: Fix the wrong format specifier
Posted by Zhu Jun 1 year, 5 months ago
The format specifier of "unsigned int" in printf() should be "%u", not
"%d".

Signed-off-by: Zhu Jun <zhujun2@cmss.chinamobile.com>
---
 tools/net/ynl/samples/page-pool.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/net/ynl/samples/page-pool.c b/tools/net/ynl/samples/page-pool.c
index 332f281ee5cb..e5d521320fbf 100644
--- a/tools/net/ynl/samples/page-pool.c
+++ b/tools/net/ynl/samples/page-pool.c
@@ -118,7 +118,7 @@ int main(int argc, char **argv)
 			name = if_indextoname(s->ifc, ifname);
 			if (name)
 				printf("%8s", name);
-			printf("[%d]\t", s->ifc);
+			printf("[%u]\t", s->ifc);
 		}
 
 		printf("page pools: %u (zombies: %u)\n",
-- 
2.17.1
Re: [PATCH] examples: Fix the wrong format specifier
Posted by Paolo Abeni 1 year, 5 months ago
On 8/20/24 05:26, Zhu Jun wrote:
> The format specifier of "unsigned int" in printf() should be "%u", not
> "%d".

You must CC the netdev ML for network related patch.

The interface index is constraint by the kernel to be a signed integer, 
(with non negative valid values), the '%d' format string is IMHO 
actually correct.

Cheers,

Paolo