From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40731) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VsUWe-0006Dp-3T for qemu-devel@nongnu.org; Mon, 16 Dec 2013 04:31:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VsUWV-0002Bj-Kg for qemu-devel@nongnu.org; Mon, 16 Dec 2013 04:31:44 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54322) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VsUWV-0002BC-CL for qemu-devel@nongnu.org; Mon, 16 Dec 2013 04:31:35 -0500 From: Gerd Hoffmann Date: Mon, 16 Dec 2013 10:31:14 +0100 Message-Id: <1387186277-9573-14-git-send-email-kraxel@redhat.com> In-Reply-To: <1387186277-9573-1-git-send-email-kraxel@redhat.com> References: <1387186277-9573-1-git-send-email-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH 13/16] nbd: avoid uninitialized warnings List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Gerd Hoffmann , Stefan Hajnoczi From: Marc-Andr=C3=A9 Lureau =3D=3D15815=3D=3D Thread 1: =3D=3D15815=3D=3D Syscall param socketcall.sendto(msg) points to uninitia= lised byte(s) =3D=3D15815=3D=3D at 0x65AD5CB: send (send.c:31) =3D=3D15815=3D=3D by 0x37F84B: nbd_wr_sync (nbd.c:145) =3D=3D15815=3D=3D by 0x37F94B: write_sync (nbd.c:186) =3D=3D15815=3D=3D by 0x380FA9: nbd_send_request (nbd.c:681) =3D=3D15815=3D=3D by 0x1C4A2D: nbd_teardown_connection (nbd-client.c:3= 37) =3D=3D15815=3D=3D by 0x1C4AD8: nbd_client_session_close (nbd-client.c:= 354) =3D=3D15815=3D=3D by 0x1ED2D8: close_socketpair (spicebd.c:132) =3D=3D15815=3D=3D by 0x1EE265: spice_close (spicebd.c:457) =3D=3D15815=3D=3D by 0x1ACBF6: bdrv_close (block.c:1519) =3D=3D15815=3D=3D by 0x1AD804: bdrv_delete (block.c:1772) =3D=3D15815=3D=3D by 0x1B4136: bdrv_unref (block.c:4476) =3D=3D15815=3D=3D by 0x1ACCE0: bdrv_close (block.c:1541) =3D=3D15815=3D=3D Address 0x7feffef98 is on thread 1's stack Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Paolo Bonzini Signed-off-by: Gerd Hoffmann --- block/nbd-client.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/block/nbd-client.c b/block/nbd-client.c index 1973cf0..0922b78 100644 --- a/block/nbd-client.c +++ b/block/nbd-client.c @@ -185,11 +185,10 @@ static int nbd_co_readv_1(NbdClientSession *client,= int64_t sector_num, int nb_sectors, QEMUIOVector *qiov, int offset) { - struct nbd_request request; + struct nbd_request request =3D { .type =3D NBD_CMD_READ }; struct nbd_reply reply; ssize_t ret; =20 - request.type =3D NBD_CMD_READ; request.from =3D sector_num * 512; request.len =3D nb_sectors * 512; =20 @@ -209,11 +208,10 @@ static int nbd_co_writev_1(NbdClientSession *client= , int64_t sector_num, int nb_sectors, QEMUIOVector *qiov, int offset) { - struct nbd_request request; + struct nbd_request request =3D { .type =3D NBD_CMD_WRITE }; struct nbd_reply reply; ssize_t ret; =20 - request.type =3D NBD_CMD_WRITE; if (!bdrv_enable_write_cache(client->bs) && (client->nbdflags & NBD_FLAG_SEND_FUA)) { request.type |=3D NBD_CMD_FLAG_FUA; @@ -275,7 +273,7 @@ int nbd_client_session_co_writev(NbdClientSession *cl= ient, int64_t sector_num, =20 int nbd_client_session_co_flush(NbdClientSession *client) { - struct nbd_request request; + struct nbd_request request =3D { .type =3D NBD_CMD_FLUSH }; struct nbd_reply reply; ssize_t ret; =20 @@ -283,7 +281,6 @@ int nbd_client_session_co_flush(NbdClientSession *cli= ent) return 0; } =20 - request.type =3D NBD_CMD_FLUSH; if (client->nbdflags & NBD_FLAG_SEND_FUA) { request.type |=3D NBD_CMD_FLAG_FUA; } @@ -305,14 +302,13 @@ int nbd_client_session_co_flush(NbdClientSession *c= lient) int nbd_client_session_co_discard(NbdClientSession *client, int64_t sect= or_num, int nb_sectors) { - struct nbd_request request; + struct nbd_request request =3D { .type =3D NBD_CMD_TRIM }; struct nbd_reply reply; ssize_t ret; =20 if (!(client->nbdflags & NBD_FLAG_SEND_TRIM)) { return 0; } - request.type =3D NBD_CMD_TRIM; request.from =3D sector_num * 512; request.len =3D nb_sectors * 512; =20 @@ -330,11 +326,12 @@ int nbd_client_session_co_discard(NbdClientSession = *client, int64_t sector_num, =20 static void nbd_teardown_connection(NbdClientSession *client) { - struct nbd_request request; + struct nbd_request request =3D { + .type =3D NBD_CMD_DISC, + .from =3D 0, + .len =3D 0 + }; =20 - request.type =3D NBD_CMD_DISC; - request.from =3D 0; - request.len =3D 0; nbd_send_request(client->sock, &request); =20 /* finish any pending coroutines */ --=20 1.8.3.1