Skip to contentSkip to conversation

hw: set_netdev: make peers an empty

PATCH In review Li Qiang 2 participants 2 messages Nov 8, 2018

lore
Share & tools
lore

Li Qiang

author
#0 lore raw

PATCH 1/1 hw: set_netdev: make peers an empty

Though there is no inconsistency between 'queues' and 'peers[i]' currently, this makes the 'peers[i] == NULL' meaningful.

---
 hw/core/qdev-properties-system.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/core/qdev-properties-system.c +1 -1
index 8b22fb51c9..74004a2f33 100644
@@ -257,7 +257,7 @@ static void set_netdev(Object *obj, Visitor *v, const char *name,
     Property *prop = opaque;
     NICPeers *peers_ptr = qdev_get_prop_ptr(dev, prop);
     NetClientState **ncs = peers_ptr->ncs;
-    NetClientState *peers[MAX_QUEUE_NUM];
+    NetClientState *peers[MAX_QUEUE_NUM] = {NULL};
     Error *local_err = NULL;
     int queues, err = 0, i = 0;
     char *str;
Signature · 1 line
2.17.1
#1 lore raw
Quoted 15 lines · Li Qiang

Though there is no inconsistency between 'queues' and 'peers[i]' currently, this makes the 'peers[i] == NULL' meaningful.

---
 hw/core/qdev-properties-system.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/core/qdev-properties-system.c +0 -0
index 8b22fb51c9..74004a2f33 100644

hw/core/qdev-properties-system.c static void set_netdev(Object *obj, Visitor *v, const char *name, · line 263

Quoted 8 lines
hw/core/qdev-properties-system.c +1 -1
@@ -257,7 +257,7 @@ static void set_netdev(Object *obj, Visitor *v, const char *name,
     Property *prop = opaque;
     NICPeers *peers_ptr = qdev_get_prop_ptr(dev, prop);
     NetClientState **ncs = peers_ptr->ncs;
-    NetClientState *peers[MAX_QUEUE_NUM];
+    NetClientState *peers[MAX_QUEUE_NUM] = {NULL};
     Error *local_err = NULL;
     int queues, err = 0, i = 0;
     char *str;

peers[] is initialized by qemu_find_net_clients_excep() until "queues" entries. So between 0 and "queues" peers[] cannot be NULL.

IMHO, you should remove the "if (peers[i] == NULL)" block instead.

Thanks,
Laurent