Netdev List
 help / color / mirror / Atom feed
* [PATCH iproute2 v2 1/2] devlink: fix format string warning for 32bit targets
@ 2019-06-27 18:37 Baruch Siach
  2019-06-27 18:37 ` [PATCH iproute2 v2 2/2] devlink: fix libc and kernel headers collision Baruch Siach
  2019-06-28 22:21 ` [PATCH iproute2 v2 1/2] devlink: fix format string warning for 32bit targets Stephen Hemminger
  0 siblings, 2 replies; 3+ messages in thread
From: Baruch Siach @ 2019-06-27 18:37 UTC (permalink / raw)
  To: Stephen Hemminger, Jiri Pirko
  Cc: netdev, Baruch Siach, Aya Levin, Moshe Shemesh

32bit targets define uint64_t as long long unsigned. This leads to the
following build warning:

devlink.c: In function ‘pr_out_u64’:
devlink.c:1729:11: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 4 has type ‘uint64_t {aka long long unsigned int}’ [-Wformat=]
    pr_out("%s %lu", name, val);
           ^
devlink.c:59:21: note: in definition of macro ‘pr_out’
   fprintf(stdout, ##args);   \
                     ^~~~

Use uint64_t specific conversion specifiers in the format string to fix
that.

Cc: Aya Levin <ayal@mellanox.com>
Cc: Moshe Shemesh <moshe@mellanox.com>
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
v2: Use inttypes.h conversion specifiers
---
 devlink/devlink.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/devlink/devlink.c b/devlink/devlink.c
index 436935f88bda..b6e68f9a4d65 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -1726,9 +1726,9 @@ static void pr_out_u64(struct dl *dl, const char *name, uint64_t val)
 		jsonw_u64_field(dl->jw, name, val);
 	} else {
 		if (g_indent_newline)
-			pr_out("%s %lu", name, val);
+			pr_out("%s %"PRIu64, name, val);
 		else
-			pr_out(" %s %lu", name, val);
+			pr_out(" %s %"PRIu64, name, val);
 	}
 }
 
@@ -1753,7 +1753,7 @@ static void pr_out_uint64_value(struct dl *dl, uint64_t value)
 	if (dl->json_output)
 		jsonw_u64(dl->jw, value);
 	else
-		pr_out(" %lu", value);
+		pr_out(" %"PRIu64, value);
 }
 
 static void pr_out_binary_value(struct dl *dl, uint8_t *data, uint32_t len)
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-06-28 22:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-27 18:37 [PATCH iproute2 v2 1/2] devlink: fix format string warning for 32bit targets Baruch Siach
2019-06-27 18:37 ` [PATCH iproute2 v2 2/2] devlink: fix libc and kernel headers collision Baruch Siach
2019-06-28 22:21 ` [PATCH iproute2 v2 1/2] devlink: fix format string warning for 32bit targets Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox