* [PATCH] vfio: use matching sizeof type
@ 2024-01-17 16:03 Paolo Bonzini
2024-01-17 17:05 ` Philippe Mathieu-Daudé
2024-01-18 5:09 ` Peter Xu
0 siblings, 2 replies; 5+ messages in thread
From: Paolo Bonzini @ 2024-01-17 16:03 UTC (permalink / raw)
To: qemu-devel; +Cc: peterx
Do not use uint64_t for the type of the declaration and __u64 when
computing the number of elements in the array.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/vfio/common.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 0b3352f2a9d..0da4003ecf5 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -1118,7 +1118,7 @@ static int vfio_device_dma_logging_report(VFIODevice *vbasedev, hwaddr iova,
{
uint64_t buf[DIV_ROUND_UP(sizeof(struct vfio_device_feature) +
sizeof(struct vfio_device_feature_dma_logging_report),
- sizeof(__u64))] = {};
+ sizeof(uint64_t))] = {};
struct vfio_device_feature *feature = (struct vfio_device_feature *)buf;
struct vfio_device_feature_dma_logging_report *report =
(struct vfio_device_feature_dma_logging_report *)feature->data;
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] vfio: use matching sizeof type
2024-01-17 16:03 [PATCH] vfio: use matching sizeof type Paolo Bonzini
@ 2024-01-17 17:05 ` Philippe Mathieu-Daudé
2024-01-18 5:09 ` Peter Xu
1 sibling, 0 replies; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2024-01-17 17:05 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel; +Cc: peterx
On 17/1/24 17:03, Paolo Bonzini wrote:
> Do not use uint64_t for the type of the declaration and __u64 when
> computing the number of elements in the array.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> hw/vfio/common.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] vfio: use matching sizeof type
2024-01-17 16:03 [PATCH] vfio: use matching sizeof type Paolo Bonzini
2024-01-17 17:05 ` Philippe Mathieu-Daudé
@ 2024-01-18 5:09 ` Peter Xu
2024-01-18 7:24 ` Cédric Le Goater
2024-01-18 7:30 ` Paolo Bonzini
1 sibling, 2 replies; 5+ messages in thread
From: Peter Xu @ 2024-01-18 5:09 UTC (permalink / raw)
To: Paolo Bonzini
Cc: qemu-devel, Alex Williamson, Cédric Le Goater,
Philippe Mathieu-Daudé
On Wed, Jan 17, 2024 at 05:03:44PM +0100, Paolo Bonzini wrote:
> Do not use uint64_t for the type of the declaration and __u64 when
> computing the number of elements in the array.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> hw/vfio/common.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/vfio/common.c b/hw/vfio/common.c
> index 0b3352f2a9d..0da4003ecf5 100644
> --- a/hw/vfio/common.c
> +++ b/hw/vfio/common.c
> @@ -1118,7 +1118,7 @@ static int vfio_device_dma_logging_report(VFIODevice *vbasedev, hwaddr iova,
> {
> uint64_t buf[DIV_ROUND_UP(sizeof(struct vfio_device_feature) +
> sizeof(struct vfio_device_feature_dma_logging_report),
> - sizeof(__u64))] = {};
> + sizeof(uint64_t))] = {};
> struct vfio_device_feature *feature = (struct vfio_device_feature *)buf;
> struct vfio_device_feature_dma_logging_report *report =
> (struct vfio_device_feature_dma_logging_report *)feature->data;
There seem to have other places in the sme file that reference __u64. Are
we going to remove all __u64 references? Or maybe something else?
Copy Alex/Cedric to make sure this won't get lost..
Thanks,
--
Peter Xu
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] vfio: use matching sizeof type
2024-01-18 5:09 ` Peter Xu
@ 2024-01-18 7:24 ` Cédric Le Goater
2024-01-18 7:30 ` Paolo Bonzini
1 sibling, 0 replies; 5+ messages in thread
From: Cédric Le Goater @ 2024-01-18 7:24 UTC (permalink / raw)
To: Peter Xu, Paolo Bonzini
Cc: qemu-devel, Alex Williamson, Philippe Mathieu-Daudé
On 1/18/24 06:09, Peter Xu wrote:
> On Wed, Jan 17, 2024 at 05:03:44PM +0100, Paolo Bonzini wrote:
>> Do not use uint64_t for the type of the declaration and __u64 when
>> computing the number of elements in the array.
>>
>> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
>> ---
>> hw/vfio/common.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/hw/vfio/common.c b/hw/vfio/common.c
>> index 0b3352f2a9d..0da4003ecf5 100644
>> --- a/hw/vfio/common.c
>> +++ b/hw/vfio/common.c
>> @@ -1118,7 +1118,7 @@ static int vfio_device_dma_logging_report(VFIODevice *vbasedev, hwaddr iova,
>> {
>> uint64_t buf[DIV_ROUND_UP(sizeof(struct vfio_device_feature) +
>> sizeof(struct vfio_device_feature_dma_logging_report),
>> - sizeof(__u64))] = {};
>> + sizeof(uint64_t))] = {};
>> struct vfio_device_feature *feature = (struct vfio_device_feature *)buf;
>> struct vfio_device_feature_dma_logging_report *report =
>> (struct vfio_device_feature_dma_logging_report *)feature->data;
>
> There seem to have other places in the sme file that reference __u64. Are
> we going to remove all __u64 references? Or maybe something else?
AFAIUI, this change is to match the types of the 'buf' array and
the one used by sizeof.
> Copy Alex/Cedric to make sure this won't get lost..
Applied to vfio-next.
Thanks,
C.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] vfio: use matching sizeof type
2024-01-18 5:09 ` Peter Xu
2024-01-18 7:24 ` Cédric Le Goater
@ 2024-01-18 7:30 ` Paolo Bonzini
1 sibling, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2024-01-18 7:30 UTC (permalink / raw)
To: Peter Xu
Cc: qemu-devel, Alex Williamson, Cédric Le Goater,
Philippe Mathieu-Daudé
[-- Attachment #1: Type: text/plain, Size: 1634 bytes --]
Il gio 18 gen 2024, 06:09 Peter Xu <peterx@redhat.com> ha scritto:
> On Wed, Jan 17, 2024 at 05:03:44PM +0100, Paolo Bonzini wrote:
> > Do not use uint64_t for the type of the declaration and __u64 when
> > computing the number of elements in the array.
> >
> > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> > ---
> > hw/vfio/common.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/hw/vfio/common.c b/hw/vfio/common.c
> > index 0b3352f2a9d..0da4003ecf5 100644
> > --- a/hw/vfio/common.c
> > +++ b/hw/vfio/common.c
> > @@ -1118,7 +1118,7 @@ static int
> vfio_device_dma_logging_report(VFIODevice *vbasedev, hwaddr iova,
> > {
> > uint64_t buf[DIV_ROUND_UP(sizeof(struct vfio_device_feature) +
> > sizeof(struct
> vfio_device_feature_dma_logging_report),
> > - sizeof(__u64))] = {};
> > + sizeof(uint64_t))] = {};
> > struct vfio_device_feature *feature = (struct vfio_device_feature
> *)buf;
> > struct vfio_device_feature_dma_logging_report *report =
> > (struct vfio_device_feature_dma_logging_report *)feature->data;
>
> There seem to have other places in the sme file that reference __u64. Are
> we going to remove all __u64 references? Or maybe something else?
>
I wanted to remove those that are unnecessary, but in some cases you have
to keep __u64, because you don't know that __u64 and uint64_t are the same
type (so e.g. they could have incompatible pointer types and printf
specifiers).
Paolo
> Copy Alex/Cedric to make sure this won't get lost..
>
> Thanks,
>
> --
> Peter Xu
>
>
[-- Attachment #2: Type: text/html, Size: 2503 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-01-18 7:32 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-17 16:03 [PATCH] vfio: use matching sizeof type Paolo Bonzini
2024-01-17 17:05 ` Philippe Mathieu-Daudé
2024-01-18 5:09 ` Peter Xu
2024-01-18 7:24 ` Cédric Le Goater
2024-01-18 7:30 ` Paolo Bonzini
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).