public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [kvm-unit-tests PATCH] lib: use %zu conversion for sizeof to fix i386 build
@ 2017-05-12 15:15 Radim Krčmář
  2017-05-12 15:23 ` Paolo Bonzini
  2017-05-12 15:28 ` Radim Krčmář
  0 siblings, 2 replies; 6+ messages in thread
From: Radim Krčmář @ 2017-05-12 15:15 UTC (permalink / raw)
  To: kvm; +Cc: Paolo Bonzini, Peter Feiner

Fixes this GCC error:

In file included from lib/report.c:13:0:
lib/libcflat.h:134:10: error: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 6 has type ‘unsigned int’ [-Werror=format=]
   printf("%s:%d: assert failed: %s: " fmt "\n",  \
          ^
lib/report.c:53:2: note: in expansion of macro ‘assert_msg’
  assert_msg(len < sizeof(prefixes), "%d >= %lu", len, sizeof(prefixes));
  ^~~~~~~~~~
lib/report.c:53:46: note: format string is defined here
  assert_msg(len < sizeof(prefixes), "%d >= %lu", len, sizeof(prefixes));
                                            ~~^
                                            %u

Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
---
 lib/report.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/report.c b/lib/report.c
index f7af596f1fc4..b002d2107e37 100644
--- a/lib/report.c
+++ b/lib/report.c
@@ -35,14 +35,14 @@ void report_prefix_pushf(const char *prefix_fmt, ...)
 	spin_lock(&lock);
 
 	len = strlen(prefixes);
-	assert_msg(len < sizeof(prefixes), "%d >= %lu", len, sizeof(prefixes));
+	assert_msg(len < sizeof(prefixes), "%d >= %zu", len, sizeof(prefixes));
 	start = len;
 
 	va_start(va, prefix_fmt);
 	len += vsnprintf(&prefixes[len], sizeof(prefixes) - len, prefix_fmt,
 			 va);
 	va_end(va);
-	assert_msg(len < sizeof(prefixes), "%d >= %lu", len, sizeof(prefixes));
+	assert_msg(len < sizeof(prefixes), "%d >= %zu", len, sizeof(prefixes));
 
 	assert_msg(!strstr(&prefixes[start], PREFIX_DELIMITER),
 		   "Prefix \"%s\" contains delimiter \"" PREFIX_DELIMITER "\"",
@@ -50,7 +50,7 @@ void report_prefix_pushf(const char *prefix_fmt, ...)
 
 	len += snprintf(&prefixes[len], sizeof(prefixes) - len,
 			PREFIX_DELIMITER);
-	assert_msg(len < sizeof(prefixes), "%d >= %lu", len, sizeof(prefixes));
+	assert_msg(len < sizeof(prefixes), "%d >= %zu", len, sizeof(prefixes));
 
 	spin_unlock(&lock);
 }
-- 
2.13.0

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

end of thread, other threads:[~2017-05-12 16:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-12 15:15 [kvm-unit-tests PATCH] lib: use %zu conversion for sizeof to fix i386 build Radim Krčmář
2017-05-12 15:23 ` Paolo Bonzini
2017-05-12 16:00   ` Peter Feiner
2017-05-12 15:28 ` Radim Krčmář
2017-05-12 15:43   ` Paolo Bonzini
2017-05-12 15:57     ` Radim Krčmář

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