qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 2/4] net/socket: fix Uninitialized scalar variab


From: Jason Wang
Subject: Re: [Qemu-devel] [PATCH 2/4] net/socket: fix Uninitialized scalar variable
Date: Thu, 20 Nov 2014 14:22:14 +0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0

On 11/20/2014 01:57 PM, address@hidden wrote:
> From: Gonglei <address@hidden>
>
> If is_connected parameter is false, the saddr
> variable will no initialize. Coverity report:
> uninit_use: Using uninitialized value saddr.sin_port.
>
> We don't need add saddr information to nc->info_str
> when is_connected is false.
>
> Signed-off-by: Gonglei <address@hidden>
> ---
>  net/socket.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/net/socket.c b/net/socket.c
> index ca4b8ba..68a93cd 100644
> --- a/net/socket.c
> +++ b/net/socket.c
> @@ -389,11 +389,6 @@ static NetSocketState 
> *net_socket_fd_init_dgram(NetClientState *peer,
>  
>      nc = qemu_new_net_client(&net_dgram_socket_info, peer, model, name);
>  
> -    snprintf(nc->info_str, sizeof(nc->info_str),
> -            "socket: fd=%d (%s mcast=%s:%d)",
> -            fd, is_connected ? "cloned" : "",
> -            inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
> -
>      s = DO_UPCAST(NetSocketState, nc, nc);
>  
>      s->fd = fd;
> @@ -404,6 +399,12 @@ static NetSocketState 
> *net_socket_fd_init_dgram(NetClientState *peer,
>      /* mcast: save bound address as dst */
>      if (is_connected) {
>          s->dgram_dst = saddr;
> +        snprintf(nc->info_str, sizeof(nc->info_str),
> +                 "socket: fd=%d (cloned mcast=%s:%d)",
> +                 fd, inet_ntoa(saddr.sin_addr), ntohs(saddr.sin_port));
> +    } else {
> +        snprintf(nc->info_str, sizeof(nc->info_str),
> +                 "socket: fd=%d", fd);
>      }
>  
>      return s;

Reviewed-by: Jason Wang <address@hidden>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]