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

Re: [PATCH] libxl: virtio: Fix build error for 32-bit platforms


  • To: Anthony PERARD <anthony.perard@xxxxxxxxxx>, Viresh Kumar <viresh.kumar@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 15 Dec 2022 16:11:34 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mr0lf+gRcRWfpIfw24gPuFVeEyhcYWSXwZxGzjq7tlA=; b=QnPvFo/4OidF5wGe8Uzt1YTW0f9x7F3wozf+MYNp+yZDyszdcdRikc4PPu/qlOVxEyHctZmFEMsQDHtKmmp0K6nKz/g4cf3c6LzUQfB2zPjOUwt/405/+KiNQ9CQTZL1KU+Q4GZsTq0MiBxQHU2FMZc3H35zwk5mmJTsSwUdx5+0geIQDyU1ezTapYgGFdt9OGLeTOksIfXO/fqVMx3t3+DDcHIc8AhfINgHwDbvUp7lnk0KqFIz0BlWBIBOFlgFMXR7BNyoyiIMEBcn3Gidx1l6ofCtS5P3PT9MhVwcI/76600hwq1glBe7jJEnmcwqRx2UcnGap4ZXhzOZdRdX2g==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=axKXVODExE3rcY2W+DbtZtx8IeokM+vItLaGElPFsFhbkEN2+2QvpPatZBq6Fo8k7G/h4aXVDBlPUIsijiSjDDF3dbPPABaJNuv0BmAPVBNLVzXspO/6OHglo6Pm6r0mL1qjw8eu0RgXTa+4wtIhujOddNuLMskvqUdRLz00dHFPhNkEZmyeLjUNYqvgsVPU6RUAzJ0VSjZx68E+k7Ir8ZIJ0mTPaN9CtiMS87JMTbwMugKwKeVCXw0+vf7uHUI06atT0txNs5gaG+O1sGZhVBrmNlH1j3Pju2UCKPgA+bwJf2RkB0cr4D8HFj+YNn7FK+Tkg+mZY3vCadIdO5bTXg==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=suse.com;
  • Cc: xen-devel@xxxxxxxxxxxxx, Juergen Gross <jgross@xxxxxxxx>, Julien Grall <julien@xxxxxxx>, osstest-admin@xxxxxxxxxxxxxx, Vincent Guittot <vincent.guittot@xxxxxxxxxx>, stratos-dev@xxxxxxxxxxxxxxxxxxx, Alex Bennée <alex.bennee@xxxxxxxxxx>, Stefano Stabellini <stefano.stabellini@xxxxxxxxxx>, Mathieu Poirier <mathieu.poirier@xxxxxxxxxx>, Mike Holmes <mike.holmes@xxxxxxxxxx>, Oleksandr Tyshchenko <olekstysh@xxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Thu, 15 Dec 2022 15:11:42 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 15.12.2022 14:48, Anthony PERARD wrote:
> On Thu, Dec 15, 2022 at 07:01:40PM +0530, Viresh Kumar wrote:
>> The field 'base' in 'struct libxl_device_virtio' is defined as uint64,
>> while we are printing it with '%lu', which is 32bit only 32-bit
>> platforms. And so generates a error like:
>>
>>   libxl_internal.h:4388:51: error: format '%lu' expects argument of type 
>> 'long
>>   unsigned int', but argument 3 has type 'uint64_t' {aka 'long long unsigned
>>   int'} [-Werror=format=]
>>
>> Fix the same by using PRIx64 instead.
>>
>> Now that the base name is available in hexadecimal format, prefix it
>> with '0x' as well, which strtoul() also depends upon since base passed
>> is 0.
>>
>> Fixes: 43ba5202e2ee ("libxl: add support for generic virtio device")
>> Signed-off-by: Viresh Kumar <viresh.kumar@xxxxxxxxxx>
>> ---
>> Couldn't test on 32-bit platforms yet, but works fine for 64 bit one.
>>
>>  tools/libs/light/libxl_virtio.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/tools/libs/light/libxl_virtio.c 
>> b/tools/libs/light/libxl_virtio.c
>> index 6a38def2faf5..2217bda8a253 100644
>> --- a/tools/libs/light/libxl_virtio.c
>> +++ b/tools/libs/light/libxl_virtio.c
>> @@ -45,12 +45,12 @@ static int libxl__set_xenstore_virtio(libxl__gc *gc, 
>> uint32_t domid,
>>      const char *transport = 
>> libxl_virtio_transport_to_string(virtio->transport);
>>  
>>      flexarray_append_pair(back, "irq", GCSPRINTF("%u", virtio->irq));
>> -    flexarray_append_pair(back, "base", GCSPRINTF("%lu", virtio->base));
>> +    flexarray_append_pair(back, "base", GCSPRINTF("0x%"PRIx64, 
>> virtio->base));
> 
> There is also PRIu64 that exist, which would be perfect to replace %u.
> Could we use that instead?
> 
> I'd rather not have to think about which base is used for numbers in
> xenstore. I can't find any hexadecimal numbers in xenstore for a simple
> guest at the moment, so probably best to avoid adding one. And using
> hexadecimal isn't needed to fix the build.

Otoh an address formatted in decimal is pretty unusable to any human
(who might be inspecting xenstore for whatever reasons).

Jan



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.