[libvirt] [PATCH] util: Fix build on s390

Andreas Krebbel krebbel at linux.vnet.ibm.com
Fri Oct 14 06:31:53 UTC 2016


On 10/07/2016 12:43 PM, Jiri Denemark wrote:
> GCC on s390 complains
> 
> util/virconf.c: In function 'virConfGetValueSizeT':
> util/virconf.c:1220:9: error: format '%zu' expects argument of type
> 'size_t', but argument 9 has type 'unsigned int' [-Werror=format=]
> 
> Signed-off-by: Jiri Denemark <jdenemar at redhat.com>
> ---
>  src/util/virconf.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/util/virconf.c b/src/util/virconf.c
> index 3e49f41..1372389 100644
> --- a/src/util/virconf.c
> +++ b/src/util/virconf.c
> @@ -1219,7 +1219,7 @@ int virConfGetValueSizeT(virConfPtr conf,
>      if (((unsigned long long)cval->l) > SIZE_MAX) {
>          virReportError(VIR_ERR_INTERNAL_ERROR,
>                         _("%s: value for '%s' parameter must be in range 0:%zu"),
> -                       conf->filename, setting, SIZE_MAX);
> +                       conf->filename, setting, (size_t) SIZE_MAX);
>          return -1;
>      }
>  #endif

S/390 32 bit uses an "unsigned long" as size_t while every other 32 bit target uses "unsigned int".
The __SIZE_MAX__ predefined macro generated by GCC itself handles this correctly by defining it as
4294967295UL. However, the stdint.h header defines it as 4294967295U. So in the end we probably have
to fix the Glibc header. This workaround is ok I think. Directly using __SIZE_MAX__ instead of
SIZE_MAX would not be portable.

-Andreas-





More information about the libvir-list mailing list