[libvirt] [PATCH 0/2] Build fixes after metadata series

Some people reported a few issues on different systems/compilers. Series pushed under the build-breaker rule. Peter Krempa (2): conf: Avoid false positive of uninitialized variable use virsh: Don't shadow global variable "remove" in cmdMetadata src/conf/domain_conf.c | 9 +++------ tools/virsh-domain.c | 6 +++--- 2 files changed, 6 insertions(+), 9 deletions(-) -- 1.8.3.2

GCC 4.8.0+ whines about variable "new" being uninitialized since commit 73bfac0e7182a3abd. This is a false positive as the xmlFreeNode(new) statement can be only reached if new was actually allocated successfully. CC conf/libvirt_conf_la-domain_conf.lo conf/domain_conf.c: In function 'virDomainDefSetMetadata': conf/domain_conf.c:18650:24: error: 'new' may be used uninitialized in this function [-Werror=maybe-uninitialized] xmlFreeNode(new); Reported independently by John Ferlan and Michal Privoznik. --- src/conf/domain_conf.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 60f25ab..e5fe900 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -18598,7 +18598,7 @@ virDomainDefSetMetadata(virDomainDefPtr def, { xmlDocPtr doc = NULL; xmlNodePtr old; - xmlNodePtr new; + xmlNodePtr new = NULL; char *tmp; int ret = -1; @@ -18647,11 +18647,8 @@ virDomainDefSetMetadata(virDomainDefPtr def, xmlFreeNode(old); } - /* just delete the metadata */ - if (!metadata) - break; - - if (!(xmlAddChild(def->metadata, new))) { + if (new && + !(xmlAddChild(def->metadata, new))) { xmlFreeNode(new); virReportOOMError(); goto cleanup; -- 1.8.3.2

Some systems apparently have a global variable/function called remove and thus break compilation of virsh-domain.c. Rename the variable to avoid this. Reported by GuanQiang. --- tools/virsh-domain.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 801b5dd..49cd154 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -6854,7 +6854,7 @@ cmdMetadata(vshControl *ctl, const vshCmd *cmd) bool live = vshCommandOptBool(cmd, "live"); bool current = vshCommandOptBool(cmd, "current"); bool edit = vshCommandOptBool(cmd, "edit"); - bool remove = vshCommandOptBool(cmd, "remove"); + bool rem = vshCommandOptBool(cmd, "remove"); const char *set = NULL; const char *uri = NULL; const char *key = NULL; @@ -6886,12 +6886,12 @@ cmdMetadata(vshControl *ctl, const vshCmd *cmd) goto cleanup; } - if (set || remove) { + if (set || rem) { if (virDomainSetMetadata(dom, VIR_DOMAIN_METADATA_ELEMENT, set, key, uri, flags)) goto cleanup; - if (remove) + if (rem) vshPrint("%s\n", _("Metadata removed")); else vshPrint("%s\n", _("Metadata modified")); -- 1.8.3.2
participants (1)
-
Peter Krempa