vfio: use matching sizeof type
PATCH 1/1 vfio: use matching sizeof type
Do not use uint64_t for the type of the declaration and __u64 when computing the number of elements in the array.
--- hw/vfio/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/vfio/common.c +1 -1
@@ -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;
Signature · 1 line
2.43.0
Quoted 7 lines · Paolo Bonzini
Do not use
uint64_tfor the type of the declaration and__u64when computing the number of elements in the array.Signed-off-by Paolo Bonzini <[email protected]>--- hw/vfio/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 13 lines · Paolo Bonzini
Do not use
uint64_tfor the type of the declaration and__u64when computing the number of elements in the array.Signed-off-by Paolo Bonzini <[email protected]>--- hw/vfio/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/vfio/common.c +0
-0
hw/vfio/common.c static int vfio_device_dma_logging_report(VFIODevice *vbasedev, hwaddr iova, · line 1124
Quoted 8 lines
hw/vfio/common.c +1
-1@@ -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,
Signature · 1 line
Peter Xu
Cédric Le Goater
AppliedQuoted 9 lines · Peter Xu
Quoted 8 lines · Paolo Bonzini
Do not use
uint64_tfor the type of the declaration and__u64when computing the number of elements in the array.Signed-off-by Paolo Bonzini <[email protected]>--- hw/vfio/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines
hw/vfio/common.c static int vfio_device_dma_logging_report(VFIODevice *vbasedev, hwaddr iova, · line 1124
Quoted 13 lines
hw/vfio/common.c +1
-1@@ -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__u64references? Or maybe something else?
AFAIUI, this change is to match the types of the 'buf' array and the one used by sizeof.
Quoted 1 line
Copy Alex/Cedric to make sure this won't get lost..
Applied to vfio-next.
Thanks,
C.
Il gio 18 gen 2024, 06:09 Peter Xu <[email protected]> ha scritto:
Quoted 22 lines · Paolo Bonzini
hw/vfio/common.c static int
Quoted 13 lines
Do not use
uint64_tfor the type of the declaration and__u64when computing the number of elements in the array.Signed-off-by Paolo Bonzini <[email protected]>--- hw/vfio/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/vfio/common.c +0
-0@@ -1118,7 +1118,7 @@ static intvfio_device_dma_logging_report(VFIODevice *vbasedev, hwaddr iova,
hw/vfio/common.c static int vfio_device_dma_logging_report(VFIODevice *vbasedev, hwaddr iova,
Quoted 3 lines
hw/vfio/common.c +0
-0{ uint64_t buf[DIV_ROUND_UP(sizeof(struct vfio_device_feature) + sizeof(struct
vfio_device_feature_dma_logging_report),hw/vfio/common.c static int vfio_device_dma_logging_report(VFIODevice *vbasedev, hwaddr iova,
Quoted 3 lines
hw/vfio/common.c +1
-1- sizeof(__u64))] = {}; + sizeof(uint64_t))] = {}; struct vfio_device_feature *feature = (struct vfio_device_feature
Quoted 7 lines
*)buf;
hw/vfio/common.c static int vfio_device_dma_logging_report(VFIODevice *vbasedev, hwaddr iova, · line 1124
Quoted 2 lines
hw/vfio/common.c +0
-0struct 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__u64references? 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
Quoted 8 lines
Copy Alex/Cedric to make sure this won't get lost..
Thanks,
--
Peter Xu