Skip to contentSkip to conversation

util: vfio-helpers: use ARRAY_SIZE in qemu_vfio_init_pci()

PATCH Applied Li Qiang 4 participants 5 messages Nov 30, 2018 – Dec 7, 2018

lore
Share & tools
lore

Li Qiang

author
#0 lore raw

PATCH 1/1 util: vfio-helpers: use ARRAY_SIZE in qemu_vfio_init_pci()

---
 util/vfio-helpers.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
util/vfio-helpers.c +1 -1
index cccc9cd42e..342d4a2285 100644
@@ -348,7 +348,7 @@ static int qemu_vfio_init_pci(QEMUVFIOState *s, const char *device,
         goto fail;
     }
 
-    for (i = 0; i < 6; i++) {
+    for (i = 0; i < ARRAY_SIZE(s->bar_region_info); i++) {
         ret = qemu_vfio_pci_init_bar(s, i, errp);
         if (ret) {
             goto fail;
Signature · 1 line
2.11.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Li Qiang
Quoted 18 lines
---
 util/vfio-helpers.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
util/vfio-helpers.c +1 -1
index cccc9cd42e..342d4a2285 100644
@@ -348,7 +348,7 @@ static int qemu_vfio_init_pci(QEMUVFIOState *s, const char *device,
         goto fail;
     }
 
-    for (i = 0; i < 6; i++) {
+    for (i = 0; i < ARRAY_SIZE(s->bar_region_info); i++) {
         ret = qemu_vfio_pci_init_bar(s, i, errp);
         if (ret) {
             goto fail;
#2 lore raw
Quoted 19 lines · Philippe Mathieu-Daudé
Quoted 3 lines · Li Qiang
Quoted 12 lines
---
 util/vfio-helpers.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
util/vfio-helpers.c +0 -0
index cccc9cd42e..342d4a2285 100644
@@ -348,7 +348,7 @@ static int qemu_vfio_init_pci(QEMUVFIOState *s, const char *device,
         goto fail;
     }
 
Quoted 6 lines

util/vfio-helpers.c static int qemu_vfio_init_pci(QEMUVFIOState *s, const char *device, · line 354

Quoted 6 lines
util/vfio-helpers.c +1 -1
-    for (i = 0; i < 6; i++) {
+    for (i = 0; i < ARRAY_SIZE(s->bar_region_info); i++) {
         ret = qemu_vfio_pci_init_bar(s, i, errp);
         if (ret) {
             goto fail;

I'm wondering if adding a #define to define the size of the array and then using it with the for() loop wouldn't be better?

Laurent

#3 lore raw
Quoted 5 lines · Laurent Vivier
Quoted 2 lines

util/vfio-helpers.c static int qemu_vfio_init_pci(QEMUVFIOState *s, const char *device, · line 351

Quoted 2 lines
util/vfio-helpers.c +1 -1
-    for (i = 0; i < 6; i++) {
+    for (i = 0; i < ARRAY_SIZE(s->bar_region_info); i++) {

I'm wondering if adding a #define to define the size of the array and then using it with the for() loop wouldn't be better?

On the other side, it doesn't really matter, one way or another.. It's so.. trivial.. ;)

/mjt

#4 lore raw
In reply to Li Qiang

Le 30/11/2018 à 10:53, Li Qiang a écrit :

Quoted 13 lines
---
 util/vfio-helpers.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
util/vfio-helpers.c +0 -0
index cccc9cd42e..342d4a2285 100644

util/vfio-helpers.c static int qemu_vfio_init_pci(QEMUVFIOState *s, const char *device, · line 354

Quoted 8 lines
util/vfio-helpers.c +1 -1
@@ -348,7 +348,7 @@ static int qemu_vfio_init_pci(QEMUVFIOState *s, const char *device,
         goto fail;
     }
 
-    for (i = 0; i < 6; i++) {
+    for (i = 0; i < ARRAY_SIZE(s->bar_region_info); i++) {
         ret = qemu_vfio_pci_init_bar(s, i, errp);
         if (ret) {
             goto fail;

Applied to my trivial-patches branch.

Thanks,
Laurent