提交 0d4f469c 编写于 作者: P Peter Krempa

conf: Avoid false positive of uninitialized variable use

GCC 4.8.0+ whines about variable "new" being uninitialized since
commit 73bfac0e. 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.
上级 716c7bb1
...@@ -18598,7 +18598,7 @@ virDomainDefSetMetadata(virDomainDefPtr def, ...@@ -18598,7 +18598,7 @@ virDomainDefSetMetadata(virDomainDefPtr def,
{ {
xmlDocPtr doc = NULL; xmlDocPtr doc = NULL;
xmlNodePtr old; xmlNodePtr old;
xmlNodePtr new; xmlNodePtr new = NULL;
char *tmp; char *tmp;
int ret = -1; int ret = -1;
...@@ -18647,11 +18647,8 @@ virDomainDefSetMetadata(virDomainDefPtr def, ...@@ -18647,11 +18647,8 @@ virDomainDefSetMetadata(virDomainDefPtr def,
xmlFreeNode(old); xmlFreeNode(old);
} }
/* just delete the metadata */ if (new &&
if (!metadata) !(xmlAddChild(def->metadata, new))) {
break;
if (!(xmlAddChild(def->metadata, new))) {
xmlFreeNode(new); xmlFreeNode(new);
virReportOOMError(); virReportOOMError();
goto cleanup; goto cleanup;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册