From patchwork Mon Nov 12 17:05:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 150855 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3383301ljp; Mon, 12 Nov 2018 09:07:43 -0800 (PST) X-Google-Smtp-Source: AJdET5eKCF6aLCOVqjmwuBCe+64OPkNjxQUnQB/sp25xdHaZ9S4C7S3zXrhNiZT1jZwO/6w/5+hh X-Received: by 2002:ac8:7691:: with SMTP id g17mr1701169qtr.388.1542042463538; Mon, 12 Nov 2018 09:07:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542042463; cv=none; d=google.com; s=arc-20160816; b=hLxM+tCmAdNBqosRbVk6hpRy2dLMdBa2TVn7h+b84roTIZgIKc+lNTsF2p/04NaWfk SC9SdBL2UvNV/CkJ9R1LuW2UzTUMF2tWc1Egh86UVbpHZ31MW++WAsdVtboXwcUFjkYe tJcwrZwhzSI/C+kAwTfnSpJ/J4ScZeFwa33Lw/XXtmeAtxEZ63tJmkvlssl1wY8zl7DN PXF85NWLcM9J2BDBRP/v0Y06g+pnlyjjnfOH/BMWj49XDjWsI5JOWdUKDV8GWtWhe+w1 efggwB6tQXjyQKZc17ix6q79iFNWiyHIv8HoLC7VpztVWj9MeG7Wb0RMC7zZLW3SJMWu dTAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from; bh=5RbRHgE0FBE/DvxDy5VI6cNC4WK1Abmo8h+jV4TDrdc=; b=QC5+5/fQ8j9YYxA6sbMjg74cf84F0uoH4tMKEcwQDkAmAQ8DrwrQtDjcQzFsw19Iwv XZqbGGl21tvY1r+uD4Tz1xD2qrkz/yDfs0rotx4e94eFo/xOuKUQOO+y4AzExYt8GJlj SmSTguQK2D2uwQNpYHPJ3sbTrayPG8GPUKs7Viom0xJv9LqZS/hMlb1hAclE50RBd2c1 4A0KLv7Y1vBE3bOUarACjdPGpYHbzaRidUJL8L5iWaU320nzVy526rUsjQWBfyafMLHY jmT/de8S0GauaZFyXsjvNQmkkHOaK1sS5n2+7zoItm0lpFxg6tfYDqhIsHJHea3EApQ/ anNw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id c19si2019384qkh.43.2018.11.12.09.07.43 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 12 Nov 2018 09:07:43 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1]:49748 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gMFgc-000194-M1 for patch@linaro.org; Mon, 12 Nov 2018 12:07:42 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59726) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gMFfF-0000HP-4Q for qemu-devel@nongnu.org; Mon, 12 Nov 2018 12:06:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gMFfE-0006n4-Bz for qemu-devel@nongnu.org; Mon, 12 Nov 2018 12:06:17 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46468) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gMFfB-0006ki-H4; Mon, 12 Nov 2018 12:06:13 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 852343082142; Mon, 12 Nov 2018 17:06:12 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-117-3.ams2.redhat.com [10.36.117.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 722DA1974C; Mon, 12 Nov 2018 17:06:11 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 12 Nov 2018 18:05:52 +0100 Message-Id: <20181112170603.23986-4-kwolf@redhat.com> In-Reply-To: <20181112170603.23986-1-kwolf@redhat.com> References: <20181112170603.23986-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Mon, 12 Nov 2018 17:06:12 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 03/14] 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: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Peter Maydell 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 = 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 Signed-off-by: Kevin Wolf --- blockdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.19.1 diff --git a/blockdev.c b/blockdev.c index 9310ff3e7c..81f95d920b 100644 --- a/blockdev.c +++ b/blockdev.c @@ -1640,7 +1640,7 @@ static void external_snapshot_prepare(BlkActionState *common, } options = 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);