[Qemu-devel] [PATCH] hw: set_netdev: make peers an empty

Li Qiang posted 1 patch 5 years, 5 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20181108143306.20187-1-liq3ea@163.com
Test docker-clang@ubuntu passed
Test checkpatch passed
Test asan passed
Test docker-mingw@fedora passed
Test docker-quick@centos7 passed
hw/core/qdev-properties-system.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[Qemu-devel] [PATCH] hw: set_netdev: make peers an empty
Posted by Li Qiang 5 years, 5 months ago
Though there is no inconsistency between 'queues'
and 'peers[i]' currently, this makes the 'peers[i] == NULL'
meaningful.

Signed-off-by: Li Qiang <liq3ea@163.com>
---
 hw/core/qdev-properties-system.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
index 8b22fb51c9..74004a2f33 100644
--- a/hw/core/qdev-properties-system.c
+++ b/hw/core/qdev-properties-system.c
@@ -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;
-- 
2.17.1



Re: [Qemu-devel] [PATCH] hw: set_netdev: make peers an empty
Posted by Laurent Vivier 5 years, 5 months ago
On 08/11/2018 15:33, Li Qiang wrote:
> Though there is no inconsistency between 'queues'
> and 'peers[i]' currently, this makes the 'peers[i] == NULL'
> meaningful.
> 
> Signed-off-by: Li Qiang <liq3ea@163.com>
> ---
>  hw/core/qdev-properties-system.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-system.c
> index 8b22fb51c9..74004a2f33 100644
> --- a/hw/core/qdev-properties-system.c
> +++ b/hw/core/qdev-properties-system.c
> @@ -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