[libvirt] [PATCH] cmdPoolDiscoverSources: initialize earlier to avoid FP from clang

This change hoists the initialization of srcSpec to the top, to keep clang from reporting a false-positive used-uninitialized problem.
From f487655124c887310be3bc82d7beae3cd47e7d21 Mon Sep 17 00:00:00 2001 From: Jim Meyering <meyering@redhat.com> Date: Mon, 1 Mar 2010 15:41:15 +0100 Subject: [PATCH] cmdPoolDiscoverSources: initialize earlier to avoid FP from clang
* tools/virsh.c (cmdPoolDiscoverSources): Always initialize srcSpec. Otherwise, clang would report that srcSpec could be used uninitialized in the call to virConnectFindStoragePoolSources. --- tools/virsh.c | 7 +++---- 1 files changed, 3 insertions(+), 4 deletions(-) diff --git a/tools/virsh.c b/tools/virsh.c index 3b1011c..191e7ba 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -4431,17 +4431,16 @@ static const vshCmdOptDef opts_find_storage_pool_sources[] = { static int cmdPoolDiscoverSources(vshControl * ctl, const vshCmd * cmd ATTRIBUTE_UNUSED) { - char *type, *srcSpec, *srcSpecFile, *srcList; + char *type, *srcSpecFile, *srcList; + char *srcSpec = NULL; int found; type = vshCommandOptString(cmd, "type", &found); if (!found) return FALSE; srcSpecFile = vshCommandOptString(cmd, "srcSpec", &found); - if (!found) { + if (!found) srcSpecFile = NULL; - srcSpec = NULL; - } if (!vshConnectionUsability(ctl, ctl->conn, TRUE)) return FALSE; -- 1.7.0.1.414.g89213d

According to Jim Meyering on 3/1/2010 7:45 AM:
This change hoists the initialization of srcSpec to the top, to keep clang from reporting a false-positive used-uninitialized problem.
Subject: [PATCH] cmdPoolDiscoverSources: initialize earlier to avoid FP from clang
* tools/virsh.c (cmdPoolDiscoverSources): Always initialize srcSpec.
ACK. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org
participants (2)
-
Eric Blake
-
Jim Meyering