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

* Re: [kvm-unit-tests PATCH] lib: use %zu conversion for sizeof to fix i386 build
  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ář
  1 sibling, 1 reply; 6+ messages in thread
From: Paolo Bonzini @ 2017-05-12 15:23 UTC (permalink / raw)
  To: Radim Krčmář, kvm; +Cc: Peter Feiner



On 12/05/2017 17:15, Radim Krčmář wrote:
> 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);
>  }
> 

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>

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

* Re: [kvm-unit-tests PATCH] lib: use %zu conversion for sizeof to fix i386 build
  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 15:28 ` Radim Krčmář
  2017-05-12 15:43   ` Paolo Bonzini
  1 sibling, 1 reply; 6+ messages in thread
From: Radim Krčmář @ 2017-05-12 15:28 UTC (permalink / raw)
  To: kvm; +Cc: Paolo Bonzini, Peter Feiner

2017-05-12 17:15+0200, Radim Krčmář:
> 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>
> ---

Ugh, and I didn't test it ... libcflat doesn't support %z.
Casting the sizeof result to unsigned would work, but I don't like it
one bit.  Is there a convention in naming the conversion?  (like PRI...)

Thanks.

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

* Re: [kvm-unit-tests PATCH] lib: use %zu conversion for sizeof to fix i386 build
  2017-05-12 15:28 ` Radim Krčmář
@ 2017-05-12 15:43   ` Paolo Bonzini
  2017-05-12 15:57     ` Radim Krčmář
  0 siblings, 1 reply; 6+ messages in thread
From: Paolo Bonzini @ 2017-05-12 15:43 UTC (permalink / raw)
  To: Radim Krčmář, kvm; +Cc: Peter Feiner



On 12/05/2017 17:28, Radim Krčmář wrote:
> 2017-05-12 17:15+0200, Radim Krčmář:
>> 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>
>> ---
> 
> Ugh, and I didn't test it ... libcflat doesn't support %z.

Let's add it, I have sent a patch.

Paolo

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

* Re: [kvm-unit-tests PATCH] lib: use %zu conversion for sizeof to fix i386 build
  2017-05-12 15:43   ` Paolo Bonzini
@ 2017-05-12 15:57     ` Radim Krčmář
  0 siblings, 0 replies; 6+ messages in thread
From: Radim Krčmář @ 2017-05-12 15:57 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: kvm, Peter Feiner

2017-05-12 17:43+0200, Paolo Bonzini:
> On 12/05/2017 17:28, Radim Krčmář wrote:
> > 2017-05-12 17:15+0200, Radim Krčmář:
> >> 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>
> >> ---
> > 
> > Ugh, and I didn't test it ... libcflat doesn't support %z.
> 
> Let's add it, I have sent a patch.

Right, shame on me for fixing it on the wrong side!
Applied after your patch,

Thanks.

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

* Re: [kvm-unit-tests PATCH] lib: use %zu conversion for sizeof to fix i386 build
  2017-05-12 15:23 ` Paolo Bonzini
@ 2017-05-12 16:00   ` Peter Feiner
  0 siblings, 0 replies; 6+ messages in thread
From: Peter Feiner @ 2017-05-12 16:00 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: Radim Krčmář, kvm

On Fri, May 12, 2017 at 8:23 AM, Paolo Bonzini <pbonzini@redhat.com> wrote:
>
>
> On 12/05/2017 17:15, Radim Krčmář wrote:
>> 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);
>>  }
>>
>
> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Peter Feiner <pfeiner@google.com>

^ permalink raw reply	[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