[virt-tools-list] [PATCH 10/11] fix used-uninitialized bugs

Jim Meyering jim at meyering.net
Fri Jan 29 14:58:51 UTC 2010


From: Jim Meyering <meyering at redhat.com>

* src/osi_device.c (dev_property_all_values): Initialize "kv" to NULL
to avoid using it uninitialized when there is no match.
* src/osi_hv.c (osi_get_hv_property_all_values): Likewise.
* src/osi_os.c (os_property_all_values): Likewise.
* src/osi_hv.c (osi_get_hv_property_first_value): Likewise.
* src/osi_os.c (osi_get_os_property_first_value): Likewise.
* src/osi_device.c (osi_get_device_property_value): Likewise.
---
 src/osi_device.c |    6 ++++--
 src/osi_hv.c     |    6 ++++--
 src/osi_os.c     |    6 ++++--
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/src/osi_device.c b/src/osi_device.c
index 1936861..8936fdb 100644
--- a/src/osi_device.c
+++ b/src/osi_device.c
@@ -28,7 +28,8 @@ static char** dev_property_all_values(struct osi_internal_dev * dev,
 {
     int i;
     char** property_values;
-    struct osi_keyval_multi * kv, * test_kv;
+    struct osi_keyval_multi *kv = NULL;
+    struct osi_keyval_multi *test_kv;
     struct list_head * cursor;
     struct osi_value * value;

@@ -634,7 +635,8 @@ char* osi_get_device_property_value(osi_device_t dev, char* propname, int* err)
 {
     char* value;
     struct osi_internal_dev * internal_dev;
-    struct osi_keyval_multi * kv, * test_kv;
+    struct osi_keyval_multi *kv = NULL;
+    struct osi_keyval_multi *test_kv;
     struct list_head * cursor;
     struct osi_value * value_container;

diff --git a/src/osi_hv.c b/src/osi_hv.c
index 3e53926..9b233a4 100644
--- a/src/osi_hv.c
+++ b/src/osi_hv.c
@@ -293,7 +293,8 @@ char** osi_get_hv_property_all_values(osi_hypervisor_t hv, char* propname, int*
     int i;
     char** property_values;
     struct osi_internal_hv * internal_hv;
-    struct osi_keyval_multi * kv, * test_kv;
+    struct osi_keyval_multi *kv = NULL;
+    struct osi_keyval_multi *test_kv;
     struct list_head * cursor;
     struct osi_value * value;

@@ -355,7 +356,8 @@ char* osi_get_hv_property_first_value(osi_hypervisor_t hv, char* propname, int*
 {
     char* value;
     struct osi_internal_hv * internal_hv;
-    struct osi_keyval_multi * kv, * test_kv;
+    struct osi_keyval_multi *kv = NULL;
+    struct osi_keyval_multi *test_kv;
     struct list_head * cursor;
     struct osi_value * value_container;

diff --git a/src/osi_os.c b/src/osi_os.c
index 03a80c0..21128e1 100644
--- a/src/osi_os.c
+++ b/src/osi_os.c
@@ -13,7 +13,8 @@ static char** os_property_all_values(struct osi_internal_os * os,
 {
     int i;
     char** property_values;
-    struct osi_keyval_multi * kv, * test_kv;
+    struct osi_keyval_multi *kv = NULL;
+    struct osi_keyval_multi *test_kv;
     struct list_head * cursor;
     struct osi_value * value;

@@ -677,7 +678,8 @@ char* osi_get_os_property_first_value(osi_os_t os, char* propname, int* err)
 {
     char* value;
     struct osi_internal_os * internal_os;
-    struct osi_keyval_multi * kv, * test_kv;
+    struct osi_keyval_multi *kv = NULL;
+    struct osi_keyval_multi *test_kv;
     struct list_head * cursor;
     struct osi_value * value_container;

-- 
1.7.0.rc0.187.g226c




More information about the virt-tools-list mailing list