From 1069fb127a38d875d0ca2f56bfc936a97a964380 Mon Sep 17 00:00:00 2001 From: Dmitri Pal Date: Fri, 14 Aug 2009 23:04:37 -0400 Subject: 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. --- common/elapi/elapi_log.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'common/elapi/elapi_log.c') diff --git a/common/elapi/elapi_log.c b/common/elapi/elapi_log.c index 122506e5a..c155fb1ac 100644 --- a/common/elapi/elapi_log.c +++ b/common/elapi/elapi_log.c @@ -202,9 +202,8 @@ int elapi_create_dispatcher_adv(struct elapi_dispatcher **dispatcher, /* Allocate memory */ handle = (struct elapi_dispatcher *) malloc(sizeof(struct elapi_dispatcher)); if (handle == NULL) { - error = errno; - TRACE_ERROR_NUMBER("Memory allocation failed. Error", error); - return error; + TRACE_ERROR_NUMBER("Memory allocation failed. Error", ENOMEM); + return ENOMEM; } /* Clean memory - we need it to be able to destroy the dispatcher at any moment */ @@ -227,10 +226,9 @@ int elapi_create_dispatcher_adv(struct elapi_dispatcher **dispatcher, /* Check error */ if (handle->appname == NULL) { - error = errno; - TRACE_ERROR_NUMBER("Memory allocation failed. Error", error); + TRACE_ERROR_NUMBER("Memory allocation failed. Error", ENOMEM); elapi_destroy_dispatcher(handle); - return error; + return ENOMEM; } /* Read the ELAPI configuration and store it in the dispatcher handle */ @@ -269,7 +267,7 @@ int elapi_create_dispatcher_adv(struct elapi_dispatcher **dispatcher, /* There is no list of targets this is bad configuration - return error */ TRACE_ERROR_STRING("No targets in the config file.", "Fatal error!"); elapi_destroy_dispatcher(handle); - return ENOKEY; + return ENOENT; } /* Get one from config but make sure we free it later */ -- cgit