virtio-mem: Work around format specifier mismatch for RISC-V
PATCH 1/1 virtio-mem: Work around format specifier mismatch for RISC-V
This likely affects other, less popular host architectures as well. Less common host architectures under linux get QEMU_VMALLOC_ALIGN (from which VIRTIO_MEM_MIN_BLOCK_SIZE is derived) define to a variable of type uintptr, which isn't compatible with the format specifier used to print a user message. Since this particular usage of the underlying data seems unique, the simple fix is to just cast it to the corresponding format specifier.
--- hw/virtio/virtio-mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/virtio/virtio-mem.c +1 -1
@@ -754,7 +754,7 @@ static void virtio_mem_set_block_size(Object *obj, Visitor *v, const char *name,if (value <VIRTIO_MEM_MIN_BLOCK_SIZE ) {error_setg (errp,"'%s' property has to be at least 0x%" PRIx32, name, -VIRTIO_MEM_MIN_BLOCK_SIZE ); + (unsigned int )VIRTIO_MEM_MIN_BLOCK_SIZE );return ; }else if (!is_power_of_2 (value)) {error_setg (errp,"'%s' property has to be a power of two" , name);
Signature · 1 line
2.27.0
Quoted 18 lines · Bruce Rogers
This likely affects other, less popular host architectures as well. Less common host architectures under linux get
QEMU_VMALLOC_ALIGN(from whichVIRTIO_MEM_MIN_BLOCK_SIZEis derived) define to a variable of type uintptr, which isn't compatible with the format specifier used to print a user message. Since this particular usage of the underlying data seems unique, the simple fix is to just cast it to the corresponding format specifier.Signed-off-by Bruce Rogers <[email protected]>--- hw/virtio/virtio-mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/virtio/virtio-mem.c +0
-0
hw/virtio/virtio-mem.c static void virtio_mem_set_block_size(Object *obj, Visitor *v, const char *name, · line 757
Quoted 5 lines
hw/virtio/virtio-mem.c +1
-1@@ -754,7 +754,7 @@ static void virtio_mem_set_block_size(Object *obj, Visitor *v, const char *name,if (value <VIRTIO_MEM_MIN_BLOCK_SIZE ) {error_setg (errp,"'%s' property has to be at least 0x%" PRIx32, name, -VIRTIO_MEM_MIN_BLOCK_SIZE ); + (unsigned int )VIRTIO_MEM_MIN_BLOCK_SIZE );
Since we use PRIx32, could be better to cast VIRTIO_MEM_MIN_BLOCK_SIZE to uint32_t?
Thanks,
Stefano
Quoted 7 lines
hw/virtio/virtio-mem.c +0
-0return ; }else if (!is_power_of_2 (value)) {error_setg (errp,"'%s' property has to be a power of two" , name);Signature · 1 line
2.27.0
Quoted 20 lines · Stefano Garzarella
Quoted 19 lines · Bruce Rogers
This likely affects other, less popular host architectures as well. Less common host architectures under linux get
QEMU_VMALLOC_ALIGN(from whichVIRTIO_MEM_MIN_BLOCK_SIZEis derived) define to a variable of type uintptr, which isn't compatible with the format specifier used to print a user message. Since this particular usage of the underlying data seems unique, the simple fix is to just cast it to the corresponding format specifier.Signed-off-by Bruce Rogers <[email protected]>--- hw/virtio/virtio-mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/virtio/virtio-mem.c +0
-0@@ -754,7 +754,7 @@ static void virtio_mem_set_block_size(Object *obj, Visitor *v, const char *name,
Quoted 7 lines
hw/virtio/virtio-mem.c static void virtio_mem_set_block_size(Object *obj, Visitor *v, const char *name, · line 757
Quoted 4 lines
hw/virtio/virtio-mem.c +1
-1if (value <VIRTIO_MEM_MIN_BLOCK_SIZE ) {error_setg (errp,"'%s' property has to be at least 0x%" PRIx32, name, -VIRTIO_MEM_MIN_BLOCK_SIZE ); + (unsigned int )VIRTIO_MEM_MIN_BLOCK_SIZE );Since we use PRIx32, could be better to cast
VIRTIO_MEM_MIN_BLOCK_SIZEtouint32_t?
Yeah, I guess something like
-#define VIRTIO_MEM_MIN_BLOCK_SIZE QEMU_VMALLOC_ALIGN +#define VIRTIO_MEM_MIN_BLOCK_SIZE ((uint32_t)QEMU_VMALLOC_ALIGN)
would be cleaner
Signature · 3 lines
Thanks, David / dhildenb
Quoted 34 lines · David Hildenbrand
Quoted 20 lines · Stefano Garzarella
Quoted 19 lines · Bruce Rogers
This likely affects other, less popular host architectures as well. Less common host architectures under linux get
QEMU_VMALLOC_ALIGN(from whichVIRTIO_MEM_MIN_BLOCK_SIZEis derived) define to a variable of type uintptr, which isn't compatible with the format specifier used to print a user message. Since this particular usage of the underlying data seems unique, the simple fix is to just cast it to the corresponding format specifier.Signed-off-by Bruce Rogers <[email protected]>--- hw/virtio/virtio-mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/virtio/virtio-mem.c +0
-0@@ -754,7 +754,7 @@ static void virtio_mem_set_block_size(Object *obj, Visitor *v, const char *name,Quoted 7 lines
hw/virtio/virtio-mem.c static void virtio_mem_set_block_size(Object *obj, Visitor *v, const char *name, · line 757
Quoted 4 lines
hw/virtio/virtio-mem.c +1
-1if (value <VIRTIO_MEM_MIN_BLOCK_SIZE ) {error_setg (errp,"'%s' property has to be at least 0x%" PRIx32, name, -VIRTIO_MEM_MIN_BLOCK_SIZE ); + (unsigned int )VIRTIO_MEM_MIN_BLOCK_SIZE );Since we use PRIx32, could be better to cast
VIRTIO_MEM_MIN_BLOCK_SIZEtouint32_t?Yeah, I guess something like
(quoted diff) +1
-1-#define VIRTIO_MEM_MIN_BLOCK_SIZE QEMU_VMALLOC_ALIGN +#define VIRTIO_MEM_MIN_BLOCK_SIZE ((uint32_t)QEMU_VMALLOC_ALIGN)
Quoted 1 line
would be cleaner
Yeah, it is cleaner.
Otherwise we could use PRIxPTR in the error message.
Thanks,
Stefano
Quoted 30 lines · Stefano Garzarella
Quoted 29 lines · David Hildenbrand
Quoted 27 lines · Stefano Garzarella
Quoted 18 lines · Bruce Rogers
This likely affects other, less popular host architectures as well. Less common host architectures under linux get
QEMU_VMALLOC_ALIGN(from whichVIRTIO_MEM_MIN_BLOCK_SIZEis derived) define to a variable of type uintptr, which isn't compatible with the format specifier used to print a user message. Since this particular usage of the underlying data seems unique, the simple fix is to just cast it to the corresponding format specifier.Signed-off-by Bruce Rogers <[email protected]>--- hw/virtio/virtio-mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/virtio/virtio-mem.c +0
-0hw/virtio/virtio-mem.c static void virtio_mem_set_block_size(Object *obj, Visitor *v, const char *name, · line 757
Quoted 5 lines
hw/virtio/virtio-mem.c +1
-1@@ -754,7 +754,7 @@ static void virtio_mem_set_block_size(Object *obj, Visitor *v, const char *name,if (value <VIRTIO_MEM_MIN_BLOCK_SIZE ) {error_setg (errp,"'%s' property has to be at least 0x%" PRIx32, name, -VIRTIO_MEM_MIN_BLOCK_SIZE ); + (unsigned int )VIRTIO_MEM_MIN_BLOCK_SIZE );Since we use PRIx32, could be better to cast
VIRTIO_MEM_MIN_BLOCK_SIZEtouint32_t?
Quoted 8 lines
Quoted 6 lines
Yeah, I guess something like
(quoted diff) +1
-1-#define VIRTIO_MEM_MIN_BLOCK_SIZE QEMU_VMALLOC_ALIGN +#define VIRTIO_MEM_MIN_BLOCK_SIZE ((uint32_t)QEMU_VMALLOC_ALIGN)would be cleaner
Yeah, it is cleaner.
Bruce, can you respin if you agree? Thanks!
Signature · 3 lines
Thanks, David / dhildenb
Quoted 43 lines · David Hildenbrand
Quoted 42 lines · Stefano Garzarella
Quoted 41 lines · David Hildenbrand
Quoted 28 lines · Stefano Garzarella
Quoted 27 lines · Bruce Rogers
This likely affects other, less popular host architectures as well.
Less common host architectures under linux getQEMU_VMALLOC_ALIGN(from
whichVIRTIO_MEM_MIN_BLOCK_SIZEis derived) define to a variable of
type uintptr, which isn't compatible with the format specifier used to
print a user message. Since this particular usage of the underlying data
seems unique, the simple fix is to just cast it to the corresponding
format specifier.Signed-off-by Bruce Rogers <[email protected]>--- hw/virtio/virtio-mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/virtio/virtio-mem.c +0
-0@@ -754,7 +754,7 @@ static voidvirtio_mem_set_block_size(Object *obj, Visitor *v, const char *name,
Quoted 9 lines
hw/virtio/virtio-mem.c static void virtio_mem_set_block_size(Object *obj, Visitor *v, const char *name, · line 757
Quoted 5 lines
if (value <
VIRTIO_MEM_MIN_BLOCK_SIZE) {
error_setg(errp, "'%s' property has to be at least
0x%" PRIx32, name,hw/virtio/virtio-mem.c +1
-1- VIRTIO_MEM_MIN_BLOCK_SIZE); + (unsigned int)VIRTIO_MEM_MIN_BLOCK_SIZE);Since we use PRIx32, could be better to cast
VIRTIO_MEM_MIN_BLOCK_SIZE
touint32_t?Yeah, I guess something like
Quoted 9 lines
Quoted 6 lines
Quoted 4 lines
(quoted diff) +1
-1-#define VIRTIO_MEM_MIN_BLOCK_SIZE QEMU_VMALLOC_ALIGN +#define VIRTIO_MEM_MIN_BLOCK_SIZE ((uint32_t)QEMU_VMALLOC_ALIGN)would be cleaner
Yeah, it is cleaner.
Bruce, can you respin if you agree? Thanks!
Agreed.
- Bruce