qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] hw: set_netdev: make peers an empty
@ 2018-11-08 14:33 Li Qiang
  2018-11-08 14:43 ` Laurent Vivier
  0 siblings, 1 reply; 2+ messages in thread
From: Li Qiang @ 2018-11-08 14:33 UTC (permalink / raw)
  To: stefanha, marcandre.lureau, lvivier; +Cc: qemu-devel, Li Qiang

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] hw: set_netdev: make peers an empty
  2018-11-08 14:33 [Qemu-devel] [PATCH] hw: set_netdev: make peers an empty Li Qiang
@ 2018-11-08 14:43 ` Laurent Vivier
  0 siblings, 0 replies; 2+ messages in thread
From: Laurent Vivier @ 2018-11-08 14:43 UTC (permalink / raw)
  To: Li Qiang, stefanha, marcandre.lureau; +Cc: qemu-devel

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-11-08 14:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-08 14:33 [Qemu-devel] [PATCH] hw: set_netdev: make peers an empty Li Qiang
2018-11-08 14:43 ` Laurent Vivier

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).