Given code like if (foo) free (foo); remove the useless "if (foo) " part.

Likewise, given if (foo != NULL) free (foo); remove the useless "if" test.

* proxy/libvirt_proxy.c: Remove unnecessary "if" test before free.
* python/generator.py: Likewise.
* qemud/qemud.c: Likewise.
* src/buf.c: Likewise.
* src/conf.c: Likewise.
* src/hash.c: Likewise.
* src/iptables.c: Likewise.
* src/libvirt.c: Likewise.
* src/openvz_conf.c: Likewise.
* src/qemu_conf.c: Likewise.
* src/qemu_driver.c: Likewise.
* src/remote_internal.c: Likewise.
* src/test.c: Likewise.
* src/virsh.c: Likewise.
* src/virterror.c: Likewise.
* src/xen_internal.c: Likewise.
* src/xen_unified.c: Likewise.
* src/xend_internal.c: Likewise.
* src/xm_internal.c: Likewise.
* src/xml.c: Likewise.
* src/xmlrpc.c: Likewise.
* src/xs_internal.c: Likewise.
* tests/testutils.c: Likewise.
* tests/xencapstest.c: Likewise.
* tests/xmconfigtest.c: Likewise.
This commit is contained in:
Jim Meyering
2008-01-29 17:41:07 +00:00
parent b17caa80d1
commit acff2d11ac
26 changed files with 143 additions and 211 deletions

View File

@@ -1,3 +1,34 @@
Tue Jan 29 18:39:25 CET 2008 Jim Meyering <meyering@redhat.com>
Given code like if (foo) free (foo); remove the useless "if (foo) " part
Likewise, given if (foo != NULL) free (foo); remove the useless "if"
test.
* proxy/libvirt_proxy.c: Remove unnecessary "if" test before free.
* python/generator.py: Likewise.
* qemud/qemud.c: Likewise.
* src/buf.c: Likewise.
* src/conf.c: Likewise.
* src/hash.c: Likewise.
* src/iptables.c: Likewise.
* src/libvirt.c: Likewise.
* src/openvz_conf.c: Likewise.
* src/qemu_conf.c: Likewise.
* src/qemu_driver.c: Likewise.
* src/remote_internal.c: Likewise.
* src/test.c: Likewise.
* src/virsh.c: Likewise.
* src/virterror.c: Likewise.
* src/xen_internal.c: Likewise.
* src/xen_unified.c: Likewise.
* src/xend_internal.c: Likewise.
* src/xm_internal.c: Likewise.
* src/xml.c: Likewise.
* src/xmlrpc.c: Likewise.
* src/xs_internal.c: Likewise.
* tests/testutils.c: Likewise.
* tests/xencapstest.c: Likewise.
* tests/xmconfigtest.c: Likewise.
Fri Jan 25 12:00:00 BST 2008 Richard W.M. Jones <rjones@redhat.com> Fri Jan 25 12:00:00 BST 2008 Richard W.M. Jones <rjones@redhat.com>
Clarify virsh documentation. Clarify virsh documentation.

View File

@@ -505,7 +505,6 @@ retry2:
memcpy(&request.extra.str[0], uuid, VIR_UUID_BUFLEN); memcpy(&request.extra.str[0], uuid, VIR_UUID_BUFLEN);
strcpy(&request.extra.str[VIR_UUID_BUFLEN], name); strcpy(&request.extra.str[VIR_UUID_BUFLEN], name);
} }
if (name)
free(name); free(name);
break; break;
} }

View File

@@ -375,7 +375,7 @@ def print_function_wrapper(name, output, export, include):
if ret[0] == 'void': if ret[0] == 'void':
if file == "python_accessor": if file == "python_accessor":
if args[1][1] == "char *": if args[1][1] == "char *":
c_call = "\n if (%s->%s != NULL) free(%s->%s);\n" % ( c_call = "\n free(%s->%s);\n" % (
args[0][0], args[1][0], args[0][0], args[1][0]) args[0][0], args[1][0], args[0][0], args[1][0])
c_call = c_call + " %s->%s = (%s)strdup((const xmlChar *)%s);\n" % (args[0][0], c_call = c_call + " %s->%s = (%s)strdup((const xmlChar *)%s);\n" % (args[0][0],
args[1][0], args[1][1], args[1][0]) args[1][0], args[1][1], args[1][0])

View File

@@ -1133,7 +1133,7 @@ static void qemudDispatchClientFailure(struct qemud_server *server, struct qemud
#if HAVE_SASL #if HAVE_SASL
if (client->saslconn) sasl_dispose(&client->saslconn); if (client->saslconn) sasl_dispose(&client->saslconn);
if (client->saslUsername) free(client->saslUsername); free(client->saslUsername);
#endif #endif
if (client->tlssession) gnutls_deinit (client->tlssession); if (client->tlssession) gnutls_deinit (client->tlssession);
close(client->fd); close(client->fd);
@@ -1639,7 +1639,6 @@ static void qemudCleanup(struct qemud_server *server) {
if (server->saslUsernameWhitelist) { if (server->saslUsernameWhitelist) {
char **list = server->saslUsernameWhitelist; char **list = server->saslUsernameWhitelist;
while (*list) { while (*list) {
if (*list)
free(*list); free(*list);
list++; list++;
} }

View File

@@ -150,7 +150,6 @@ void
virBufferFree(virBufferPtr buf) virBufferFree(virBufferPtr buf)
{ {
if (buf) { if (buf) {
if (buf->content)
free(buf->content); free(buf->content);
free(buf); free(buf);
} }

View File

@@ -490,7 +490,6 @@ virConfParseValue(virConfParserCtxtPtr ctxt)
ret = calloc(1, sizeof(*ret)); ret = calloc(1, sizeof(*ret));
if (ret == NULL) { if (ret == NULL) {
virConfError(NULL, VIR_ERR_NO_MEMORY, _("allocating configuration"), 0); virConfError(NULL, VIR_ERR_NO_MEMORY, _("allocating configuration"), 0);
if (str != NULL)
free(str); free(str);
return(NULL); return(NULL);
} }
@@ -642,7 +641,6 @@ virConfParseStatement(virConfParserCtxtPtr ctxt)
if (virConfAddEntry(ctxt->conf, name, value, comm) == NULL) { if (virConfAddEntry(ctxt->conf, name, value, comm) == NULL) {
free(name); free(name);
virConfFreeValue(value); virConfFreeValue(value);
if (comm != NULL)
free(comm); free(comm);
return(-1); return(-1);
} }
@@ -776,7 +774,6 @@ __virConfFree(virConfPtr conf)
virConfEntryPtr next; virConfEntryPtr next;
free(tmp->name); free(tmp->name);
virConfFreeValue(tmp->value); virConfFreeValue(tmp->value);
if (tmp->comment)
free(tmp->comment); free(tmp->comment);
next = tmp->next; next = tmp->next;
free(tmp); free(tmp);

View File

@@ -226,7 +226,6 @@ virHashFree(virHashTablePtr table, virHashDeallocator f)
next = iter->next; next = iter->next;
if ((f != NULL) && (iter->payload != NULL)) if ((f != NULL) && (iter->payload != NULL))
f(iter->payload, iter->name); f(iter->payload, iter->name);
if (iter->name)
free(iter->name); free(iter->name);
iter->payload = NULL; iter->payload = NULL;
if (!inside_table) if (!inside_table)
@@ -453,7 +452,6 @@ virHashRemoveEntry(virHashTablePtr table, const char *name,
if ((f != NULL) && (entry->payload != NULL)) if ((f != NULL) && (entry->payload != NULL))
f(entry->payload, entry->name); f(entry->payload, entry->name);
entry->payload = NULL; entry->payload = NULL;
if (entry->name)
free(entry->name); free(entry->name);
if (prev) { if (prev) {
prev->next = entry->next; prev->next = entry->next;
@@ -538,7 +536,6 @@ int virHashRemoveSet(virHashTablePtr table, virHashSearcher iter, virHashDealloc
if (iter(entry->payload, entry->name, data)) { if (iter(entry->payload, entry->name, data)) {
count++; count++;
f(entry->payload, entry->name); f(entry->payload, entry->name);
if (entry->name)
free(entry->name); free(entry->name);
if (prev) { if (prev) {
prev->next = entry->next; prev->next = entry->next;
@@ -812,7 +809,6 @@ __virGetDomain(virConnectPtr conn, const char *name, const unsigned char *uuid)
error: error:
pthread_mutex_unlock(&conn->lock); pthread_mutex_unlock(&conn->lock);
if (ret != NULL) { if (ret != NULL) {
if (ret->name != NULL)
free(ret->name ); free(ret->name );
free(ret); free(ret);
} }
@@ -946,7 +942,6 @@ __virGetNetwork(virConnectPtr conn, const char *name, const unsigned char *uuid)
error: error:
pthread_mutex_unlock(&conn->lock); pthread_mutex_unlock(&conn->lock);
if (ret != NULL) { if (ret != NULL) {
if (ret->name != NULL)
free(ret->name ); free(ret->name );
free(ret); free(ret);
} }

View File

@@ -254,7 +254,6 @@ iptRulesSave(iptRules *rules)
static void static void
iptRuleFree(iptRule *rule) iptRuleFree(iptRule *rule)
{ {
if (rule->rule)
free(rule->rule); free(rule->rule);
rule->rule = NULL; rule->rule = NULL;
@@ -488,7 +487,6 @@ iptablesAddRemoveRule(iptRules *rules, int action, const char *arg, ...)
} }
error: error:
if (rule)
free(rule); free(rule);
if (argv) { if (argv) {

View File

@@ -615,7 +615,7 @@ do_open (const char *name,
return ret; return ret;
failed: failed:
if (ret->name) free (ret->name); free (ret->name);
if (ret->driver) ret->driver->close (ret); if (ret->driver) ret->driver->close (ret);
if (uri) xmlFreeURI(uri); if (uri) xmlFreeURI(uri);
virUnrefConnect(ret); virUnrefConnect(ret);
@@ -1974,8 +1974,8 @@ virDomainMigrate (virDomainPtr domain,
ddomain = virDomainLookupByName (dconn, dname); ddomain = virDomainLookupByName (dconn, dname);
done: done:
if (uri_out) free (uri_out); free (uri_out);
if (cookie) free (cookie); free (cookie);
return ddomain; return ddomain;
} }

View File

@@ -494,7 +494,6 @@ static struct openvz_vm_def
return def; return def;
bail_out: bail_out:
if (prop)
free(prop); free(prop);
if (obj) if (obj)
xmlXPathFreeObject(obj); xmlXPathFreeObject(obj);

View File

@@ -1379,7 +1379,6 @@ static struct qemud_vm_def *qemudParseXML(virConnectPtr conn,
return def; return def;
error: error:
if (prop)
free(prop); free(prop);
if (obj) if (obj)
xmlXPathFreeObject(obj); xmlXPathFreeObject(obj);
@@ -1468,7 +1467,6 @@ qemudNetworkIfaceConnect(virConnectPtr conn,
no_memory: no_memory:
qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "tapfds"); qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "tapfds");
error: error:
if (retval)
free(retval); free(retval);
if (tapfd != -1) if (tapfd != -1)
close(tapfd); close(tapfd);
@@ -1941,7 +1939,7 @@ qemudParseVMDeviceDef(virConnectPtr conn,
error: error:
if (xml) xmlFreeDoc(xml); if (xml) xmlFreeDoc(xml);
if (dev) free(dev); free(dev);
return NULL; return NULL;
} }

View File

@@ -228,7 +228,7 @@ qemudStartup(void) {
out_of_memory: out_of_memory:
qemudLog (QEMUD_ERR, "qemudStartup: out of memory"); qemudLog (QEMUD_ERR, "qemudStartup: out of memory");
if (base) free (base); free (base);
free(qemu_driver); free(qemu_driver);
qemu_driver = NULL; qemu_driver = NULL;
return -1; return -1;
@@ -330,16 +330,10 @@ qemudShutdown(void) {
qemu_driver->nactivenetworks = 0; qemu_driver->nactivenetworks = 0;
qemu_driver->ninactivenetworks = 0; qemu_driver->ninactivenetworks = 0;
if (qemu_driver->configDir)
free(qemu_driver->configDir); free(qemu_driver->configDir);
if (qemu_driver->autostartDir)
free(qemu_driver->autostartDir); free(qemu_driver->autostartDir);
if (qemu_driver->networkConfigDir)
free(qemu_driver->networkConfigDir); free(qemu_driver->networkConfigDir);
if (qemu_driver->networkAutostartDir)
free(qemu_driver->networkAutostartDir); free(qemu_driver->networkAutostartDir);
if (qemu_driver->vncTLSx509certdir)
free(qemu_driver->vncTLSx509certdir); free(qemu_driver->vncTLSx509certdir);
if (qemu_driver->brctl) if (qemu_driver->brctl)

View File

@@ -735,13 +735,13 @@ doRemoteOpen (virConnectPtr conn,
cleanup: cleanup:
/* Free up the URL and strings. */ /* Free up the URL and strings. */
if (name) free (name); free (name);
if (command) free (command); free (command);
if (sockname) free (sockname); free (sockname);
if (authtype) free (authtype); free (authtype);
if (netcat) free (netcat); free (netcat);
if (username) free (username); free (username);
if (port) free (port); free (port);
if (cmd_argv) { if (cmd_argv) {
char **cmd_argv_ptr = cmd_argv; char **cmd_argv_ptr = cmd_argv;
while (*cmd_argv_ptr) { while (*cmd_argv_ptr) {
@@ -1139,10 +1139,10 @@ doRemoteClose (virConnectPtr conn, struct private_data *priv)
#endif #endif
/* Free hostname copy */ /* Free hostname copy */
if (priv->hostname) free (priv->hostname); free (priv->hostname);
/* See comment for remoteType. */ /* See comment for remoteType. */
if (priv->type) free (priv->type); free (priv->type);
/* Free private data. */ /* Free private data. */
priv->magic = DEAD; priv->magic = DEAD;
@@ -3267,7 +3267,7 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open,
/* This server call shows complete, and earlier client step was OK */ /* This server call shows complete, and earlier client step was OK */
if (complete && err == SASL_OK) { if (complete && err == SASL_OK) {
if (serverin) free(serverin); free(serverin);
break; break;
} }
} }
@@ -3297,9 +3297,9 @@ remoteAuthSASL (virConnectPtr conn, struct private_data *priv, int in_open,
ret = 0; ret = 0;
cleanup: cleanup:
if (localAddr) free(localAddr); free(localAddr);
if (remoteAddr) free(remoteAddr); free(remoteAddr);
if (serverin) free(serverin); free(serverin);
free(saslcb); free(saslcb);
remoteAuthFreeCredentials(cred, ncred); remoteAuthFreeCredentials(cred, ncred);

View File

@@ -354,7 +354,6 @@ static int testLoadDomain(virConnectPtr conn,
return (handle); return (handle);
error: error:
if (name)
free(name); free(name);
return (-1); return (-1);
} }
@@ -525,15 +524,10 @@ static int testLoadNetwork(virConnectPtr conn,
return (handle); return (handle);
error: error:
if (ipaddress)
free(ipaddress); free(ipaddress);
if (ipnetmask)
free(ipnetmask); free(ipnetmask);
if (dhcpstart)
free(dhcpstart); free(dhcpstart);
if (dhcpend)
free(dhcpend); free(dhcpend);
if (name)
free(name); free(name);
return (-1); return (-1);
} }
@@ -838,9 +832,7 @@ static int testOpenFromFile(virConnectPtr conn,
return (0); return (0);
error: error:
if (domains != NULL)
free(domains); free(domains);
if (networks != NULL)
free(networks); free(networks);
if (xml) if (xml)
xmlFreeDoc(xml); xmlFreeDoc(xml);

View File

@@ -428,7 +428,6 @@ cmdConnect(vshControl * ctl, vshCmd * cmd)
ctl->conn = NULL; ctl->conn = NULL;
} }
if (ctl->name)
free(ctl->name); free(ctl->name);
ctl->name = vshStrdup(ctl, vshCommandOptString(cmd, "name", NULL)); ctl->name = vshStrdup(ctl, vshCommandOptString(cmd, "name", NULL));
@@ -577,7 +576,6 @@ cmdList(vshControl * ctl, vshCmd * cmd ATTRIBUTE_UNUSED)
maxname = virConnectNumOfDefinedDomains(ctl->conn); maxname = virConnectNumOfDefinedDomains(ctl->conn);
if (maxname < 0) { if (maxname < 0) {
vshError(ctl, FALSE, "%s", _("Failed to list inactive domains")); vshError(ctl, FALSE, "%s", _("Failed to list inactive domains"));
if (ids)
free(ids); free(ids);
return FALSE; return FALSE;
} }
@@ -586,7 +584,6 @@ cmdList(vshControl * ctl, vshCmd * cmd ATTRIBUTE_UNUSED)
if ((maxname = virConnectListDefinedDomains(ctl->conn, names, maxname)) < 0) { if ((maxname = virConnectListDefinedDomains(ctl->conn, names, maxname)) < 0) {
vshError(ctl, FALSE, "%s", _("Failed to list inactive domains")); vshError(ctl, FALSE, "%s", _("Failed to list inactive domains"));
if (ids)
free(ids); free(ids);
free(names); free(names);
return FALSE; return FALSE;
@@ -639,9 +636,7 @@ cmdList(vshControl * ctl, vshCmd * cmd ATTRIBUTE_UNUSED)
virDomainFree(dom); virDomainFree(dom);
free(names[i]); free(names[i]);
} }
if (ids)
free(ids); free(ids);
if (names)
free(names); free(names);
return TRUE; return TRUE;
} }
@@ -1217,7 +1212,6 @@ cmdSchedinfo(vshControl * ctl, vshCmd * cmd)
} }
} }
cleanup: cleanup:
if (params)
free(params); free(params);
virDomainFree(dom); virDomainFree(dom);
return ret_val; return ret_val;
@@ -2513,7 +2507,6 @@ cmdNetworkList(vshControl * ctl, vshCmd * cmd ATTRIBUTE_UNUSED)
maxinactive = virConnectNumOfDefinedNetworks(ctl->conn); maxinactive = virConnectNumOfDefinedNetworks(ctl->conn);
if (maxinactive < 0) { if (maxinactive < 0) {
vshError(ctl, FALSE, "%s", _("Failed to list inactive networks")); vshError(ctl, FALSE, "%s", _("Failed to list inactive networks"));
if (activeNames)
free(activeNames); free(activeNames);
return FALSE; return FALSE;
} }
@@ -2522,7 +2515,6 @@ cmdNetworkList(vshControl * ctl, vshCmd * cmd ATTRIBUTE_UNUSED)
if ((maxinactive = virConnectListDefinedNetworks(ctl->conn, inactiveNames, maxinactive)) < 0) { if ((maxinactive = virConnectListDefinedNetworks(ctl->conn, inactiveNames, maxinactive)) < 0) {
vshError(ctl, FALSE, "%s", _("Failed to list inactive networks")); vshError(ctl, FALSE, "%s", _("Failed to list inactive networks"));
if (activeNames)
free(activeNames); free(activeNames);
free(inactiveNames); free(inactiveNames);
return FALSE; return FALSE;
@@ -2581,9 +2573,7 @@ cmdNetworkList(vshControl * ctl, vshCmd * cmd ATTRIBUTE_UNUSED)
virNetworkFree(network); virNetworkFree(network);
free(inactiveNames[i]); free(inactiveNames[i]);
} }
if (activeNames)
free(activeNames); free(activeNames);
if (inactiveNames)
free(inactiveNames); free(inactiveNames);
return TRUE; return TRUE;
} }
@@ -3230,9 +3220,7 @@ cmdAttachInterface(vshControl * ctl, vshCmd * cmd)
cleanup: cleanup:
if (dom) if (dom)
virDomainFree(dom); virDomainFree(dom);
if (buf)
free(buf); free(buf);
if (tmp)
free(tmp); free(tmp);
return ret; return ret;
} }
@@ -3516,9 +3504,7 @@ cmdAttachDisk(vshControl * ctl, vshCmd * cmd)
cleanup: cleanup:
if (dom) if (dom)
virDomainFree(dom); virDomainFree(dom);
if (buf)
free(buf); free(buf);
if (tmp)
free(tmp); free(tmp);
return ret; return ret;
} }
@@ -3868,7 +3854,6 @@ vshCommandOptFree(vshCmdOpt * arg)
a = a->next; a = a->next;
if (tmp->data)
free(tmp->data); free(tmp->data);
free(tmp); free(tmp);
} }
@@ -4267,7 +4252,7 @@ vshCommandParse(vshControl * ctl, char *cmdstr)
c->next = NULL; c->next = NULL;
if (!vshCommandCheckOpts(ctl, c)) { if (!vshCommandCheckOpts(ctl, c)) {
if(c) free(c); free(c);
goto syntaxError; goto syntaxError;
} }
@@ -4286,7 +4271,6 @@ vshCommandParse(vshControl * ctl, char *cmdstr)
vshCommandFree(ctl->cmd); vshCommandFree(ctl->cmd);
if (first) if (first)
vshCommandOptFree(first); vshCommandOptFree(first);
if (tkdata)
free(tkdata); free(tkdata);
return FALSE; return FALSE;
} }
@@ -4791,7 +4775,6 @@ static int
vshDeinit(vshControl * ctl) vshDeinit(vshControl * ctl)
{ {
vshCloseLogFile(ctl); vshCloseLogFile(ctl);
if (ctl->name)
free(ctl->name); free(ctl->name);
if (ctl->conn) { if (ctl->conn) {
if (virConnectClose(ctl->conn) != 0) { if (virConnectClose(ctl->conn) != 0) {

View File

@@ -109,13 +109,9 @@ virResetError(virErrorPtr err)
{ {
if (err == NULL) if (err == NULL)
return; return;
if (err->message != NULL)
free(err->message); free(err->message);
if (err->str1 != NULL)
free(err->str1); free(err->str1);
if (err->str2 != NULL)
free(err->str2); free(err->str2);
if (err->str3 != NULL)
free(err->str3); free(err->str3);
memset(err, 0, sizeof(virError)); memset(err, 0, sizeof(virError));
} }

View File

@@ -1680,7 +1680,6 @@ virXen_setvcpumap(int handle, int id, unsigned int vcpu,
op.u.setvcpumapd5.cpumap.nr_cpus = nr_cpus; op.u.setvcpumapd5.cpumap.nr_cpus = nr_cpus;
} }
ret = xenHypervisorDoV2Dom(handle, &op); ret = xenHypervisorDoV2Dom(handle, &op);
if (new)
free(new); free(new);
if (unlock_pages(cpumap, maplen) < 0) { if (unlock_pages(cpumap, maplen) < 0) {
@@ -2056,14 +2055,12 @@ xenHypervisorInit(void)
virXenError(NULL, VIR_ERR_XEN_CALL, " ioctl ", IOCTL_PRIVCMD_HYPERCALL); virXenError(NULL, VIR_ERR_XEN_CALL, " ioctl ", IOCTL_PRIVCMD_HYPERCALL);
close(fd); close(fd);
in_init = 0; in_init = 0;
if (ipt)
free(ipt); free(ipt);
return(-1); return(-1);
done: done:
close(fd); close(fd);
in_init = 0; in_init = 0;
if (ipt)
free(ipt); free(ipt);
return(0); return(0);
} }

View File

@@ -200,11 +200,8 @@ xenDomainUsedCpus(virDomainPtr dom)
} }
done: done:
if (cpulist != NULL)
free(cpulist); free(cpulist);
if (cpumap != NULL)
free(cpumap); free(cpumap);
if (cpuinfo != NULL)
free(cpuinfo); free(cpuinfo);
return(res); return(res);
} }
@@ -912,7 +909,6 @@ xenUnifiedDomainDumpXML (virDomainPtr dom, int flags)
char *cpus, *res; char *cpus, *res;
cpus = xenDomainUsedCpus(dom); cpus = xenDomainUsedCpus(dom);
res = xenDaemonDomainDumpXML(dom, flags, cpus); res = xenDaemonDomainDumpXML(dom, flags, cpus);
if (cpus != NULL)
free(cpus); free(cpus);
return(res); return(res);
} }

View File

@@ -620,7 +620,6 @@ xend_op_ext2(virConnectPtr xend, const char *path, char *error,
} }
ret = http2unix(xend, xend_post(xend, path, buf.content, error, n_error)); ret = http2unix(xend, xend_post(xend, path, buf.content, error, n_error));
if (buf.content != NULL)
free(buf.content); free(buf.content);
return ret; return ret;
@@ -1640,9 +1639,7 @@ xend_parse_sexp_desc(virConnectPtr conn, struct sexpr *root,
virBufferAdd(&buf, " </disk>\n", 12); virBufferAdd(&buf, " </disk>\n", 12);
bad_parse: bad_parse:
if (drvName)
free(drvName); free(drvName);
if (drvType)
free(drvType); free(drvType);
} else if (sexpr_lookup(node, "device/vif")) { } else if (sexpr_lookup(node, "device/vif")) {
const char *tmp2; const char *tmp2;
@@ -1809,7 +1806,6 @@ xend_parse_sexp_desc(virConnectPtr conn, struct sexpr *root,
return (buf.content); return (buf.content);
error: error:
if (buf.content != NULL)
free(buf.content); free(buf.content);
return (NULL); return (NULL);
} }
@@ -2809,7 +2805,6 @@ xenDaemonListDomains(virConnectPtr conn, int *ids, int maxids)
} }
error: error:
if (root != NULL)
sexpr_free(root); sexpr_free(root);
return(ret); return(ret);
} }
@@ -2843,7 +2838,6 @@ xenDaemonNumOfDomains(virConnectPtr conn)
} }
error: error:
if (root != NULL)
sexpr_free(root); sexpr_free(root);
return(ret); return(ret);
} }
@@ -2877,7 +2871,6 @@ xenDaemonLookupByID(virConnectPtr conn, int id) {
return (ret); return (ret);
error: error:
if (name != NULL)
free(name); free(name);
return (NULL); return (NULL);
} }
@@ -3152,9 +3145,7 @@ xenDaemonCreateLinux(virConnectPtr conn, const char *xmlDesc,
sexpr = virDomainParseXMLDesc(conn, xmlDesc, &name, priv->xendConfigVersion); sexpr = virDomainParseXMLDesc(conn, xmlDesc, &name, priv->xendConfigVersion);
if ((sexpr == NULL) || (name == NULL)) { if ((sexpr == NULL) || (name == NULL)) {
virXendError(conn, VIR_ERR_XML_ERROR, "domain"); virXendError(conn, VIR_ERR_XML_ERROR, "domain");
if (sexpr != NULL)
free(sexpr); free(sexpr);
if (name != NULL)
free(name); free(name);
return (NULL); return (NULL);
@@ -3187,7 +3178,6 @@ xenDaemonCreateLinux(virConnectPtr conn, const char *xmlDesc,
xenDaemonDomainDestroy(dom); xenDaemonDomainDestroy(dom);
virUnrefDomain(dom); virUnrefDomain(dom);
} }
if (name != NULL)
free(name); free(name);
return (NULL); return (NULL);
} }
@@ -3228,7 +3218,6 @@ xenDaemonAttachDevice(virDomainPtr domain, const char *xml)
str = virDomainGetOSType(domain); str = virDomainGetOSType(domain);
if (strcmp(str, "linux")) if (strcmp(str, "linux"))
hvm = 1; hvm = 1;
if (str)
free(str); free(str);
sexpr = virParseXMLDevice(domain->conn, xml, hvm, priv->xendConfigVersion); sexpr = virParseXMLDevice(domain->conn, xml, hvm, priv->xendConfigVersion);
if (sexpr == NULL) if (sexpr == NULL)
@@ -3460,9 +3449,7 @@ virDomainPtr xenDaemonDomainDefineXML(virConnectPtr conn, const char *xmlDesc) {
sexpr = virDomainParseXMLDesc(conn, xmlDesc, &name, priv->xendConfigVersion); sexpr = virDomainParseXMLDesc(conn, xmlDesc, &name, priv->xendConfigVersion);
if ((sexpr == NULL) || (name == NULL)) { if ((sexpr == NULL) || (name == NULL)) {
virXendError(conn, VIR_ERR_XML_ERROR, "domain"); virXendError(conn, VIR_ERR_XML_ERROR, "domain");
if (sexpr != NULL)
free(sexpr); free(sexpr);
if (name != NULL)
free(name); free(name);
return (NULL); return (NULL);
@@ -3482,7 +3469,6 @@ virDomainPtr xenDaemonDomainDefineXML(virConnectPtr conn, const char *xmlDesc) {
return (dom); return (dom);
error: error:
if (name != NULL)
free(name); free(name);
return (NULL); return (NULL);
} }
@@ -3558,7 +3544,6 @@ xenDaemonNumOfDefinedDomains(virConnectPtr conn)
} }
error: error:
if (root != NULL)
sexpr_free(root); sexpr_free(root);
return(ret); return(ret);
} }
@@ -3591,7 +3576,6 @@ int xenDaemonListDefinedDomains(virConnectPtr conn, char **const names, int maxn
} }
error: error:
if (root != NULL)
sexpr_free(root); sexpr_free(root);
return(ret); return(ret);
} }

View File

@@ -1307,9 +1307,7 @@ int xenXMDomainPinVcpu(virDomainPtr domain,
ret = 0; ret = 0;
cleanup: cleanup:
if(mapstr)
free(mapstr); free(mapstr);
if(ranges)
free(ranges); free(ranges);
return (ret); return (ret);
} }
@@ -1865,7 +1863,6 @@ static char *xenXMParseXMLVif(virConnectPtr conn, xmlNodePtr node, int hvm) {
} }
cleanup: cleanup:
if (bridge != NULL)
free(bridge); free(bridge);
if (mac != NULL) if (mac != NULL)
xmlFree(mac); xmlFree(mac);
@@ -2238,7 +2235,6 @@ virConfPtr xenXMParseXMLToConfig(virConnectPtr conn, const char *xml) {
if (!vif) if (!vif)
goto error; goto error;
if (!(thisVif = malloc(sizeof(*thisVif)))) { if (!(thisVif = malloc(sizeof(*thisVif)))) {
if (vif)
free(vif); free(vif);
xenXMError(conn, VIR_ERR_NO_MEMORY, "config"); xenXMError(conn, VIR_ERR_NO_MEMORY, "config");
goto error; goto error;
@@ -2410,7 +2406,6 @@ virDomainPtr xenXMDomainDefineXML(virConnectPtr conn, const char *xml) {
return (ret); return (ret);
error: error:
if (entry)
free(entry); free(entry);
if (conf) if (conf)
virConfFree(conf); virConfFree(conf);

View File

@@ -397,13 +397,11 @@ virParseXenCpuTopology(virConnectPtr conn, virBufferPtr xml,
parse_error: parse_error:
virXMLError(conn, VIR_ERR_XEN_CALL, _("topology syntax error"), 0); virXMLError(conn, VIR_ERR_XEN_CALL, _("topology syntax error"), 0);
error: error:
if (cpuset != NULL)
free(cpuset); free(cpuset);
return (-1); return (-1);
memory_error: memory_error:
if (cpuset != NULL)
free(cpuset); free(cpuset);
virXMLError(conn, VIR_ERR_NO_MEMORY, _("allocate buffer"), 0); virXMLError(conn, VIR_ERR_NO_MEMORY, _("allocate buffer"), 0);
return (-1); return (-1);
@@ -1066,7 +1064,6 @@ virDomainParseXMLOSDescHVM(virConnectPtr conn, xmlNodePtr node,
if (str != NULL && !strcmp(str, "localtime")) { if (str != NULL && !strcmp(str, "localtime")) {
virBufferAdd(buf, "(localtime 1)", 13); virBufferAdd(buf, "(localtime 1)", 13);
} }
if (str)
free(str); free(str);
virBufferAdd(buf, "))", 2); virBufferAdd(buf, "))", 2);
@@ -1074,7 +1071,6 @@ virDomainParseXMLOSDescHVM(virConnectPtr conn, xmlNodePtr node,
return (0); return (0);
error: error:
if (nodes)
free(nodes); free(nodes);
return (-1); return (-1);
} }
@@ -1723,7 +1719,6 @@ virDomainParseXMLDesc(virConnectPtr conn, const char *xmldesc, char **name,
vcpus, xendConfigVersion); vcpus, xendConfigVersion);
} }
if (str != NULL)
free(str); free(str);
if (res != 0) if (res != 0)
@@ -1797,7 +1792,6 @@ virDomainParseXMLDesc(virConnectPtr conn, const char *xmldesc, char **name,
return (buf.content); return (buf.content);
error: error:
if (nam != NULL)
free(nam); free(nam);
if (name != NULL) if (name != NULL)
*name = NULL; *name = NULL;
@@ -1807,7 +1801,6 @@ virDomainParseXMLDesc(virConnectPtr conn, const char *xmldesc, char **name,
xmlFreeDoc(xml); xmlFreeDoc(xml);
if (pctxt != NULL) if (pctxt != NULL)
xmlFreeParserCtxt(pctxt); xmlFreeParserCtxt(pctxt);
if (buf.content != NULL)
free(buf.content); free(buf.content);
return (NULL); return (NULL);
} }

View File

@@ -115,7 +115,6 @@ static xmlRpcValuePtr xmlRpcValueUnmarshalInteger(xmlNodePtr node)
if (ret && value) if (ret && value)
ret->value.integer = atoi(value); ret->value.integer = atoi(value);
if (value)
free(value); free(value);
return ret; return ret;
} }
@@ -131,7 +130,6 @@ static xmlRpcValuePtr xmlRpcValueUnmarshalBoolean(xmlNodePtr node)
ret->value.boolean = true; ret->value.boolean = true;
else else
ret->value.boolean = false; ret->value.boolean = false;
if (value)
free(value); free(value);
return ret; return ret;
} }
@@ -143,7 +141,6 @@ static xmlRpcValuePtr xmlRpcValueUnmarshalDouble(xmlNodePtr node)
if (ret && value) if (ret && value)
ret->value.real = atof(value); ret->value.real = atof(value);
if (value)
free(value); free(value);
return ret; return ret;
} }
@@ -198,7 +195,6 @@ static xmlRpcValueDictElementPtr xmlRpcValueUnmarshalDictElement(xmlNodePtr node
ret->value = xmlRpcValueUnmarshal(cur); ret->value = xmlRpcValueUnmarshal(cur);
} else { } else {
xmlRpcError(VIR_ERR_XML_ERROR, _("unexpected dict node"), 0); xmlRpcError(VIR_ERR_XML_ERROR, _("unexpected dict node"), 0);
if (ret->name)
free(ret->name); free(ret->name);
if (ret->value) if (ret->value)
xmlRpcValueFree(ret->value); xmlRpcValueFree(ret->value);
@@ -679,12 +675,8 @@ xmlRpcContextPtr xmlRpcContextNew(const char *uri)
void xmlRpcContextFree(xmlRpcContextPtr context) void xmlRpcContextFree(xmlRpcContextPtr context)
{ {
if (context) { if (context) {
if (context->uri)
free(context->uri); free(context->uri);
if (context->faultMessage)
free(context->faultMessage); free(context->faultMessage);
free(context); free(context);
} }
} }

View File

@@ -635,9 +635,7 @@ xenStoreLookupByName(virConnectPtr conn, const char *name)
ret->id = id; ret->id = id;
done: done:
if (xenddomain != NULL)
free(xenddomain); free(xenddomain);
if (idlist != NULL)
free(idlist); free(idlist);
return(ret); return(ret);

View File

@@ -83,7 +83,6 @@ virtTestRun(const char *title, int nloops, int (*body)(const void *data), const
else else
fprintf(stderr, "%-50s ... FAILED\n", title); fprintf(stderr, "%-50s ... FAILED\n", title);
if (ts)
free(ts); free(ts);
return ret; return ret;
} }

View File

@@ -62,7 +62,6 @@ static int testCompareFiles(const char *hostmachine,
fail: fail:
if (actualxml)
free(actualxml); free(actualxml);
if (fp1) if (fp1)
fclose(fp1); fclose(fp1);

View File

@@ -153,7 +153,6 @@ static int testCompareFormatXML(const char *xmcfg_rel, const char *xml_rel,
fail: fail:
if (conf) if (conf)
virConfFree(conf); virConfFree(conf);
if (gotxml)
free(gotxml); free(gotxml);
if (conn) { if (conn) {