Here's another distracting and easily avoided error:
$ valgrind --leak-check=full ./virsh --connect test://$PWD/../docs/testnode.xml list
==13150== Conditional jump or move depends on uninitialised value(s)
==13150== at 0x4177DE: testLoadDomain (test.c:324)
==13150== by 0x417BA4: testLoadDomainFromFile (test.c:401)
==13150== by 0x418E52: testOpenFromFile (test.c:797)
==13150== by 0x4192C9: testOpen (test.c:913)
==13150== by 0x40FA20: do_open (libvirt.c:572)
==13150== by 0x40FDE4: virConnectOpenAuth (libvirt.c:681)
==13150== by 0x40D5B1: vshInit (virsh.c:4464)
==13150== by 0x40E67C: main (virsh.c:4985)
==13150==
==13150== Conditional jump or move depends on uninitialised value(s)
==13150== at 0x417F0D: testLoadNetwork (test.c:486)
==13150== by 0x4183AA: testLoadNetworkFromFile (test.c:577)
==13150== by 0x418F81: testOpenFromFile (test.c:822)
==13150== by 0x4192C9: testOpen (test.c:913)
==13150== by 0x40FA20: do_open (libvirt.c:572)
==13150== by 0x40FDE4: virConnectOpenAuth (libvirt.c:681)
==13150== by 0x40D5B1: vshInit (virsh.c:4464)
==13150== by 0x40E67C: main (virsh.c:4985)
==13150==
==13150== Conditional jump or move depends on uninitialised value(s)
==13150== at 0x41955B: testNumOfDomains (test.c:1020)
==13150== by 0x4104B9: virConnectNumOfDomains (libvirt.c:940)
==13150== by 0x405363: cmdList (virsh.c:557)
==13150== by 0x40C5F9: vshCommandRun (virsh.c:4032)
==13150== by 0x40E6AF: main (virsh.c:4991)
Id Name State
----------------------------------
1 fv0 running
2 fc4 running
This patch fixes it:
* src/test.c (testOpenFromFile): avoid used-uninitialized errors in test driver
---
src/test.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/test.c b/src/test.c
index 85170d9..fe5da41 100644
--- a/src/test.c
+++ b/src/test.c
@@ -672,7 +672,7 @@ static int testOpenFromFile(virConnectPtr conn,
xmlNodePtr *domains, *networks = NULL;
xmlXPathContextPtr ctxt = NULL;
virNodeInfoPtr nodeInfo;
- testConnPtr privconn = malloc(sizeof(*privconn));
+ testConnPtr privconn = calloc(1, sizeof(*privconn));
if (!privconn) {
testError(NULL, NULL, NULL, VIR_ERR_NO_MEMORY, "testConn");
return VIR_DRV_OPEN_ERROR;
--
1.5.4.rc5.1.g0fa73