* [PATCH] virtio-mem: Work around format specifier mismatch for RISC-V
@ 2020-07-30 0:54 Bruce Rogers
2020-07-30 7:49 ` Stefano Garzarella
0 siblings, 1 reply; 6+ messages in thread
From: Bruce Rogers @ 2020-07-30 0:54 UTC (permalink / raw)
To: qemu-devel; +Cc: Bruce Rogers, david
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.
Signed-off-by: Bruce Rogers <brogers@suse.com>
---
hw/virtio/virtio-mem.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c
index c12e9f79b0..fd01ffd83e 100644
--- a/hw/virtio/virtio-mem.c
+++ b/hw/virtio/virtio-mem.c
@@ -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);
--
2.27.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] virtio-mem: Work around format specifier mismatch for RISC-V
2020-07-30 0:54 [PATCH] virtio-mem: Work around format specifier mismatch for RISC-V Bruce Rogers
@ 2020-07-30 7:49 ` Stefano Garzarella
2020-07-30 7:51 ` David Hildenbrand
0 siblings, 1 reply; 6+ messages in thread
From: Stefano Garzarella @ 2020-07-30 7:49 UTC (permalink / raw)
To: Bruce Rogers; +Cc: qemu-devel, david
On Wed, Jul 29, 2020 at 06:54:38PM -0600, Bruce Rogers wrote:
> 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.
>
> Signed-off-by: Bruce Rogers <brogers@suse.com>
> ---
> hw/virtio/virtio-mem.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c
> index c12e9f79b0..fd01ffd83e 100644
> --- a/hw/virtio/virtio-mem.c
> +++ b/hw/virtio/virtio-mem.c
> @@ -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
> return;
> } else if (!is_power_of_2(value)) {
> error_setg(errp, "'%s' property has to be a power of two", name);
> --
> 2.27.0
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] virtio-mem: Work around format specifier mismatch for RISC-V
2020-07-30 7:49 ` Stefano Garzarella
@ 2020-07-30 7:51 ` David Hildenbrand
2020-07-30 7:58 ` Stefano Garzarella
0 siblings, 1 reply; 6+ messages in thread
From: David Hildenbrand @ 2020-07-30 7:51 UTC (permalink / raw)
To: Stefano Garzarella, Bruce Rogers; +Cc: qemu-devel
On 30.07.20 09:49, Stefano Garzarella wrote:
> On Wed, Jul 29, 2020 at 06:54:38PM -0600, Bruce Rogers wrote:
>> 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.
>>
>> Signed-off-by: Bruce Rogers <brogers@suse.com>
>> ---
>> hw/virtio/virtio-mem.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c
>> index c12e9f79b0..fd01ffd83e 100644
>> --- a/hw/virtio/virtio-mem.c
>> +++ b/hw/virtio/virtio-mem.c
>> @@ -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?
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
--
Thanks,
David / dhildenb
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] virtio-mem: Work around format specifier mismatch for RISC-V
2020-07-30 7:51 ` David Hildenbrand
@ 2020-07-30 7:58 ` Stefano Garzarella
2020-07-30 8:12 ` David Hildenbrand
0 siblings, 1 reply; 6+ messages in thread
From: Stefano Garzarella @ 2020-07-30 7:58 UTC (permalink / raw)
To: David Hildenbrand; +Cc: qemu-devel, Bruce Rogers
On Thu, Jul 30, 2020 at 09:51:19AM +0200, David Hildenbrand wrote:
> On 30.07.20 09:49, Stefano Garzarella wrote:
> > On Wed, Jul 29, 2020 at 06:54:38PM -0600, Bruce Rogers wrote:
> >> 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.
> >>
> >> Signed-off-by: Bruce Rogers <brogers@suse.com>
> >> ---
> >> hw/virtio/virtio-mem.c | 2 +-
> >> 1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c
> >> index c12e9f79b0..fd01ffd83e 100644
> >> --- a/hw/virtio/virtio-mem.c
> >> +++ b/hw/virtio/virtio-mem.c
> >> @@ -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?
>
> 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
Yeah, it is cleaner.
Otherwise we could use PRIxPTR in the error message.
Thanks,
Stefano
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] virtio-mem: Work around format specifier mismatch for RISC-V
2020-07-30 7:58 ` Stefano Garzarella
@ 2020-07-30 8:12 ` David Hildenbrand
2020-07-30 12:51 ` Bruce Rogers
0 siblings, 1 reply; 6+ messages in thread
From: David Hildenbrand @ 2020-07-30 8:12 UTC (permalink / raw)
To: Stefano Garzarella; +Cc: qemu-devel, Bruce Rogers
On 30.07.20 09:58, Stefano Garzarella wrote:
> On Thu, Jul 30, 2020 at 09:51:19AM +0200, David Hildenbrand wrote:
>> On 30.07.20 09:49, Stefano Garzarella wrote:
>>> On Wed, Jul 29, 2020 at 06:54:38PM -0600, Bruce Rogers wrote:
>>>> 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.
>>>>
>>>> Signed-off-by: Bruce Rogers <brogers@suse.com>
>>>> ---
>>>> hw/virtio/virtio-mem.c | 2 +-
>>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>>
>>>> diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c
>>>> index c12e9f79b0..fd01ffd83e 100644
>>>> --- a/hw/virtio/virtio-mem.c
>>>> +++ b/hw/virtio/virtio-mem.c
>>>> @@ -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?
>>
>> 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
>
> Yeah, it is cleaner.
Bruce, can you respin if you agree? Thanks!
--
Thanks,
David / dhildenb
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] virtio-mem: Work around format specifier mismatch for RISC-V
2020-07-30 8:12 ` David Hildenbrand
@ 2020-07-30 12:51 ` Bruce Rogers
0 siblings, 0 replies; 6+ messages in thread
From: Bruce Rogers @ 2020-07-30 12:51 UTC (permalink / raw)
To: David Hildenbrand, Stefano Garzarella; +Cc: qemu-devel
On Thu, 2020-07-30 at 10:12 +0200, David Hildenbrand wrote:
> On 30.07.20 09:58, Stefano Garzarella wrote:
> > On Thu, Jul 30, 2020 at 09:51:19AM +0200, David Hildenbrand wrote:
> > > On 30.07.20 09:49, Stefano Garzarella wrote:
> > > > On Wed, Jul 29, 2020 at 06:54:38PM -0600, Bruce Rogers wrote:
> > > > > 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.
> > > > >
> > > > > Signed-off-by: Bruce Rogers <brogers@suse.com>
> > > > > ---
> > > > > hw/virtio/virtio-mem.c | 2 +-
> > > > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > > > >
> > > > > diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c
> > > > > index c12e9f79b0..fd01ffd83e 100644
> > > > > --- a/hw/virtio/virtio-mem.c
> > > > > +++ b/hw/virtio/virtio-mem.c
> > > > > @@ -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?
> > >
> > > 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
> >
> > Yeah, it is cleaner.
>
> Bruce, can you respin if you agree? Thanks!
>
Agreed.
- Bruce
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-07-30 12:52 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-07-30 0:54 [PATCH] virtio-mem: Work around format specifier mismatch for RISC-V Bruce Rogers
2020-07-30 7:49 ` Stefano Garzarella
2020-07-30 7:51 ` David Hildenbrand
2020-07-30 7:58 ` Stefano Garzarella
2020-07-30 8:12 ` David Hildenbrand
2020-07-30 12:51 ` Bruce Rogers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).