[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH] linuxNodeInfoCPUPopulate: avoid used-uninitialized via a test



See the comment:

>From 1b200ba22d742e685de0b9853c8cd276df8e129f Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering redhat com>
Date: Tue, 18 May 2010 11:58:32 +0200
Subject: [PATCH] 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.
---
 tests/nodeinfotest.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/tests/nodeinfotest.c b/tests/nodeinfotest.c
index 9aeb459..cb92215 100644
--- a/tests/nodeinfotest.c
+++ b/tests/nodeinfotest.c
@@ -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;
--
1.7.1.250.g7d1e8


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]