From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60074) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XrL8V-00049D-Rr for qemu-devel@nongnu.org; Thu, 20 Nov 2014 01:22:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XrL8R-0004jL-07 for qemu-devel@nongnu.org; Thu, 20 Nov 2014 01:22:35 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46145) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XrL8Q-0004jF-NB for qemu-devel@nongnu.org; Thu, 20 Nov 2014 01:22:30 -0500 Message-ID: <546D8896.2020801@redhat.com> Date: Thu, 20 Nov 2014 14:22:14 +0800 From: Jason Wang MIME-Version: 1.0 References: <1416463034-8264-1-git-send-email-arei.gonglei@huawei.com> <1416463034-8264-3-git-send-email-arei.gonglei@huawei.com> In-Reply-To: <1416463034-8264-3-git-send-email-arei.gonglei@huawei.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 2/4] net/socket: fix Uninitialized scalar variable List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: arei.gonglei@huawei.com, qemu-devel@nongnu.org Cc: pbonzini@redhat.com, peter.huangpeng@huawei.com, stefanha@redhat.com On 11/20/2014 01:57 PM, arei.gonglei@huawei.com wrote: > From: Gonglei > > 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 > --- > 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