On Mon, Nov 06, 2017 at 01:33:49PM +0000, Darren Kenny wrote:
Hi Jan,

On Mon, Nov 06, 2017 at 02:28:05PM +0100, Jens Freimann wrote:
This fixes coverity issue CID1005339.

Make sure that saddr is not used uninitialized if the
mcast parameter is NULL.

Cc: qemu-sta...@nongnu.org
Reported-by: Peter Maydell <peter.mayd...@linaro.org>
Signed-off-by: Jens Freimann <jfreim...@redhat.com>
---
net/socket.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/socket.c b/net/socket.c
index e6b471c63d..51eaea67a0 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -332,7 +332,7 @@ static NetSocketState 
*net_socket_fd_init_dgram(NetClientState *peer,
                                               const char *mcast,
                                               Error **errp)
{
-    struct sockaddr_in saddr;
+    struct sockaddr_in saddr = { 0 };

Based on:

 https://lists.gnu.org/archive/html/qemu-devel/2017-10/msg04946.html

It would appear that the use of {} to initialize the struct is
preferred over {0}.

Thanks for the hint Darren. I'll change it in the next version (or get
rid of the initalization completely).

regards,
Jens

Reply via email to