Re: [kvm-unit-tests PATCH] lib: use %zu conversion for sizeof to fix i386 build

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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@xxxxxxxxxx>
> ---
>  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@xxxxxxxxxx>



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux