From nobody Sun May 5 04:35:12 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1541089927698955.5077518794931; Thu, 1 Nov 2018 09:32:07 -0700 (PDT) Received: from localhost ([::1]:42999 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gIFsu-0007eY-Vb for importer@patchew.org; Thu, 01 Nov 2018 12:31:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51017) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gIFro-0007Jt-Mo for qemu-devel@nongnu.org; Thu, 01 Nov 2018 12:30:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gIFrn-0001uy-RF for qemu-devel@nongnu.org; Thu, 01 Nov 2018 12:30:44 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:52196) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gIFrn-0001pu-HO; Thu, 01 Nov 2018 12:30:43 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1gIFrj-0002s8-DQ; Thu, 01 Nov 2018 16:30:39 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 1 Nov 2018 16:30:37 +0000 Message-Id: <20181101163037.800-1-peter.maydell@linaro.org> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PATCH for-3.1] blockdev: Consistently use snapshot_node_name in external_snapshot_prepare() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Markus Armbruster , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" In the function external_snapshot_prepare() we have a BlockdevSnapshotSync struct, which has the usual combination of has_snapshot_node_name and snapshot_node_name fields for an optional field. We set up a local variable const char *snapshot_node_name =3D s->has_snapshot_node_name ? s->snapshot_node_name : NULL; and then mostly use "if (!snapshot_node_name)" for checking whether we have a snapshot node name. The exception is that in one place we check s->has_snapshot_node_name instead. This confuses Coverity (CID 1396473), which thinks it might be possible to get here with s->has_snapshot_node_name true but snapshot_node_name NULL, and warns that the call to qdict_put_str() will segfault in that case. Make the code consistent and unconfuse Coverity by using the same check for this conditional that we do in the rest of the surrounding code. Signed-off-by: Peter Maydell Reviewed-by: Alberto Garcia --- Disclaimer: tested only with "make check"... blockdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blockdev.c b/blockdev.c index 574adbcb7f5..b24610c606e 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1639,7 +1639,7 @@ static void external_snapshot_prepare(BlkActionState = *common, } =20 options =3D qdict_new(); - if (s->has_snapshot_node_name) { + if (snapshot_node_name) { qdict_put_str(options, "node-name", snapshot_node_name); } qdict_put_str(options, "driver", format); --=20 2.19.1