mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
linuxNodeInfoCPUPopulate: avoid used-uninitialized via a test
* tests/nodeinfotest.c (linuxTestCompareFiles): Don't use nodeinfo->member uninitialized. linuxNodeInfoCPUPopulate requires that some of its nodeinfo members (including threads) be initialized upon input. The nodeinfotest.c program lacked the initialization, while the only other use (nodeGetInfo) did perform it. It's not trivial to move the initialization into the function, since nodeGetInfo sets at least one member after clearing the buffer but before calling linuxNodeInfoCPUPopulate.
This commit is contained in:
parent
4d2adaa1d5
commit
43beb82eca
@ -40,6 +40,8 @@ static int linuxTestCompareFiles(const char *cpuinfofile, const char *outputfile
|
||||
cpuinfo = fopen(cpuinfofile, "r");
|
||||
if (!cpuinfo)
|
||||
return -1;
|
||||
|
||||
memset(&nodeinfo, 0, sizeof(nodeinfo));
|
||||
if (linuxNodeInfoCPUPopulate(cpuinfo, &nodeinfo) < 0) {
|
||||
fclose(cpuinfo);
|
||||
return -1;
|
||||
|
Loading…
Reference in New Issue
Block a user