diff mbox series

[PULL,04/10] libvhost-user: Fix wrong type of argument to formatting function (reported by LGTM)

Message ID 20221103161727.4116147-5-laurent@vivier.eu (mailing list archive)
State New, archived
Headers show
Series [PULL,01/10] qapi: virtio: Fix the introduced version | expand

Commit Message

Laurent Vivier Nov. 3, 2022, 4:17 p.m. UTC
From: Stefan Weil <sw@weilnetz.de>

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Stefan Weil <sw@weilnetz.de>
Message-Id: <20220422070144.1043697-2-sw@weilnetz.de>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 subprojects/libvhost-user/libvhost-user.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Laurent Vivier Nov. 4, 2022, 4:16 p.m. UTC | #1
Hi Stefan,

Le 03/11/2022 à 17:17, Laurent Vivier a écrit :
> From: Stefan Weil <sw@weilnetz.de>
> 
> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> Signed-off-by: Stefan Weil <sw@weilnetz.de>
> Message-Id: <20220422070144.1043697-2-sw@weilnetz.de>
> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
> ---
>   subprojects/libvhost-user/libvhost-user.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvhost-user/libvhost-user.c
> index ffed4729a3dc..d9a6e3e5560f 100644
> --- a/subprojects/libvhost-user/libvhost-user.c
> +++ b/subprojects/libvhost-user/libvhost-user.c
> @@ -651,7 +651,7 @@ generate_faults(VuDev *dev) {
>   
>           if (ioctl(dev->postcopy_ufd, UFFDIO_REGISTER, &reg_struct)) {
>               vu_panic(dev, "%s: Failed to userfault region %d "
> -                          "@%p + size:%zx offset: %zx: (ufd=%d)%s\n",
> +                          "@%" PRIx64 " + size:%zx offset: %zx: (ufd=%d)%s\n",
>                        __func__, i,
>                        dev_region->mmap_addr,
>                        dev_region->size, dev_region->mmap_offset,

They all need PRIx64:

typedef struct VuDevRegion {
     /* Guest Physical address. */
     uint64_t gpa;
     /* Memory region size. */
     uint64_t size;
     /* QEMU virtual address (userspace). */
     uint64_t qva;
     /* Starting offset in our mmaped space. */
     uint64_t mmap_offset;
     /* Start address of mmaped space. */
     uint64_t mmap_addr;
} VuDevRegion;

Could you fix your patch?

Thanks,
Laurent
Stefan Weil Nov. 5, 2022, 9:15 a.m. UTC | #2
Am 04.11.22 um 17:16 schrieb Laurent Vivier:

> Hi Stefan,
>
> Le 03/11/2022 à 17:17, Laurent Vivier a écrit :
>> From: Stefan Weil <sw@weilnetz.de>
>>
>> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
>> Signed-off-by: Stefan Weil <sw@weilnetz.de>
>> Message-Id: <20220422070144.1043697-2-sw@weilnetz.de>
>> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
>> ---
>>   subprojects/libvhost-user/libvhost-user.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/subprojects/libvhost-user/libvhost-user.c 
>> b/subprojects/libvhost-user/libvhost-user.c
>> index ffed4729a3dc..d9a6e3e5560f 100644
>> --- a/subprojects/libvhost-user/libvhost-user.c
>> +++ b/subprojects/libvhost-user/libvhost-user.c
>> @@ -651,7 +651,7 @@ generate_faults(VuDev *dev) {
>>             if (ioctl(dev->postcopy_ufd, UFFDIO_REGISTER, 
>> &reg_struct)) {
>>               vu_panic(dev, "%s: Failed to userfault region %d "
>> -                          "@%p + size:%zx offset: %zx: (ufd=%d)%s\n",
>> +                          "@%" PRIx64 " + size:%zx offset: %zx: 
>> (ufd=%d)%s\n",
>>                        __func__, i,
>>                        dev_region->mmap_addr,
>>                        dev_region->size, dev_region->mmap_offset,
>
> They all need PRIx64:
>
> typedef struct VuDevRegion {
>     /* Guest Physical address. */
>     uint64_t gpa;
>     /* Memory region size. */
>     uint64_t size;
>     /* QEMU virtual address (userspace). */
>     uint64_t qva;
>     /* Starting offset in our mmaped space. */
>     uint64_t mmap_offset;
>     /* Start address of mmaped space. */
>     uint64_t mmap_addr;
> } VuDevRegion;
>
> Could you fix your patch?


The patch fixes one error ("%p"). The two "%zx" are old errors which I 
did not notice because they are only relevant for platforms with 
sizeof(void *) != sizeof(uint64_t), and 32 bit Windows builds don't 
compile libvhost-user. So we need an additional patch which fixes the 
"%zx" before patch 06/10 which adds the format attribute is applied.

Stefan, I suggest to merge the trivial branch without patch 06/10. That 
should fix the build failure and fixes at least some of the format 
errors. Then a patch which fixes the remaining format errors can be 
applied later together with the omitted patch 06/10.

Regards,

Stefan
diff mbox series

Patch

diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvhost-user/libvhost-user.c
index ffed4729a3dc..d9a6e3e5560f 100644
--- a/subprojects/libvhost-user/libvhost-user.c
+++ b/subprojects/libvhost-user/libvhost-user.c
@@ -651,7 +651,7 @@  generate_faults(VuDev *dev) {
 
         if (ioctl(dev->postcopy_ufd, UFFDIO_REGISTER, &reg_struct)) {
             vu_panic(dev, "%s: Failed to userfault region %d "
-                          "@%p + size:%zx offset: %zx: (ufd=%d)%s\n",
+                          "@%" PRIx64 " + size:%zx offset: %zx: (ufd=%d)%s\n",
                      __func__, i,
                      dev_region->mmap_addr,
                      dev_region->size, dev_region->mmap_offset,