From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55053) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gIG0T-0003nX-Qr for qemu-devel@nongnu.org; Thu, 01 Nov 2018 12:39:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gIG0N-0000Oc-5a for qemu-devel@nongnu.org; Thu, 01 Nov 2018 12:39:41 -0400 From: Alberto Garcia In-Reply-To: <20181101163037.800-1-peter.maydell@linaro.org> References: <20181101163037.800-1-peter.maydell@linaro.org> Date: Thu, 01 Nov 2018 17:38:33 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [Qemu-block] [PATCH for-3.1] blockdev: Consistently use snapshot_node_name in external_snapshot_prepare() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell , qemu-devel@nongnu.org Cc: Kevin Wolf , Markus Armbruster , qemu-block@nongnu.org, Max Reitz On Thu 01 Nov 2018 05:30:37 PM CET, Peter Maydell wrote: > 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 Berto