From patchwork Sun Dec 1 21:23:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marc-Andr=C3=A9_Lureau?= X-Patchwork-Id: 295727 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D4C1B2C0098 for ; Mon, 2 Dec 2013 08:52:59 +1100 (EST) Received: from localhost ([::1]:32978 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VnEb6-0006Tz-Ep for incoming@patchwork.ozlabs.org; Sun, 01 Dec 2013 16:30:36 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51872) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VnEVa-0007Kn-4Y for qemu-devel@nongnu.org; Sun, 01 Dec 2013 16:25:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VnEVQ-000852-RC for qemu-devel@nongnu.org; Sun, 01 Dec 2013 16:24:54 -0500 Received: from mail-qe0-x234.google.com ([2607:f8b0:400d:c02::234]:64275) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VnEVQ-00084w-Gw for qemu-devel@nongnu.org; Sun, 01 Dec 2013 16:24:44 -0500 Received: by mail-qe0-f52.google.com with SMTP id ne12so12233714qeb.25 for ; Sun, 01 Dec 2013 13:24:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=ILlQcQXYtucZPKI6WQxo8B+9vMYOU23+1Y2/IPj0QSU=; b=EDsD6jLTEi+JfiOe2n2aozeE+1mb5u71aXj2+2LnKVK4DlVQiSRpklfI+fiYjQArgJ aVSm8Y5H3W8//k7UgQb+0vJSTE+6Rr3uYigdX1cyAVFzghc9ijXr32wlThbV8oRnSeLS 0UnPl5pe7WowyN3xrSCnBeL2UynOBaBDxMTILRsyDESGXTqWOvzA7YkPkL6sHWI3u1o8 ywEQWBLHuMbO1+Ax2vPI4g3VRPr2474WaZVaSUonAYEpkVtH6ggQIV9orznjh0O8neWm +owFzj1bczRe9bzyCO65Ux5xjB9okJvVc2fAlpQil5JoBzV3O9n0Ar4qZwGjYo1Y67bi 5zIw== X-Received: by 10.224.64.196 with SMTP id f4mr72774118qai.55.1385933083780; Sun, 01 Dec 2013 13:24:43 -0800 (PST) Received: from localhost (105.Red-83-60-241.dynamicIP.rima-tde.net. [83.60.241.105]) by mx.google.com with ESMTPSA id x10sm114924040qas.5.2013.12.01.13.24.41 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Dec 2013 13:24:43 -0800 (PST) From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= To: qemu-devel@nongnu.org Date: Sun, 1 Dec 2013 22:23:46 +0100 Message-Id: <1385933027-21261-14-git-send-email-marcandre.lureau@gmail.com> X-Mailer: git-send-email 1.8.4.2 In-Reply-To: <1385933027-21261-1-git-send-email-marcandre.lureau@gmail.com> References: <1385933027-21261-1-git-send-email-marcandre.lureau@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400d:c02::234 Cc: pbonzini@redhat.com, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , kraxel@redhat.com Subject: [Qemu-devel] [PATCHv2 13/14] nbd: avoid uninitialized warnings X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org ==15815== Thread 1: ==15815== Syscall param socketcall.sendto(msg) points to uninitialised byte(s) ==15815== at 0x65AD5CB: send (send.c:31) ==15815== by 0x37F84B: nbd_wr_sync (nbd.c:145) ==15815== by 0x37F94B: write_sync (nbd.c:186) ==15815== by 0x380FA9: nbd_send_request (nbd.c:681) ==15815== by 0x1C4A2D: nbd_teardown_connection (nbd-client.c:337) ==15815== by 0x1C4AD8: nbd_client_session_close (nbd-client.c:354) ==15815== by 0x1ED2D8: close_socketpair (spicebd.c:132) ==15815== by 0x1EE265: spice_close (spicebd.c:457) ==15815== by 0x1ACBF6: bdrv_close (block.c:1519) ==15815== by 0x1AD804: bdrv_delete (block.c:1772) ==15815== by 0x1B4136: bdrv_unref (block.c:4476) ==15815== by 0x1ACCE0: bdrv_close (block.c:1541) ==15815== Address 0x7feffef98 is on thread 1's stack Signed-off-by: Marc-André Lureau --- 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 = { .type = NBD_CMD_READ }; struct nbd_reply reply; ssize_t ret; - request.type = NBD_CMD_READ; request.from = sector_num * 512; request.len = nb_sectors * 512; @@ -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 = { .type = NBD_CMD_WRITE }; struct nbd_reply reply; ssize_t ret; - request.type = NBD_CMD_WRITE; if (!bdrv_enable_write_cache(client->bs) && (client->nbdflags & NBD_FLAG_SEND_FUA)) { request.type |= NBD_CMD_FLAG_FUA; @@ -275,7 +273,7 @@ int nbd_client_session_co_writev(NbdClientSession *client, int64_t sector_num, int nbd_client_session_co_flush(NbdClientSession *client) { - struct nbd_request request; + struct nbd_request request = { .type = NBD_CMD_FLUSH }; struct nbd_reply reply; ssize_t ret; @@ -283,7 +281,6 @@ int nbd_client_session_co_flush(NbdClientSession *client) return 0; } - request.type = NBD_CMD_FLUSH; if (client->nbdflags & NBD_FLAG_SEND_FUA) { request.type |= NBD_CMD_FLAG_FUA; } @@ -305,14 +302,13 @@ int nbd_client_session_co_flush(NbdClientSession *client) int nbd_client_session_co_discard(NbdClientSession *client, int64_t sector_num, int nb_sectors) { - struct nbd_request request; + struct nbd_request request = { .type = NBD_CMD_TRIM }; struct nbd_reply reply; ssize_t ret; if (!(client->nbdflags & NBD_FLAG_SEND_TRIM)) { return 0; } - request.type = NBD_CMD_TRIM; request.from = sector_num * 512; request.len = nb_sectors * 512; @@ -330,11 +326,12 @@ int nbd_client_session_co_discard(NbdClientSession *client, int64_t sector_num, static void nbd_teardown_connection(NbdClientSession *client) { - struct nbd_request request; + struct nbd_request request = { + .type = NBD_CMD_DISC, + .from = 0, + .len = 0 + }; - request.type = NBD_CMD_DISC; - request.from = 0; - request.len = 0; nbd_send_request(client->sock, &request); /* finish any pending coroutines */