From 56b3277a0eff7a6128f4eaf0ac31bdcdbbfcfae9 Mon Sep 17 00:00:00 2001 From: Dmitri Pal Date: Sun, 26 Dec 2010 21:58:24 -0500 Subject: 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 --- ini/ini_configobj.c | 2 +- ini/ini_parse_ut.c | 4 ++++ ini/ini_valueobj_ut.c | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) 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); -- cgit