diff options
author | Dmitri Pal <dpal@redhat.com> | 2009-08-14 23:04:37 -0400 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2009-08-20 15:47:34 -0400 |
commit | 1069fb127a38d875d0ca2f56bfc936a97a964380 (patch) | |
tree | d100388a5be8ef2926b80a6182f2cfc8e6d16c5c /common/ini | |
parent | c7916d6b820bde690145450ba02209e741154866 (diff) | |
download | sssd-1069fb127a38d875d0ca2f56bfc936a97a964380.tar.gz sssd-1069fb127a38d875d0ca2f56bfc936a97a964380.tar.bz2 sssd-1069fb127a38d875d0ca2f56bfc936a97a964380.zip |
COMMON Fixes to return values, errno, leaks
Started looking at the ticket #107 related to
traverse functions. Realized that the return values
are not consistent. That ovelapped with the work
that I wanted to do for ticket #103 - errno cleanup.
So I (across collection, INI and ELAPI):
* Made the return codes consistent (where found)
* Removed errno where it is not needed
While was testing used valgrind and found a nasty
problem when the value was added to collection with
overwriting duplicates the count was decreased improperly.
Fixing collection.c to not decrease count made
valgrind happy. While I was debugging this
I also spotted several build warnings in trace
statements when the " exp ? v1 : v2 " was used.
Fixed those.
In ini_config.c there was a trace stament that used
variable after it was freed. Removed trace stament.
Diffstat (limited to 'common/ini')
-rw-r--r-- | common/ini/ini_config.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/common/ini/ini_config.c b/common/ini/ini_config.c index 9ef06e55..5c89bdd4 100644 --- a/common/ini/ini_config.c +++ b/common/ini/ini_config.c @@ -632,7 +632,7 @@ int config_for_app(const char *application, /* Get specific application file */ file_name = malloc(strlen(config_dir) + strlen(application) + NAME_OVERHEAD); if (file_name == NULL) { - error = errno; + error = ENOMEM; TRACE_ERROR_NUMBER("Failed to allocate memory for file name", error); /* In case of error when we created collection - delete it */ if(error && created) { @@ -665,7 +665,6 @@ int config_for_app(const char *application, /* Add error results if any to the overarching error collection */ if ((pass_specific != NULL) && (*pass_specific != NULL)) { - TRACE_INFO_STRING("Process erros resulting from file:", file_name); error = col_add_collection_to_collection(*error_set, NULL, NULL, *pass_specific, COL_ADD_MODE_EMBED); @@ -1260,7 +1259,6 @@ char *get_string_config_value(struct collection_item *item, return NULL; } - errno = 0; str = strdup((const char *)col_get_item_data(item)); if (str == NULL) { TRACE_ERROR_NUMBER("Failed to allocate memory.", ENOMEM); @@ -1643,8 +1641,8 @@ double *get_double_config_array(struct collection_item *item, int *size, int *er /* Now parse the string */ str = (const char *)col_get_item_data(item); while (*str) { - errno = 0; TRACE_INFO_STRING("String to convert",str); + errno = 0; val = strtod(str, &endptr); if ((errno == ERANGE) || ((errno != 0) && (val == 0)) || @@ -1729,7 +1727,7 @@ char **get_section_list(struct collection_item *ini_config, int *size, int *erro /* Pass it to the function from collection API */ list = col_collection_to_list(ini_config, size, error); - TRACE_FLOW_STRING("get_section_list returning", list == NULL ? "NULL" : list[0]); + TRACE_FLOW_STRING("get_section_list returning", ((list == NULL) ? "NULL" : list[0])); return list; } @@ -1766,6 +1764,6 @@ char **get_attribute_list(struct collection_item *ini_config, const char *sectio col_destroy_collection(subcollection); - TRACE_FLOW_STRING("get_attribute_list returning", list == NULL ? "NULL" : list[0]); + TRACE_FLOW_STRING("get_attribute_list returning", ((list == NULL) ? "NULL" : list[0])); return list; } |