summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitri Pal <dpal@redhat.com>2010-12-26 21:58:24 -0500
committerStephen Gallagher <sgallagh@redhat.com>2012-04-05 11:20:09 -0700
commit56b3277a0eff7a6128f4eaf0ac31bdcdbbfcfae9 (patch)
tree764176abe94c1527e56e27462601c439666c3f30
parent0513944b4e65415a697190d716551dbeb9a0fa0d (diff)
downloadding-libs-56b3277a0eff7a6128f4eaf0ac31bdcdbbfcfae9.tar.gz
ding-libs-56b3277a0eff7a6128f4eaf0ac31bdcdbbfcfae9.tar.xz
ding-libs-56b3277a0eff7a6128f4eaf0ac31bdcdbbfcfae9.zip
Initialize variables in loops
It occured to me that one of the issues that Coverity did not like (and I could not understand what it is complaining about) is related to intializing the variables in the loop. This patch adds initialization in the loops. Also there was an initialization missing in the ini_configobj.c
-rw-r--r--ini/ini_configobj.c2
-rw-r--r--ini/ini_parse_ut.c4
-rw-r--r--ini/ini_valueobj_ut.c3
3 files changed, 8 insertions, 1 deletions
diff --git a/ini/ini_configobj.c b/ini/ini_configobj.c
index f825b73..538541f 100644
--- a/ini/ini_configobj.c
+++ b/ini/ini_configobj.c
@@ -214,7 +214,7 @@ int ini_config_copy(struct ini_cfgobj *ini_config,
struct ini_cfgobj **ini_new)
{
int error = EOK;
- struct ini_cfgobj *new_co;
+ struct ini_cfgobj *new_co = NULL;
TRACE_FLOW_ENTRY();
diff --git a/ini/ini_parse_ut.c b/ini/ini_parse_ut.c
index 4effeb1..75a1145 100644
--- a/ini/ini_parse_ut.c
+++ b/ini/ini_parse_ut.c
@@ -343,6 +343,7 @@ int merge_values_test(void)
INIOUT(printf("<==== Testing mode %s ====>\n", mstr[i]));
/* Create config collection */
+ ini_config = NULL;
error = ini_config_create(&ini_config);
if (error) {
printf("Failed to create collection. Error %d.\n", error);
@@ -350,6 +351,7 @@ int merge_values_test(void)
return error;
}
+ file_ctx = NULL;
error = ini_config_file_open(filename,
INI_STOP_ON_ANY,
mflags[i],
@@ -517,6 +519,7 @@ int merge_section_test(void)
}
/* Create config collection */
+ ini_config = NULL;
error = ini_config_create(&ini_config);
if (error) {
printf("Failed to create collection. "
@@ -525,6 +528,7 @@ int merge_section_test(void)
return error;
}
+ file_ctx = NULL;
error = ini_config_file_open(filename,
INI_STOP_ON_ANY,
msecflags[i] | mflags[j],
diff --git a/ini/ini_valueobj_ut.c b/ini/ini_valueobj_ut.c
index cb261fe..0e7959f 100644
--- a/ini/ini_valueobj_ut.c
+++ b/ini/ini_valueobj_ut.c
@@ -403,6 +403,7 @@ int vo_basic_test(void)
return error;
}
+ vo = NULL;
error = value_create_new(strvalue,
strlen(strvalue),
INI_VALUE_CREATED,
@@ -542,6 +543,7 @@ int vo_copy_test(void)
TRACE_INFO_NUMBER("Iteration:", wrap);
+ vo_copy = NULL;
error = value_copy(vo, &vo_copy);
if (error) {
printf("Failed to create a new value object %d.\n", error);
@@ -560,6 +562,7 @@ int vo_copy_test(void)
}
/* Get comment from the value */
+ ic = NULL;
error = value_extract_comment(vo_copy, &ic);
if (error) {
printf("Failed to extract comment %d.\n", error);