celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pnol...@apache.org
Subject [4/5] celix git commit: CELIX-354: Fixes concerning high impact issues reported by coverity
Date Wed, 20 Apr 2016 16:31:12 GMT
CELIX-354: Fixes concerning high impact issues reported by coverity


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/777b8311
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/777b8311
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/777b8311

Branch: refs/heads/develop
Commit: 777b831101ed08a806eb0c64c7e7997ae38e086e
Parents: 3a37954
Author: Pepijn Noltes <pepijnnoltes@gmail.com>
Authored: Wed Apr 20 18:29:38 2016 +0200
Committer: Pepijn Noltes <pepijnnoltes@gmail.com>
Committed: Wed Apr 20 18:29:38 2016 +0200

----------------------------------------------------------------------
 config_admin/example/CMakeLists.txt             |   11 +-
 .../private/src/dm_service_dependency.c         | 1105 +++++++-------
 deployment_admin/private/src/log_sync.c         |    9 +-
 deployment_admin/private/src/unzip.c            |    2 +
 .../private/include/driver_attributes.h         |    1 +
 .../device_access/private/src/device_manager.c  |   16 +-
 .../private/src/driver_attributes.c             |    7 +
 .../device_access/private/src/driver_loader.c   |   10 +-
 .../device_access/private/src/driver_matcher.c  |   39 +-
 .../driver_locator/private/src/activator.c      |   11 +-
 .../private/include/base_driver_private.h       |    3 +
 .../example/base_driver/private/src/activator.c |   16 +-
 .../base_driver/private/src/base_driver.c       |   17 +
 .../private/include/refining_driver_private.h   |    1 +
 .../private/src/refining_driver.c               |   17 +-
 dfi/private/src/dyn_type.c                      |    3 +-
 dfi/private/src/json_serializer.c               |    8 +-
 dfi/private/test/dyn_interface_tests.cpp        |   40 +-
 .../private/src/mutex_benchmark.c               |    2 +
 examples/mongoose/private/src/mongoose.c        |   20 +-
 .../private/src/listener_example.c              |    3 +-
 .../database/private/src/activator.c            |   53 +-
 framework/private/mock/celix_log_mock.c         |    2 +
 framework/private/src/bundle_archive.c          |  603 ++++----
 framework/private/src/bundle_cache.c            |  238 +--
 framework/private/src/framework.c               |   24 +-
 framework/private/src/manifest.c                |   16 +-
 framework/private/src/manifest_parser.c         |  601 ++++----
 framework/private/src/resolver.c                |   12 +-
 framework/private/src/service_registry.c        |    5 +-
 framework/private/src/service_tracker.c         |    8 +-
 framework/private/src/unzip.c                   |    2 +
 .../private/test/service_reference_test.cpp     |    1 +
 .../discovery/private/src/discovery_activator.c |  187 ++-
 .../private/src/endpoint_discovery_poller.c     |  180 +--
 .../private/src/endpoint_discovery_server.c     |  116 +-
 .../private/src/discovery_shmWatcher.c          |   23 +-
 .../private/src/remote_proxy_factory_impl.c     |   11 +-
 .../rsa/private/src/import_registration_dfi.c   |    5 +-
 .../rsa/private/src/remote_service_admin_dfi.c  |    7 +-
 .../private/src/remote_service_admin_impl.c     | 1349 +++++++++--------
 .../topology_manager/private/src/activator.c    |  334 ++--
 .../private/src/topology_manager.c              | 1433 +++++++++---------
 remote_shell/private/src/connection_listener.c  |    3 +-
 utils/private/src/hash_map.c                    |    9 +-
 45 files changed, 3401 insertions(+), 3162 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/777b8311/config_admin/example/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/config_admin/example/CMakeLists.txt b/config_admin/example/CMakeLists.txt
index 2d92d0a..c1c80bd 100644
--- a/config_admin/example/CMakeLists.txt
+++ b/config_admin/example/CMakeLists.txt
@@ -10,8 +10,6 @@ SET(
     "org.apache.celix.config_admin.example"
 )
 
-SET(BUNDLE_VERSION "0.0.1")
-
 include_directories(
 	"private/include"
 	"public/include"
@@ -19,10 +17,11 @@ include_directories(
     ../service/public/include
 )
 
-bundle(
-config_admin_example SOURCES
-	private/src/bundle_activator
-	private/src/example
+add_bundle(config_admin_example 
+	VERSION 0.0.1
+	SOURCES
+		private/src/bundle_activator
+		private/src/example
 )
 
 target_link_libraries(config_admin_example ${CELIX_FRAMEWORK_LIBRARY} ${CELIX_UTILS_LIBRARY})

http://git-wip-us.apache.org/repos/asf/celix/blob/777b8311/dependency_manager/private/src/dm_service_dependency.c
----------------------------------------------------------------------
diff --git a/dependency_manager/private/src/dm_service_dependency.c b/dependency_manager/private/src/dm_service_dependency.c
index f81bd93..733f7fd 100644
--- a/dependency_manager/private/src/dm_service_dependency.c
+++ b/dependency_manager/private/src/dm_service_dependency.c
@@ -43,737 +43,736 @@ static celix_status_t serviceDependency_modifiedService(void *_ptr, service_refe
 static celix_status_t serviceDependency_removedService(void *_ptr, service_reference_pt reference, void *service);
 
 celix_status_t serviceDependency_create(dm_service_dependency_pt *dependency_ptr) {
-    celix_status_t status = CELIX_SUCCESS;
+	celix_status_t status = CELIX_SUCCESS;
 
-    *dependency_ptr = calloc(1, sizeof(**dependency_ptr));
-    if (!*dependency_ptr) {
-        status = CELIX_ENOMEM;
-    } else {
-        (*dependency_ptr)->component = NULL;
-        (*dependency_ptr)->available = false;
-        (*dependency_ptr)->instanceBound = false;
-        (*dependency_ptr)->required = false;
-        (*dependency_ptr)->strategy = DM_SERVICE_DEPENDENCY_DEFAULT_STRATEGY;
+	*dependency_ptr = calloc(1, sizeof(**dependency_ptr));
+	if (!*dependency_ptr) {
+		status = CELIX_ENOMEM;
+	} else {
+		(*dependency_ptr)->component = NULL;
+		(*dependency_ptr)->available = false;
+		(*dependency_ptr)->instanceBound = false;
+		(*dependency_ptr)->required = false;
+		(*dependency_ptr)->strategy = DM_SERVICE_DEPENDENCY_DEFAULT_STRATEGY;
 
-        (*dependency_ptr)->set = NULL;
-        (*dependency_ptr)->add = NULL;
-        (*dependency_ptr)->change = NULL;
-        (*dependency_ptr)->remove = NULL;
-        (*dependency_ptr)->swap = NULL;
+		(*dependency_ptr)->set = NULL;
+		(*dependency_ptr)->add = NULL;
+		(*dependency_ptr)->change = NULL;
+		(*dependency_ptr)->remove = NULL;
+		(*dependency_ptr)->swap = NULL;
 
-        (*dependency_ptr)->add_with_ref = NULL;
-        (*dependency_ptr)->change_with_ref = NULL;
-        (*dependency_ptr)->remove_with_ref = NULL;
-        (*dependency_ptr)->swap_with_ref = NULL;
+		(*dependency_ptr)->add_with_ref = NULL;
+		(*dependency_ptr)->change_with_ref = NULL;
+		(*dependency_ptr)->remove_with_ref = NULL;
+		(*dependency_ptr)->swap_with_ref = NULL;
 
-        (*dependency_ptr)->autoConfigure = NULL;
+		(*dependency_ptr)->autoConfigure = NULL;
 
-        (*dependency_ptr)->isStarted = false;
+		(*dependency_ptr)->isStarted = false;
 
-        (*dependency_ptr)->tracked_service = NULL;
-        (*dependency_ptr)->tracked_filter_unmodified = NULL;
-        (*dependency_ptr)->tracked_filter = NULL;
+		(*dependency_ptr)->tracked_service = NULL;
+		(*dependency_ptr)->tracked_filter_unmodified = NULL;
+		(*dependency_ptr)->tracked_filter = NULL;
 
-        (*dependency_ptr)->tracker = NULL;
-        (*dependency_ptr)->tracker_customizer = NULL;
-    }
+		(*dependency_ptr)->tracker = NULL;
+		(*dependency_ptr)->tracker_customizer = NULL;
+	}
 
-    return status;
+	return status;
 }
 
 celix_status_t serviceDependency_destroy(dm_service_dependency_pt *dependency_ptr) {
-    celix_status_t status = CELIX_SUCCESS;
+	celix_status_t status = CELIX_SUCCESS;
 
-    if (!*dependency_ptr) {
-        status = CELIX_ENOMEM;
-    }
+	if (!*dependency_ptr) {
+		status = CELIX_ENOMEM;
+	}
 
-    if (status == CELIX_SUCCESS) {
-        free((*dependency_ptr)->tracked_service);
-        free((*dependency_ptr)->tracked_filter);
-        free((*dependency_ptr)->tracked_filter_unmodified);
-        free(*dependency_ptr);
-        *dependency_ptr = NULL;
-    }
+	if (status == CELIX_SUCCESS) {
+		free((*dependency_ptr)->tracked_service);
+		free((*dependency_ptr)->tracked_filter);
+		free((*dependency_ptr)->tracked_filter_unmodified);
+		free(*dependency_ptr);
+		*dependency_ptr = NULL;
+	}
 
-    return status;
+	return status;
 }
 
 celix_status_t serviceDependency_lock(dm_service_dependency_pt dependency) {
-    celixThreadMutex_lock(&dependency->lock);
-    return CELIX_SUCCESS;
+	celixThreadMutex_lock(&dependency->lock);
+	return CELIX_SUCCESS;
 }
 
 celix_status_t serviceDependency_unlock(dm_service_dependency_pt dependency) {
-    celixThreadMutex_unlock(&dependency->lock);
-    return CELIX_SUCCESS;
+	celixThreadMutex_unlock(&dependency->lock);
+	return CELIX_SUCCESS;
 }
 
 celix_status_t serviceDependency_setRequired(dm_service_dependency_pt dependency, bool required) {
-    celix_status_t status = CELIX_SUCCESS;
+	celix_status_t status = CELIX_SUCCESS;
 
-    if (!dependency) {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    }
+	if (!dependency) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
 
-    if (status == CELIX_SUCCESS) {
-        dependency->required = required;
-    }
+	if (status == CELIX_SUCCESS) {
+		dependency->required = required;
+	}
 
-    return status;
+	return status;
 }
 
 celix_status_t serviceDependency_setStrategy(dm_service_dependency_pt dependency, dm_service_dependency_strategy_t strategy) {
-    celix_status_t status = CELIX_SUCCESS;
+	celix_status_t status = CELIX_SUCCESS;
 
-    if (!dependency) {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    } else {
-        dependency->strategy = strategy;
-    }
+	if (!dependency) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	} else {
+		dependency->strategy = strategy;
+	}
 
-    return status;
+	return status;
 }
 
 celix_status_t serviceDependency_getStrategy(dm_service_dependency_pt dependency, dm_service_dependency_strategy_t* strategy) {
-    celix_status_t status = CELIX_SUCCESS;
+	celix_status_t status = CELIX_SUCCESS;
 
-    if (!dependency) {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    } else {
-        *strategy = dependency->strategy;
-    }
+	if (!dependency) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	} else {
+		*strategy = dependency->strategy;
+	}
 
-    return status;
+	return status;
 
 }
 
 celix_status_t serviceDependency_setService(dm_service_dependency_pt dependency, char *serviceName, char *serviceVersionRange, char *filter) {
-    celix_status_t status = CELIX_SUCCESS;
-    if (!dependency) {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    }
-
-    if (status == CELIX_SUCCESS) {
-        array_list_pt filterElements = NULL;
-        arrayList_create(&filterElements);
-
-        if (serviceName != NULL) {
-            dependency->tracked_service = strdup(serviceName);
-        }
-
-        if (serviceVersionRange != NULL) {
-            version_range_pt versionRange = NULL;
-
-            if (versionRange_parse(serviceVersionRange, &versionRange) == CELIX_SUCCESS) {
-                version_pt lowVersion = NULL;
-                version_pt highVersion = NULL;
-
-                if ((versionRange_getHighVersion(versionRange, &highVersion) == CELIX_SUCCESS) && (highVersion != NULL)) {
-                    bool isHighInclusive;
-                    char* highOperator;
-                    char* highVersionStr = NULL;
-
-                    versionRange_isHighInclusive(versionRange, &isHighInclusive);
-                    version_toString(highVersion, &highVersionStr);
-
-                    highOperator = isHighInclusive ? "<=" : "<";
-
-                    size_t len = strlen(CELIX_FRAMEWORK_SERVICE_VERSION) + strlen(highVersionStr) + strlen(highOperator) + 3;
-                    char serviceVersionFilter[len];
-                    snprintf(serviceVersionFilter, len, "(%s%s%s)", CELIX_FRAMEWORK_SERVICE_VERSION, highOperator, highVersionStr);
-                    arrayList_add(filterElements, strdup(serviceVersionFilter));
-
-                    if(highVersionStr!=NULL){
-                    	free(highVersionStr);
-                    }
-                }
-
-                if ((versionRange_getLowVersion(versionRange, &lowVersion) == CELIX_SUCCESS) && (lowVersion != NULL)) {
-                    bool isLowInclusive;
-                    char* lowOperator;
-                    char* lowVersionStr = NULL;
-
-                    versionRange_isLowInclusive(versionRange, &isLowInclusive);
-                    version_toString(lowVersion, &lowVersionStr);
-
-                    lowOperator = isLowInclusive ? ">=" : ">";
-
-                    size_t len = strlen(CELIX_FRAMEWORK_SERVICE_VERSION) + strlen(lowVersionStr) + strlen(lowOperator) + 3;
-                    char serviceVersionFilter[len];
-                    snprintf(serviceVersionFilter, len, "(%s%s%s)", CELIX_FRAMEWORK_SERVICE_VERSION, lowOperator, lowVersionStr);
-                    arrayList_add(filterElements, strdup(serviceVersionFilter));
-
-                    if(lowVersionStr!=NULL){
-                    	free(lowVersionStr);
-                    }
-                }
-            }
-
-            if(versionRange!=NULL){
-            	versionRange_destroy(versionRange);
-            }
-        }
-
-        if (filter != NULL) {
-            dependency->tracked_filter_unmodified = strdup(filter);
-            arrayList_add(filterElements, strdup(filter));
-        }
-
-        if (arrayList_size(filterElements) > 0) {
-            array_list_iterator_pt filterElementsIter = arrayListIterator_create(filterElements);
-
-            size_t len = strlen(serviceName) + strlen(OSGI_FRAMEWORK_OBJECTCLASS) + 4;
-            dependency->tracked_filter = calloc(len, sizeof(*dependency->tracked_filter));
-            snprintf(dependency->tracked_filter, len, "(%s=%s)", OSGI_FRAMEWORK_OBJECTCLASS, serviceName);
-
-            while (arrayListIterator_hasNext(filterElementsIter) == true) {
-                char* filterElement = (char*) arrayListIterator_next(filterElementsIter);
-                size_t len = strnlen(dependency->tracked_filter, 1024*1024) + strnlen(filterElement, 1024*1024) + 4;
-                char* newFilter = calloc(len, sizeof(*newFilter));
-
-                if (dependency->tracked_filter[0] == '(' && dependency->tracked_filter[1] == '&') {
-                    //already have an & (AND) can combine with additional filter -> easier to read
-                    size_t orgLen = strnlen(dependency->tracked_filter, 1024*1024);
-                    snprintf(newFilter, len, "%.*s%s)", (int)orgLen -1, dependency->tracked_filter, filterElement);
-                } else {
-                    snprintf(newFilter, len, "(&%s%s)", dependency->tracked_filter, filterElement);
-                }
-
-                free(dependency->tracked_filter);
-                free(filterElement);
-
-                dependency->tracked_filter = newFilter;
-            }
-
-            arrayListIterator_destroy(filterElementsIter);
-        }
-        else {
-            dependency->tracked_filter = NULL;
-        }
-
-        arrayList_destroy(filterElements);
-    }
-
-    return status;
+	celix_status_t status = CELIX_SUCCESS;
+	if (!dependency) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
+
+	if (status == CELIX_SUCCESS) {
+		array_list_pt filterElements = NULL;
+		arrayList_create(&filterElements);
+
+		if (serviceName != NULL) {
+			dependency->tracked_service = strdup(serviceName);
+		}
+
+		if (serviceVersionRange != NULL) {
+			version_range_pt versionRange = NULL;
+
+			if (versionRange_parse(serviceVersionRange, &versionRange) == CELIX_SUCCESS) {
+				version_pt lowVersion = NULL;
+				version_pt highVersion = NULL;
+
+				if ((versionRange_getHighVersion(versionRange, &highVersion) == CELIX_SUCCESS) && (highVersion != NULL)) {
+					bool isHighInclusive;
+					char* highOperator;
+					char* highVersionStr = NULL;
+
+					versionRange_isHighInclusive(versionRange, &isHighInclusive);
+					version_toString(highVersion, &highVersionStr);
+
+					highOperator = isHighInclusive ? "<=" : "<";
+
+					if(highVersionStr != NULL){
+						size_t len = strlen(CELIX_FRAMEWORK_SERVICE_VERSION) + strlen(highVersionStr) + strlen(highOperator) + 3;
+						char serviceVersionFilter[len];
+						snprintf(serviceVersionFilter, len, "(%s%s%s)", CELIX_FRAMEWORK_SERVICE_VERSION, highOperator, highVersionStr);
+						arrayList_add(filterElements, strdup(serviceVersionFilter));
+						free(highVersionStr);
+					}
+				}
+
+				if ((versionRange_getLowVersion(versionRange, &lowVersion) == CELIX_SUCCESS) && (lowVersion != NULL)) {
+					bool isLowInclusive;
+					char* lowOperator;
+					char* lowVersionStr = NULL;
+
+					versionRange_isLowInclusive(versionRange, &isLowInclusive);
+					version_toString(lowVersion, &lowVersionStr);
+
+					lowOperator = isLowInclusive ? ">=" : ">";
+
+					if(lowVersionStr != NULL){
+						size_t len = strlen(CELIX_FRAMEWORK_SERVICE_VERSION) + strlen(lowVersionStr) + strlen(lowOperator) + 3;
+						char serviceVersionFilter[len];
+						snprintf(serviceVersionFilter, len, "(%s%s%s)", CELIX_FRAMEWORK_SERVICE_VERSION, lowOperator, lowVersionStr);
+						arrayList_add(filterElements, strdup(serviceVersionFilter));
+						free(lowVersionStr);
+					}
+				}
+			}
+
+			if(versionRange!=NULL){
+				versionRange_destroy(versionRange);
+			}
+		}
+
+		if (filter != NULL) {
+			dependency->tracked_filter_unmodified = strdup(filter);
+			arrayList_add(filterElements, strdup(filter));
+		}
+
+		if (arrayList_size(filterElements) > 0) {
+			array_list_iterator_pt filterElementsIter = arrayListIterator_create(filterElements);
+
+			size_t len = strlen(serviceName) + strlen(OSGI_FRAMEWORK_OBJECTCLASS) + 4;
+			dependency->tracked_filter = calloc(len, sizeof(*dependency->tracked_filter));
+			snprintf(dependency->tracked_filter, len, "(%s=%s)", OSGI_FRAMEWORK_OBJECTCLASS, serviceName);
+
+			while (arrayListIterator_hasNext(filterElementsIter) == true) {
+				char* filterElement = (char*) arrayListIterator_next(filterElementsIter);
+				size_t len = strnlen(dependency->tracked_filter, 1024*1024) + strnlen(filterElement, 1024*1024) + 4;
+				char* newFilter = calloc(len, sizeof(*newFilter));
+
+				if (dependency->tracked_filter[0] == '(' && dependency->tracked_filter[1] == '&') {
+					//already have an & (AND) can combine with additional filter -> easier to read
+					size_t orgLen = strnlen(dependency->tracked_filter, 1024*1024);
+					snprintf(newFilter, len, "%.*s%s)", (int)orgLen -1, dependency->tracked_filter, filterElement);
+				} else {
+					snprintf(newFilter, len, "(&%s%s)", dependency->tracked_filter, filterElement);
+				}
+
+				free(dependency->tracked_filter);
+				free(filterElement);
+
+				dependency->tracked_filter = newFilter;
+			}
+
+			arrayListIterator_destroy(filterElementsIter);
+		}
+		else {
+			dependency->tracked_filter = NULL;
+		}
+
+		arrayList_destroy(filterElements);
+	}
+
+	return status;
 }
 
 celix_status_t serviceDependency_getFilter(dm_service_dependency_pt dependency, char **filter) {
-    *filter = dependency->tracked_filter;
-    return CELIX_SUCCESS;
+	*filter = dependency->tracked_filter;
+	return CELIX_SUCCESS;
 }
 
 celix_status_t serviceDependency_setCallbacks(dm_service_dependency_pt dependency, service_set_fpt set, service_add_fpt add, service_change_fpt change, service_remove_fpt remove, service_swap_fpt swap) {
-    celix_status_t status = CELIX_SUCCESS;
+	celix_status_t status = CELIX_SUCCESS;
 
-    if (!dependency) {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    }
+	if (!dependency) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
 
-    if (status == CELIX_SUCCESS) {
-        dependency->set = set;
-        dependency->add = add;
-        dependency->change = change;
-        dependency->remove = remove;
-        dependency->swap = swap;
-    }
+	if (status == CELIX_SUCCESS) {
+		dependency->set = set;
+		dependency->add = add;
+		dependency->change = change;
+		dependency->remove = remove;
+		dependency->swap = swap;
+	}
 
-    return status;
+	return status;
 }
 
 celix_status_t serviceDependency_setCallbacksWithServiceReference(dm_service_dependency_pt dependency, service_set_with_ref_fpt set, service_add_with_ref_fpt add, service_change_with_ref_fpt change, service_remove_with_ref_fpt remove,
-        service_swap_with_ref_fpt swap) {
-    celix_status_t status = CELIX_SUCCESS;
+		service_swap_with_ref_fpt swap) {
+	celix_status_t status = CELIX_SUCCESS;
 
-    if (!dependency) {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    }
+	if (!dependency) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
 
-    if (status == CELIX_SUCCESS) {
-        dependency->set_with_ref = set;
-        dependency->add_with_ref = add;
-        dependency->change_with_ref = change;
-        dependency->remove_with_ref = remove;
-        dependency->swap_with_ref = swap;
-    }
+	if (status == CELIX_SUCCESS) {
+		dependency->set_with_ref = set;
+		dependency->add_with_ref = add;
+		dependency->change_with_ref = change;
+		dependency->remove_with_ref = remove;
+		dependency->swap_with_ref = swap;
+	}
 
-    return status;
+	return status;
 }
 
 celix_status_t serviceDependency_setAutoConfigure(dm_service_dependency_pt dependency, celix_thread_mutex_t *service_lock, void **field) {
-    celix_status_t status = CELIX_SUCCESS;
+	celix_status_t status = CELIX_SUCCESS;
 
-    celix_thread_mutex_t lock;
+	celix_thread_mutex_t lock;
 
-    if (!dependency) {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    }
+	if (!dependency) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
 
-    if (status == CELIX_SUCCESS) {
-        dependency->autoConfigure = field;
-        celixThreadMutex_create(&lock, NULL);
-        *service_lock = lock;
-        dependency->lock = lock;
-    }
+	if (status == CELIX_SUCCESS) {
+		dependency->autoConfigure = field;
+		celixThreadMutex_create(&lock, NULL);
+		*service_lock = lock;
+		dependency->lock = lock;
+	}
 
-    return status;
+	return status;
 }
 
 celix_status_t serviceDependency_setComponent(dm_service_dependency_pt dependency, dm_component_pt component) {
-    celix_status_t status = CELIX_SUCCESS;
+	celix_status_t status = CELIX_SUCCESS;
 
-    if (!dependency) {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    }
+	if (!dependency) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
 
-    if (status == CELIX_SUCCESS) {
-        dependency->component = component;
-    }
+	if (status == CELIX_SUCCESS) {
+		dependency->component = component;
+	}
 
-    return status;
+	return status;
 }
 
 celix_status_t serviceDependency_start(dm_service_dependency_pt dependency) {
-    celix_status_t status = CELIX_SUCCESS;
-    bundle_context_pt context = NULL;
-
-    if (!dependency || !dependency->component || (!dependency->tracked_service && !dependency->tracked_filter)) {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    }
-    if (status == CELIX_SUCCESS) {
-        status = component_getBundleContext(dependency->component, &context);
-        if (!context) {
-            status = CELIX_BUNDLE_EXCEPTION;
-        }
-    }
-    if (status == CELIX_SUCCESS) {
-        dependency->tracker_customizer = NULL;
-        status = serviceTrackerCustomizer_create(dependency, NULL, serviceDependency_addedService, serviceDependency_modifiedService, serviceDependency_removedService, &dependency->tracker_customizer);
-    }
-    if (status == CELIX_SUCCESS) {
-        if (dependency->tracked_filter) {
-            status = serviceTracker_createWithFilter(context, dependency->tracked_filter, dependency->tracker_customizer, &dependency->tracker);
-        } else if (dependency->tracked_service) {
-            status = serviceTracker_create(context, dependency->tracked_service, dependency->tracker_customizer, &dependency->tracker);
-        }
-    }
-
-    if (status == CELIX_SUCCESS) {
-        status = serviceTracker_open(dependency->tracker);
-    }
-
-    if (status == CELIX_SUCCESS) {
-        dependency->isStarted = true;
-    }
-
-    return status;
+	celix_status_t status = CELIX_SUCCESS;
+	bundle_context_pt context = NULL;
+
+	if (!dependency || !dependency->component || (!dependency->tracked_service && !dependency->tracked_filter)) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
+	if (status == CELIX_SUCCESS) {
+		status = component_getBundleContext(dependency->component, &context);
+		if (!context) {
+			status = CELIX_BUNDLE_EXCEPTION;
+		}
+	}
+	if (status == CELIX_SUCCESS) {
+		dependency->tracker_customizer = NULL;
+		status = serviceTrackerCustomizer_create(dependency, NULL, serviceDependency_addedService, serviceDependency_modifiedService, serviceDependency_removedService, &dependency->tracker_customizer);
+	}
+	if (status == CELIX_SUCCESS) {
+		if (dependency->tracked_filter) {
+			status = serviceTracker_createWithFilter(context, dependency->tracked_filter, dependency->tracker_customizer, &dependency->tracker);
+		} else if (dependency->tracked_service) {
+			status = serviceTracker_create(context, dependency->tracked_service, dependency->tracker_customizer, &dependency->tracker);
+		}
+	}
+
+	if (status == CELIX_SUCCESS) {
+		status = serviceTracker_open(dependency->tracker);
+	}
+
+	if (status == CELIX_SUCCESS) {
+		dependency->isStarted = true;
+	}
+
+	return status;
 }
 
 celix_status_t serviceDependency_stop(dm_service_dependency_pt dependency) {
-    celix_status_t status = CELIX_SUCCESS;
-    celix_status_t tmp_status;
+	celix_status_t status = CELIX_SUCCESS;
+	celix_status_t tmp_status;
 
-    if (!dependency) {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    }
+	if (!dependency) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
 
-    if (status == CELIX_SUCCESS) {
-        dependency->isStarted = false;
-    }
+	if (status == CELIX_SUCCESS) {
+		dependency->isStarted = false;
+	}
 
-    if (status == CELIX_SUCCESS) {
-        if (dependency->tracker) {
-            tmp_status = serviceTracker_close(dependency->tracker);
-            if (tmp_status != CELIX_SUCCESS) {
-                status = tmp_status;
-            }
-            tmp_status = serviceTracker_destroy(dependency->tracker);
-            if (tmp_status != CELIX_SUCCESS && status == CELIX_SUCCESS) {
-                status = tmp_status;
-            }
-        }
-    }
+	if (status == CELIX_SUCCESS) {
+		if (dependency->tracker) {
+			tmp_status = serviceTracker_close(dependency->tracker);
+			if (tmp_status != CELIX_SUCCESS) {
+				status = tmp_status;
+			}
+			tmp_status = serviceTracker_destroy(dependency->tracker);
+			if (tmp_status != CELIX_SUCCESS && status == CELIX_SUCCESS) {
+				status = tmp_status;
+			}
+		}
+	}
 
-    return status;
+	return status;
 }
 
 celix_status_t serviceDependency_setInstanceBound(dm_service_dependency_pt dependency, bool instanceBound) {
-    celix_status_t status = CELIX_SUCCESS;
+	celix_status_t status = CELIX_SUCCESS;
 
-    if (!dependency) {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    }
+	if (!dependency) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
 
-    if (status == CELIX_SUCCESS) {
-        dependency->instanceBound = instanceBound;
-    }
+	if (status == CELIX_SUCCESS) {
+		dependency->instanceBound = instanceBound;
+	}
 
-    return status;
+	return status;
 }
 
 celix_status_t serviceDependency_setAvailable(dm_service_dependency_pt dependency, bool available) {
-    celix_status_t status = CELIX_SUCCESS;
+	celix_status_t status = CELIX_SUCCESS;
 
-    if (!dependency) {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    }
+	if (!dependency) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
 
-    if (status == CELIX_SUCCESS) {
-        dependency->available = available;
-    }
+	if (status == CELIX_SUCCESS) {
+		dependency->available = available;
+	}
 
-    return status;
+	return status;
 }
 
 celix_status_t serviceDependency_invokeSet(dm_service_dependency_pt dependency, dm_event_pt event) {
-    celix_status_t status = CELIX_SUCCESS;
-    assert(dependency->isStarted == true);
-    array_list_pt serviceReferences = NULL;
-    int i;
-    int curRanking = INT_MIN;
-    service_reference_pt curServRef = NULL;
-    void *service = NULL;
-
-    serviceReferences = serviceTracker_getServiceReferences(dependency->tracker);
-
-    /* Find the service with the higest ranking */
-    for (i = 0; i < arrayList_size(serviceReferences); i++) {
-        service_reference_pt serviceReference = arrayList_get(serviceReferences, i);
-        char *ranking_value;
-        int ranking = 0;
-
-        status = serviceReference_getProperty(serviceReference, ((char *) OSGI_FRAMEWORK_SERVICE_RANKING), &ranking_value);
-
-        if (status == CELIX_SUCCESS) {
-            if (ranking_value == NULL) {
-                ranking = DEFAULT_RANKING;
-            } else {
-                char *end;
-                ranking = strtol(ranking_value, &end, 10);
-                if (end == ranking_value) {
-                    ranking = DEFAULT_RANKING;
-                }
-            }
-
-            if (ranking > curRanking) {
-                curRanking = ranking;
-                curServRef = serviceReference;
-            }
-        } else {
-            return status;
-        }
-
-    }
-
-    arrayList_destroy(serviceReferences);
-
-    if (curServRef) {
-        status = bundleContext_getService(event->context, curServRef, &service);
-    } else {
-        service = NULL;
-    }
-
-    if (dependency->set) {
-        dependency->set(component_getImplementation(dependency->component), service);
-    }
-    if (dependency->set_with_ref) {
-        dependency->set_with_ref(component_getImplementation(dependency->component), curServRef, service);
-    }
-
-    if (curServRef) {
-        bundleContext_ungetService(event->context, curServRef, NULL);
-    }
-
-    return status;
+	celix_status_t status = CELIX_SUCCESS;
+	assert(dependency->isStarted == true);
+	array_list_pt serviceReferences = NULL;
+	int i;
+	int curRanking = INT_MIN;
+	service_reference_pt curServRef = NULL;
+	void *service = NULL;
+
+	serviceReferences = serviceTracker_getServiceReferences(dependency->tracker);
+
+	/* Find the service with the higest ranking */
+	for (i = 0; i < arrayList_size(serviceReferences); i++) {
+		service_reference_pt serviceReference = arrayList_get(serviceReferences, i);
+		char *ranking_value;
+		int ranking = 0;
+
+		status = serviceReference_getProperty(serviceReference, ((char *) OSGI_FRAMEWORK_SERVICE_RANKING), &ranking_value);
+
+		if (status == CELIX_SUCCESS) {
+			if (ranking_value == NULL) {
+				ranking = DEFAULT_RANKING;
+			} else {
+				char *end;
+				ranking = strtol(ranking_value, &end, 10);
+				if (end == ranking_value) {
+					ranking = DEFAULT_RANKING;
+				}
+			}
+
+			if (ranking > curRanking) {
+				curRanking = ranking;
+				curServRef = serviceReference;
+			}
+		} else {
+			arrayList_destroy(serviceReferences);
+			return status;
+		}
+
+	}
+
+	arrayList_destroy(serviceReferences);
+
+	if (curServRef) {
+		status = bundleContext_getService(event->context, curServRef, &service);
+	} else {
+		service = NULL;
+	}
+
+	if (dependency->set) {
+		dependency->set(component_getImplementation(dependency->component), service);
+	}
+	if (dependency->set_with_ref) {
+		dependency->set_with_ref(component_getImplementation(dependency->component), curServRef, service);
+	}
+
+	if (curServRef) {
+		bundleContext_ungetService(event->context, curServRef, NULL);
+	}
+
+	return status;
 }
 
 celix_status_t serviceDependency_invokeAdd(dm_service_dependency_pt dependency, dm_event_pt event) {
-    celix_status_t status = CELIX_SUCCESS;
+	celix_status_t status = CELIX_SUCCESS;
 
-    if (!dependency) {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    }
+	if (!dependency) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
 
-    if (status == CELIX_SUCCESS) {
-        if (dependency->add) {
-            dependency->add(component_getImplementation(dependency->component), event->service);
-        }
-        if (dependency->add_with_ref) {
-            dependency->add_with_ref(component_getImplementation(dependency->component), event->reference, event->service);
-        }
-    }
+	if (status == CELIX_SUCCESS) {
+		if (dependency->add) {
+			dependency->add(component_getImplementation(dependency->component), event->service);
+		}
+		if (dependency->add_with_ref) {
+			dependency->add_with_ref(component_getImplementation(dependency->component), event->reference, event->service);
+		}
+	}
 
-    return status;
+	return status;
 }
 
 celix_status_t serviceDependency_invokeChange(dm_service_dependency_pt dependency, dm_event_pt event) {
-    celix_status_t status = CELIX_SUCCESS;
+	celix_status_t status = CELIX_SUCCESS;
 
-    if (!dependency) {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    }
+	if (!dependency) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
 
-    if (status == CELIX_SUCCESS) {
-        if (dependency->change) {
-            dependency->change(component_getImplementation(dependency->component), event->service);
-        }
-        if (dependency->change_with_ref) {
-            dependency->change_with_ref(component_getImplementation(dependency->component), event->reference, event->service);
-        }
-    }
+	if (status == CELIX_SUCCESS) {
+		if (dependency->change) {
+			dependency->change(component_getImplementation(dependency->component), event->service);
+		}
+		if (dependency->change_with_ref) {
+			dependency->change_with_ref(component_getImplementation(dependency->component), event->reference, event->service);
+		}
+	}
 
-    return status;
+	return status;
 }
 
 celix_status_t serviceDependency_invokeRemove(dm_service_dependency_pt dependency, dm_event_pt event) {
-    celix_status_t status = CELIX_SUCCESS;
+	celix_status_t status = CELIX_SUCCESS;
 
-    if (!dependency) {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    }
+	if (!dependency) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
 
-    if (status == CELIX_SUCCESS) {
-        if (dependency->remove) {
-            dependency->remove(component_getImplementation(dependency->component), event->service);
-        }
-        if (dependency->remove_with_ref) {
-            dependency->remove_with_ref(component_getImplementation(dependency->component), event->reference, event->service);
-        }
-    }
+	if (status == CELIX_SUCCESS) {
+		if (dependency->remove) {
+			dependency->remove(component_getImplementation(dependency->component), event->service);
+		}
+		if (dependency->remove_with_ref) {
+			dependency->remove_with_ref(component_getImplementation(dependency->component), event->reference, event->service);
+		}
+	}
 
-    return status;
+	return status;
 }
 
 celix_status_t serviceDependency_invokeSwap(dm_service_dependency_pt dependency, dm_event_pt event, dm_event_pt newEvent) {
-    celix_status_t status = CELIX_SUCCESS;
+	celix_status_t status = CELIX_SUCCESS;
 
-    if (!dependency) {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    }
+	if (!dependency) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
 
-    if (status == CELIX_SUCCESS) {
-        if (dependency->swap) {
-            dependency->swap(component_getImplementation(dependency->component), event->service, newEvent->service);
-        }
-        if (dependency->swap_with_ref) {
-            dependency->swap_with_ref(component_getImplementation(dependency->component), event->reference, event->service, newEvent->reference, newEvent->service);
-        }
-    }
+	if (status == CELIX_SUCCESS) {
+		if (dependency->swap) {
+			dependency->swap(component_getImplementation(dependency->component), event->service, newEvent->service);
+		}
+		if (dependency->swap_with_ref) {
+			dependency->swap_with_ref(component_getImplementation(dependency->component), event->reference, event->service, newEvent->reference, newEvent->service);
+		}
+	}
 
-    return status;
+	return status;
 }
 
 celix_status_t serviceDependency_isAvailable(dm_service_dependency_pt dependency, bool *available) {
-    celix_status_t status = CELIX_SUCCESS;
+	celix_status_t status = CELIX_SUCCESS;
 
-    if (!dependency) {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    }
+	if (!dependency) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
 
-    if (status == CELIX_SUCCESS) {
-        *available = dependency->available;
-    }
+	if (status == CELIX_SUCCESS) {
+		*available = dependency->available;
+	}
 
-    return status;
+	return status;
 }
 
 celix_status_t serviceDependency_isRequired(dm_service_dependency_pt dependency, bool *required) {
-    celix_status_t status = CELIX_SUCCESS;
+	celix_status_t status = CELIX_SUCCESS;
 
-    if (!dependency) {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    }
+	if (!dependency) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
 
-    if (status == CELIX_SUCCESS) {
-        *required = dependency->required;
-    }
+	if (status == CELIX_SUCCESS) {
+		*required = dependency->required;
+	}
 
-    return status;
+	return status;
 }
 
 celix_status_t serviceDependency_isInstanceBound(dm_service_dependency_pt dependency, bool *instanceBound) {
-    celix_status_t status = CELIX_SUCCESS;
+	celix_status_t status = CELIX_SUCCESS;
 
-    if (!dependency) {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    }
+	if (!dependency) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
 
-    if (status == CELIX_SUCCESS) {
-        *instanceBound = dependency->instanceBound;
-    }
+	if (status == CELIX_SUCCESS) {
+		*instanceBound = dependency->instanceBound;
+	}
 
-    return status;
+	return status;
 }
 
 celix_status_t serviceDependency_isAutoConfig(dm_service_dependency_pt dependency, bool *autoConfig) {
-    celix_status_t status = CELIX_SUCCESS;
+	celix_status_t status = CELIX_SUCCESS;
 
-    if (!dependency) {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    }
+	if (!dependency) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
 
-    if (status == CELIX_SUCCESS) {
-        *autoConfig = dependency->autoConfigure != NULL;
-    }
+	if (status == CELIX_SUCCESS) {
+		*autoConfig = dependency->autoConfigure != NULL;
+	}
 
-    return status;
+	return status;
 }
 
 celix_status_t serviceDependency_getAutoConfig(dm_service_dependency_pt dependency, void ***autoConfigure) {
-    celix_status_t status = CELIX_SUCCESS;
+	celix_status_t status = CELIX_SUCCESS;
 
-    if (!dependency) {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    }
+	if (!dependency) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
 
-    if (status == CELIX_SUCCESS) {
-        *autoConfigure = dependency->autoConfigure;
-    }
+	if (status == CELIX_SUCCESS) {
+		*autoConfigure = dependency->autoConfigure;
+	}
 
-    return status;
+	return status;
 }
 
 celix_status_t serviceDependency_addedService(void *_ptr, service_reference_pt reference, void *service) {
-    celix_status_t status = CELIX_SUCCESS;
-    bundle_context_pt context = NULL;
-    bundle_pt bundle = NULL;
-    dm_event_pt event = NULL;
-    dm_service_dependency_pt dependency = _ptr;
+	celix_status_t status = CELIX_SUCCESS;
+	bundle_context_pt context = NULL;
+	bundle_pt bundle = NULL;
+	dm_event_pt event = NULL;
+	dm_service_dependency_pt dependency = _ptr;
 
-    if (!dependency || !reference || !service) {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    }
+	if (!dependency || !reference || !service) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
 
-    if (status == CELIX_SUCCESS) {
-        status = component_getBundleContext(dependency->component, &context);
-        if (!context) {
-            status = CELIX_BUNDLE_EXCEPTION;
-        }
-    }
+	if (status == CELIX_SUCCESS) {
+		status = component_getBundleContext(dependency->component, &context);
+		if (!context) {
+			status = CELIX_BUNDLE_EXCEPTION;
+		}
+	}
 
-    if (status == CELIX_SUCCESS) {
-        status = bundleContext_getBundle(context, &bundle);
-        if (!bundle) {
-            status = CELIX_BUNDLE_EXCEPTION;
-        }
-    }
+	if (status == CELIX_SUCCESS) {
+		status = bundleContext_getBundle(context, &bundle);
+		if (!bundle) {
+			status = CELIX_BUNDLE_EXCEPTION;
+		}
+	}
 
-    if (status == CELIX_SUCCESS) {
-        status = event_create(DM_EVENT_ADDED, bundle, context, reference, service, &event);
-    }
+	if (status == CELIX_SUCCESS) {
+		status = event_create(DM_EVENT_ADDED, bundle, context, reference, service, &event);
+	}
 
-    if (status == CELIX_SUCCESS) {
-        component_handleEvent(dependency->component, dependency, event);
-    }
+	if (status == CELIX_SUCCESS) {
+		component_handleEvent(dependency->component, dependency, event);
+	}
 
-    return status;
+	return status;
 }
 
 celix_status_t serviceDependency_modifiedService(void *_ptr, service_reference_pt reference, void *service) {
-    celix_status_t status = CELIX_SUCCESS;
-    bundle_context_pt context = NULL;
-    bundle_pt bundle = NULL;
-    dm_event_pt event = NULL;
-    dm_service_dependency_pt dependency = _ptr;
+	celix_status_t status = CELIX_SUCCESS;
+	bundle_context_pt context = NULL;
+	bundle_pt bundle = NULL;
+	dm_event_pt event = NULL;
+	dm_service_dependency_pt dependency = _ptr;
 
-    if (!dependency || !reference || !service) {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    }
+	if (!dependency || !reference || !service) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
 
-    if (status == CELIX_SUCCESS) {
-        status = component_getBundleContext(dependency->component, &context);
-        if (!context) {
-            status = CELIX_BUNDLE_EXCEPTION;
-        }
-    }
+	if (status == CELIX_SUCCESS) {
+		status = component_getBundleContext(dependency->component, &context);
+		if (!context) {
+			status = CELIX_BUNDLE_EXCEPTION;
+		}
+	}
 
-    if (status == CELIX_SUCCESS) {
-        status = bundleContext_getBundle(context, &bundle);
-        if (!bundle) {
-            status = CELIX_BUNDLE_EXCEPTION;
-        }
-    }
+	if (status == CELIX_SUCCESS) {
+		status = bundleContext_getBundle(context, &bundle);
+		if (!bundle) {
+			status = CELIX_BUNDLE_EXCEPTION;
+		}
+	}
 
-    if (status == CELIX_SUCCESS) {
-        status = event_create(DM_EVENT_CHANGED, bundle, context, reference, service, &event);
-    }
+	if (status == CELIX_SUCCESS) {
+		status = event_create(DM_EVENT_CHANGED, bundle, context, reference, service, &event);
+	}
 
-    if (status == CELIX_SUCCESS) {
-        component_handleEvent(dependency->component, dependency, event);
-    }
+	if (status == CELIX_SUCCESS) {
+		component_handleEvent(dependency->component, dependency, event);
+	}
 
-    return status;
+	return status;
 }
 
 celix_status_t serviceDependency_removedService(void *_ptr, service_reference_pt reference, void *service) {
-    celix_status_t status = CELIX_SUCCESS;
-    bundle_context_pt context = NULL;
-    bundle_pt bundle = NULL;
-    dm_event_pt event = NULL;
-    dm_service_dependency_pt dependency = _ptr;
+	celix_status_t status = CELIX_SUCCESS;
+	bundle_context_pt context = NULL;
+	bundle_pt bundle = NULL;
+	dm_event_pt event = NULL;
+	dm_service_dependency_pt dependency = _ptr;
 
-    if (!dependency || !reference || !service) {
-        status = CELIX_ILLEGAL_ARGUMENT;
-    }
+	if (!dependency || !reference || !service) {
+		status = CELIX_ILLEGAL_ARGUMENT;
+	}
 
-    if (status == CELIX_SUCCESS) {
-        status = component_getBundleContext(dependency->component, &context);
-        if (!context) {
-            status = CELIX_BUNDLE_EXCEPTION;
-        }
-    }
+	if (status == CELIX_SUCCESS) {
+		status = component_getBundleContext(dependency->component, &context);
+		if (!context) {
+			status = CELIX_BUNDLE_EXCEPTION;
+		}
+	}
 
-    if (status == CELIX_SUCCESS) {
-        status = bundleContext_getBundle(context, &bundle);
-        if (!bundle) {
-            status = CELIX_BUNDLE_EXCEPTION;
-        }
-    }
+	if (status == CELIX_SUCCESS) {
+		status = bundleContext_getBundle(context, &bundle);
+		if (!bundle) {
+			status = CELIX_BUNDLE_EXCEPTION;
+		}
+	}
 
-    if (status == CELIX_SUCCESS) {
-        status = event_create(DM_EVENT_REMOVED, bundle, context, reference, service, &event);
-    }
+	if (status == CELIX_SUCCESS) {
+		status = event_create(DM_EVENT_REMOVED, bundle, context, reference, service, &event);
+	}
 
-    if (status == CELIX_SUCCESS) {
-        component_handleEvent(dependency->component, dependency, event);
-    }
+	if (status == CELIX_SUCCESS) {
+		component_handleEvent(dependency->component, dependency, event);
+	}
 
-    return status;
+	return status;
 }
 
 celix_status_t serviceDependency_getServiceDependencyInfo(dm_service_dependency_pt dep, dm_service_dependency_info_pt *out) {
-    celix_status_t status = CELIX_SUCCESS;
-    dm_service_dependency_info_pt info = calloc(1, sizeof(*info));
-    if (info != NULL) {
-        celixThreadMutex_lock(&dep->lock);
-        info->available = dep->available;
-        info->filter = dep->tracked_filter != NULL ? strdup(dep->tracked_filter) : NULL;
-        if (info->filter == NULL) {
-            info->filter = dep->tracked_service != NULL ? strdup(dep->tracked_service) : NULL;
-        }
-        info->required = dep->required;
-
-        array_list_pt refs = serviceTracker_getServiceReferences(dep->tracker);
-        if (refs != NULL) {
-            info->count = arrayList_size(refs);
-        }
-        arrayList_destroy(refs);
-
-        celixThreadMutex_unlock(&dep->lock);
-    } else {
-        status = CELIX_ENOMEM;
-    }
-
-    if (status == CELIX_SUCCESS) {
-        *out = info;
-    }
-
-    return status;
+	celix_status_t status = CELIX_SUCCESS;
+	dm_service_dependency_info_pt info = calloc(1, sizeof(*info));
+	if (info != NULL) {
+		celixThreadMutex_lock(&dep->lock);
+		info->available = dep->available;
+		info->filter = dep->tracked_filter != NULL ? strdup(dep->tracked_filter) : NULL;
+		if (info->filter == NULL) {
+			info->filter = dep->tracked_service != NULL ? strdup(dep->tracked_service) : NULL;
+		}
+		info->required = dep->required;
+
+		array_list_pt refs = serviceTracker_getServiceReferences(dep->tracker);
+		if (refs != NULL) {
+			info->count = arrayList_size(refs);
+		}
+		arrayList_destroy(refs);
+
+		celixThreadMutex_unlock(&dep->lock);
+	} else {
+		status = CELIX_ENOMEM;
+	}
+
+	if (status == CELIX_SUCCESS) {
+		*out = info;
+	}
+
+	return status;
 }
 
 void dependency_destroyDependencyInfo(dm_service_dependency_info_pt info) {
-    if (info != NULL) {
-        free(info->filter);
-    }
-    free(info);
+	if (info != NULL) {
+		free(info->filter);
+	}
+	free(info);
 }

http://git-wip-us.apache.org/repos/asf/celix/blob/777b8311/deployment_admin/private/src/log_sync.c
----------------------------------------------------------------------
diff --git a/deployment_admin/private/src/log_sync.c b/deployment_admin/private/src/log_sync.c
index 164e51c..242beea 100644
--- a/deployment_admin/private/src/log_sync.c
+++ b/deployment_admin/private/src/log_sync.c
@@ -118,7 +118,7 @@ celix_status_t logSync_parseLogDescriptor(log_sync_pt logSync, char *descriptorS
 static void *logSync_synchronize(void *logSyncP) {
 	log_sync_pt logSync = logSyncP;
 
-		while (logSync->running) {
+	while (logSync->running) {
 
 		//query current log
 		// http://localhost:8080/auditlog/query?tid=targetid&logid=logid
@@ -139,6 +139,11 @@ static void *logSync_synchronize(void *logSyncP) {
 				logStore_getEvents(logSync->logStore, &events);
 			}
 		}
+
+		if(descriptor!=NULL){
+			free(descriptor);
+		}
+
 		sleep(10);
 	}
 
@@ -166,7 +171,7 @@ celix_status_t logSync_queryLog(log_sync_pt logSync, char *targetId, long logId,
 	chunk.memory = calloc(1, sizeof(char));
 	chunk.size = 0;
 	if (curl) {
-	    curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
+		curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
 		curl_easy_setopt(curl, CURLOPT_URL, query);
 		curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, logSync_readQeury);
 		curl_easy_setopt(curl, CURLOPT_WRITEDATA, &chunk);

http://git-wip-us.apache.org/repos/asf/celix/blob/777b8311/deployment_admin/private/src/unzip.c
----------------------------------------------------------------------
diff --git a/deployment_admin/private/src/unzip.c b/deployment_admin/private/src/unzip.c
index e80113d..3aab52c 100644
--- a/deployment_admin/private/src/unzip.c
+++ b/deployment_admin/private/src/unzip.c
@@ -750,6 +750,7 @@ local unzFile unzOpenInternal (const void *path,
     us.central_pos = central_pos;
     us.pfile_in_zip_read = NULL;
     us.encrypted = 0;
+    us.num_file = 0;
 
 
     s=(unz64_s*)ALLOC(sizeof(unz64_s));
@@ -784,6 +785,7 @@ extern unzFile ZEXPORT unzOpen2_64 (const void *path,
         zlib_filefunc64_32_def_fill.zfile_func64 = *pzlib_filefunc_def;
         zlib_filefunc64_32_def_fill.ztell32_file = NULL;
         zlib_filefunc64_32_def_fill.zseek32_file = NULL;
+        zlib_filefunc64_32_def_fill.zopen32_file = NULL;
         return unzOpenInternal(path, &zlib_filefunc64_32_def_fill, 1);
     }
     else

http://git-wip-us.apache.org/repos/asf/celix/blob/777b8311/device_access/device_access/private/include/driver_attributes.h
----------------------------------------------------------------------
diff --git a/device_access/device_access/private/include/driver_attributes.h b/device_access/device_access/private/include/driver_attributes.h
index 73bfac1..bdb12a2 100644
--- a/device_access/device_access/private/include/driver_attributes.h
+++ b/device_access/device_access/private/include/driver_attributes.h
@@ -31,6 +31,7 @@
 typedef struct driver_attributes *driver_attributes_pt;
 
 celix_status_t driverAttributes_create(service_reference_pt reference, driver_service_pt driver, driver_attributes_pt *attributes);
+celix_status_t driverAttributes_destroy(driver_attributes_pt attributes);
 
 celix_status_t driverAttributes_getReference(driver_attributes_pt driverAttributes, service_reference_pt *reference);
 celix_status_t driverAttributes_getDriverId(driver_attributes_pt driverAttributes, char **driverId);

http://git-wip-us.apache.org/repos/asf/celix/blob/777b8311/device_access/device_access/private/src/device_manager.c
----------------------------------------------------------------------
diff --git a/device_access/device_access/private/src/device_manager.c b/device_access/device_access/private/src/device_manager.c
index 14a7a02..b39e5af 100644
--- a/device_access/device_access/private/src/device_manager.c
+++ b/device_access/device_access/private/src/device_manager.c
@@ -193,15 +193,17 @@ static celix_status_t deviceManager_attachAlgorithm(device_manager_pt manager, s
 								}
 							}
 							arrayListIterator_destroy(idsIter);
-						} else {
-							// Ignore
+						}
+						if(id != NULL){
+							free(id);
 						}
 					}
 					hashMapIterator_destroy(iter);
 
 					status = deviceManager_matchAttachDriver(manager, loader, driverIds, included, excluded, service, ref);
-					arrayList_destroy(driverIds);
+
 				}
+				arrayList_destroy(driverIds);
 				properties_destroy(properties);
 				arrayList_destroy(excluded);
 			}
@@ -209,6 +211,8 @@ static celix_status_t deviceManager_attachAlgorithm(device_manager_pt manager, s
 		}
 
 	}
+
+	driverLoader_destroy(&loader);
 	return status;
 }
 
@@ -287,6 +291,9 @@ celix_status_t deviceManager_matchAttachDriver(device_manager_pt manager, driver
 				}
 			}
 		}
+
+		driverMatcher_destroy(&matcher);
+
 	}
 
 	if (references != NULL) {
@@ -333,6 +340,9 @@ celix_status_t deviceManager_driverAdded(void * handle, service_reference_pt ref
 	if (status == CELIX_SUCCESS) {
 		hashMap_put(manager->drivers, ref, attributes);
 	}
+	else{
+		driverAttributes_destroy(attributes);
+	}
 	return status;
 }
 

http://git-wip-us.apache.org/repos/asf/celix/blob/777b8311/device_access/device_access/private/src/driver_attributes.c
----------------------------------------------------------------------
diff --git a/device_access/device_access/private/src/driver_attributes.c b/device_access/device_access/private/src/driver_attributes.c
index 3beb675..5da996d 100644
--- a/device_access/device_access/private/src/driver_attributes.c
+++ b/device_access/device_access/private/src/driver_attributes.c
@@ -72,6 +72,13 @@ celix_status_t driverAttributes_create(service_reference_pt reference, driver_se
 	return status;
 }
 
+celix_status_t driverAttributes_destroy(driver_attributes_pt attributes){
+	if(attributes != NULL){
+		free(attributes);
+	}
+	return CELIX_SUCCESS;
+}
+
 celix_status_t driverAttributes_getReference(driver_attributes_pt driverAttributes, service_reference_pt *reference) {
 	*reference = driverAttributes->reference;
 

http://git-wip-us.apache.org/repos/asf/celix/blob/777b8311/device_access/device_access/private/src/driver_loader.c
----------------------------------------------------------------------
diff --git a/device_access/device_access/private/src/driver_loader.c b/device_access/device_access/private/src/driver_loader.c
index 6cb6a65..c4caa65 100644
--- a/device_access/device_access/private/src/driver_loader.c
+++ b/device_access/device_access/private/src/driver_loader.c
@@ -51,7 +51,11 @@ celix_status_t driverLoader_create(bundle_context_pt context, driver_loader_pt *
 }
 
 celix_status_t driverLoader_destroy(driver_loader_pt *loader) {
-	arrayList_destroy((*loader)->loadedDrivers);
+	if((*loader) != NULL){
+		arrayList_destroy((*loader)->loadedDrivers);
+		free((*loader));
+		(*loader)=NULL;
+	}
 	return CELIX_SUCCESS;
 }
 
@@ -137,8 +141,8 @@ celix_status_t driverLoader_loadDriverForLocator(driver_loader_pt loader, driver
 	if (status == CELIX_SUCCESS) {
 		bundle_pt bundle = NULL;
 		int length = strlen(DRIVER_LOCATION_PREFIX) + strlen(driverId);
-		char location[length];
-		snprintf(location, length, "%s%s", DRIVER_LOCATION_PREFIX, driverId);
+		char location[length+2];
+		snprintf(location, length+2, "%s%s", DRIVER_LOCATION_PREFIX, driverId);
 		status = bundleContext_installBundle2(loader->context, location, filename, &bundle);
 		if (status == CELIX_SUCCESS) {
 			status = bundle_start(bundle);

http://git-wip-us.apache.org/repos/asf/celix/blob/777b8311/device_access/device_access/private/src/driver_matcher.c
----------------------------------------------------------------------
diff --git a/device_access/device_access/private/src/driver_matcher.c b/device_access/device_access/private/src/driver_matcher.c
index 5b9103d..98ad69b 100644
--- a/device_access/device_access/private/src/driver_matcher.c
+++ b/device_access/device_access/private/src/driver_matcher.c
@@ -81,21 +81,34 @@ celix_status_t driverMatcher_create(bundle_context_pt context, driver_matcher_pt
 }
 
 celix_status_t driverMatcher_destroy(driver_matcher_pt *matcher) {
-	arrayList_destroy((*matcher)->matches);
-	hash_map_iterator_pt iter = hashMapIterator_create((*matcher)->attributes);
-	while (hashMapIterator_hasNext(iter)) {
-		array_list_pt list = hashMapIterator_nextValue(iter);
-		if (list != NULL) {
-			arrayList_destroy(list);
+
+	if((*matcher) != NULL){
+
+		int i = 0;
+
+		for(;i<arrayList_size((*matcher)->matches);i++){
+			free(arrayList_get((*matcher)->matches,i));
 		}
-	}
-	hashMapIterator_destroy(iter);
-	hashMap_destroy((*matcher)->attributes, false, false);
+		arrayList_destroy((*matcher)->matches);
+
+		hash_map_iterator_pt iter = hashMapIterator_create((*matcher)->attributes);
+		while (hashMapIterator_hasNext(iter)) {
+			hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
+			match_key_t match = (match_key_t)hashMapEntry_getKey(entry);
+			array_list_pt list = (array_list_pt)hashMapEntry_getValue(entry);
+			free(match);
+			if (list != NULL) {
+				arrayList_destroy(list);
+			}
+		}
+		hashMapIterator_destroy(iter);
+		hashMap_destroy((*matcher)->attributes, false, false);
 
-	logHelper_stop((*matcher)->loghelper);
-	logHelper_destroy(&(*matcher)->loghelper);
+		logHelper_stop((*matcher)->loghelper);
+		logHelper_destroy(&(*matcher)->loghelper);
 
-	free(*matcher);
+		free(*matcher);
+	}
 
 	return CELIX_SUCCESS;
 }
@@ -137,6 +150,8 @@ celix_status_t driverMatcher_get(driver_matcher_pt matcher, int key, array_list_
 		hashMap_put(matcher->attributes, matchKey, *attributes);
 	}
 
+	free(matchKeyS);
+
 	return status;
 }
 

http://git-wip-us.apache.org/repos/asf/celix/blob/777b8311/device_access/driver_locator/private/src/activator.c
----------------------------------------------------------------------
diff --git a/device_access/driver_locator/private/src/activator.c b/device_access/driver_locator/private/src/activator.c
index 9cc5500..f17ae67 100644
--- a/device_access/driver_locator/private/src/activator.c
+++ b/device_access/driver_locator/private/src/activator.c
@@ -41,15 +41,10 @@ typedef struct bundle_instance *bundle_instance_pt;
 
 celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
 	celix_status_t status = CELIX_SUCCESS;
-	bundle_instance_pt bi = calloc(1, sizeof(struct bundle_instance));
-	if (userData != NULL) {
-		bi->service=NULL;
-		bi->locator=NULL;
-		bi->locatorRegistration=NULL;
-		(*userData)=bi;
-	} else {
+	(*userData) = calloc(1, sizeof(struct bundle_instance));
+	if ( (*userData) == NULL ){
 		status = CELIX_ENOMEM;
-    }
+	}
     return status;
 }
 

http://git-wip-us.apache.org/repos/asf/celix/blob/777b8311/device_access/example/base_driver/private/include/base_driver_private.h
----------------------------------------------------------------------
diff --git a/device_access/example/base_driver/private/include/base_driver_private.h b/device_access/example/base_driver/private/include/base_driver_private.h
index 4667e65..3ee5814 100644
--- a/device_access/example/base_driver/private/include/base_driver_private.h
+++ b/device_access/example/base_driver/private/include/base_driver_private.h
@@ -35,4 +35,7 @@ celix_status_t baseDriver_noDriverFound(device_pt device);
 
 celix_status_t baseDriver_getNextChar(base_driver_device_pt service, char *c);
 
+celix_status_t baseDriver_destroy(base_driver_device_pt device);
+celix_status_t baseDriver_destroyService(base_driver_device_service_pt service);
+
 #endif /* BASE_DRIVER_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/777b8311/device_access/example/base_driver/private/src/activator.c
----------------------------------------------------------------------
diff --git a/device_access/example/base_driver/private/src/activator.c b/device_access/example/base_driver/private/src/activator.c
index c59a68b..a6b9d62 100644
--- a/device_access/example/base_driver/private/src/activator.c
+++ b/device_access/example/base_driver/private/src/activator.c
@@ -60,9 +60,9 @@ celix_status_t bundleActivator_create(bundle_context_pt context, void **userData
 static celix_status_t bundleActivator_registerBaseDriverDevice(base_driver_bundle_instance_pt bi, char *serial) {
 	celix_status_t status = CELIX_SUCCESS;
 	base_driver_device_pt device = NULL;
+	base_driver_device_service_pt service = NULL;
 	status = baseDriver_create(&device);
 	if (status == CELIX_SUCCESS) {
-		base_driver_device_service_pt service = NULL;
 		status = baseDriver_createService(device, &service);
 		if (status == CELIX_SUCCESS) {
 			properties_pt props = properties_create();
@@ -72,11 +72,9 @@ static celix_status_t bundleActivator_registerBaseDriverDevice(base_driver_bundl
 			status = bundleContext_registerService(bi->context, OSGI_DEVICEACCESS_DEVICE_SERVICE_NAME, service, props, &service_registration);
 			if (status == CELIX_SUCCESS) {
 				arrayList_add(bi->serviceRegistrations, service_registration);
-//				service_registration = NULL;
-//				status = bundleContext_registerService(bi->context, BASE_DRIVER_SERVICE_NAME, service, NULL, &service_registration);
-//				if (status == CELIX_SUCCESS) {
-//					arrayList_add(bi->serviceRegistrations, service_registration);
-//				}
+			}
+			else{
+				properties_destroy(props);
 			}
 		}
 	}
@@ -87,6 +85,12 @@ static celix_status_t bundleActivator_registerBaseDriverDevice(base_driver_bundl
 		char error[256];
 		printf("BASE_DRIVER: Unsuccessfully registered device service with serial %s. Got error: %s\n",
 				serial, celix_strerror(status, error, 256));
+		if(service != NULL){
+			baseDriver_destroyService(service);
+		}
+		if(device != NULL){
+			baseDriver_destroy(device);
+		}
 	}
 	return status;
 }

http://git-wip-us.apache.org/repos/asf/celix/blob/777b8311/device_access/example/base_driver/private/src/base_driver.c
----------------------------------------------------------------------
diff --git a/device_access/example/base_driver/private/src/base_driver.c b/device_access/example/base_driver/private/src/base_driver.c
index 33a2dca..a48c7de 100644
--- a/device_access/example/base_driver/private/src/base_driver.c
+++ b/device_access/example/base_driver/private/src/base_driver.c
@@ -92,3 +92,20 @@ celix_status_t baseDriver_getNextChar(base_driver_device_pt device, char *c) {
 	return CELIX_SUCCESS;
 }
 
+celix_status_t baseDriver_destroy(base_driver_device_pt device){
+	if(device != NULL){
+		if(device->device != NULL){
+			free(device->device);
+		}
+		free(device);
+	}
+	return CELIX_SUCCESS;
+}
+
+celix_status_t baseDriver_destroyService(base_driver_device_service_pt service){
+	if(service != NULL){
+		free(service);
+	}
+
+	return CELIX_SUCCESS;
+}

http://git-wip-us.apache.org/repos/asf/celix/blob/777b8311/device_access/example/refining_driver/private/include/refining_driver_private.h
----------------------------------------------------------------------
diff --git a/device_access/example/refining_driver/private/include/refining_driver_private.h b/device_access/example/refining_driver/private/include/refining_driver_private.h
index 32d5082..37f15a5 100644
--- a/device_access/example/refining_driver/private/include/refining_driver_private.h
+++ b/device_access/example/refining_driver/private/include/refining_driver_private.h
@@ -52,6 +52,7 @@ celix_status_t refiningDriver_match(void *driver, service_reference_pt reference
 
 celix_status_t refiningDriverDevice_noDriverFound(device_pt device);
 celix_status_t refiningDriverDevice_createService(refining_driver_device_pt, refining_driver_device_service_pt *service);
+celix_status_t refiningDriverDevice_destroyService(refining_driver_device_service_pt service);
 celix_status_t refiningDriverDevice_getNextWord(refining_driver_device_pt refiningDriverDevice, char **word);
 
 #endif /* REFINING_DRIVER_PRIVATE_H_ */

http://git-wip-us.apache.org/repos/asf/celix/blob/777b8311/device_access/example/refining_driver/private/src/refining_driver.c
----------------------------------------------------------------------
diff --git a/device_access/example/refining_driver/private/src/refining_driver.c b/device_access/example/refining_driver/private/src/refining_driver.c
index fe3e03e..b624e7d 100644
--- a/device_access/example/refining_driver/private/src/refining_driver.c
+++ b/device_access/example/refining_driver/private/src/refining_driver.c
@@ -167,8 +167,9 @@ static celix_status_t refiningDriver_registerDevice(refining_driver_pt driver, r
 	celix_status_t status = CELIX_SUCCESS;
 	refining_driver_device_service_pt service = NULL;
 	status = refiningDriverDevice_createService(device, &service);
+	properties_pt props = properties_create();
+
 	if (status == CELIX_SUCCESS) {
-		properties_pt props = properties_create();
 		properties_set(props, OSGI_DEVICEACCESS_DEVICE_CATEGORY, REFINING_DRIVER_DEVICE_CATEGORY);
 		properties_set(props, OSGI_DEVICEACCESS_DEVICE_SERIAL, serial);
 		status = bundleContext_registerService(driver->context, OSGI_DEVICEACCESS_DEVICE_SERVICE_NAME, service, props, &device->deviceRegistration);
@@ -177,6 +178,10 @@ static celix_status_t refiningDriver_registerDevice(refining_driver_pt driver, r
 	if (status == CELIX_SUCCESS) {
 		printf("REFINING_DRIVER: registered refining device with serial %s\n", serial);
 	}
+	else{
+		properties_destroy(props);
+		refiningDriverDevice_destroyService(service);
+	}
 	return status;
 }
 
@@ -235,6 +240,16 @@ celix_status_t refiningDriverDevice_createService(refining_driver_device_pt devi
 	return status;
 }
 
+celix_status_t refiningDriverDevice_destroyService(refining_driver_device_service_pt service){
+	if(service != NULL){
+		if(service->deviceService.device != NULL){
+			free(service->deviceService.device);
+		}
+		free(service);
+	}
+	return CELIX_SUCCESS;
+}
+
 celix_status_t refiningDriverDevice_getNextWord(refining_driver_device_pt refiningDriverDevice, char **word) {
 	celix_status_t status = CELIX_SUCCESS;
 	base_driver_device_pt baseDevice = refiningDriverDevice->baseDriverDeviceService->baseDriverDevice;

http://git-wip-us.apache.org/repos/asf/celix/blob/777b8311/dfi/private/src/dyn_type.c
----------------------------------------------------------------------
diff --git a/dfi/private/src/dyn_type.c b/dfi/private/src/dyn_type.c
index 9b98a43..24fd09c 100644
--- a/dfi/private/src/dyn_type.c
+++ b/dfi/private/src/dyn_type.c
@@ -1071,8 +1071,9 @@ static void dynType_printTypedPointer(char *name, dyn_type *type, int depth, FIL
     dynType_printDepth(depth, stream);
     fprintf(stream, "%s: typed pointer, size is %zu, alignment is %i, points to ->\n", name, type->ffiType->size, type->ffiType->alignment);
     char *subName = NULL;
+    char buf[128];
+    memset(buf,0,128);
     if (name != NULL) {
-        char buf[128];
         snprintf(buf, 128, "*%s", name);
         subName = buf;
     }

http://git-wip-us.apache.org/repos/asf/celix/blob/777b8311/dfi/private/src/json_serializer.c
----------------------------------------------------------------------
diff --git a/dfi/private/src/json_serializer.c b/dfi/private/src/json_serializer.c
index 1a9b4b0..85ba782 100644
--- a/dfi/private/src/json_serializer.c
+++ b/dfi/private/src/json_serializer.c
@@ -82,17 +82,15 @@ static int jsonSerializer_createType(dyn_type *type, json_t *val, void **result)
         if (status == OK) {
             assert(inst != NULL);
             status = jsonSerializer_parseAny(type, inst, val);
-
-            if (status != OK) {
-                dynType_free(type, inst);
-            }
         }
     }
 
-
     if (status == OK) {
         *result = inst;
     }
+    else{
+    	dynType_free(type, inst);
+    }
 
     return status;
 }

http://git-wip-us.apache.org/repos/asf/celix/blob/777b8311/dfi/private/test/dyn_interface_tests.cpp
----------------------------------------------------------------------
diff --git a/dfi/private/test/dyn_interface_tests.cpp b/dfi/private/test/dyn_interface_tests.cpp
index d3ef642..d417685 100644
--- a/dfi/private/test/dyn_interface_tests.cpp
+++ b/dfi/private/test/dyn_interface_tests.cpp
@@ -42,6 +42,7 @@ extern "C" {
         va_start(ap, msg);
         vfprintf(stderr, msg, ap);
         fprintf(stderr, "\n");
+        va_end(ap);
     }
 
     static void checkInterfaceVersion(dyn_interface_type* dynIntf, const char* v) {
@@ -118,57 +119,66 @@ extern "C" {
         FILE *desc = fopen("descriptors/invalids/invalid.descriptor", "r");
         assert(desc != NULL);
         status = dynInterface_parse(desc, &dynIntf);
-        CHECK_EQUAL(1, status); //Test fails because of a space at the end of the name
-        fclose(desc);
         dynInterface_destroy(dynIntf);
+        CHECK_EQUAL(1, status); //Test fails because of a space at the end of the name
+        fclose(desc); desc=NULL;
+
 
         /* Header without Version */
         desc = fopen("descriptors/invalids/noVersion.descriptor", "r");
+        assert(desc != NULL);
         status = dynInterface_parse(desc, &dynIntf);
-        CHECK_EQUAL(1, status); //Test fails because of missing version field in header section
-        fclose(desc);
         dynInterface_destroy(dynIntf);
+        CHECK_EQUAL(1, status); //Test fails because of missing version field in header section
+        fclose(desc); desc=NULL;
 
         /* Invalid section */
         desc = fopen("descriptors/invalids/invalidSection.descriptor", "r");
+        assert(desc != NULL);
         status = dynInterface_parse(desc, &dynIntf);
-        CHECK_EQUAL(1, status); //Test fails because of unknown section type
-        fclose(desc);
         dynInterface_destroy(dynIntf);
+        CHECK_EQUAL(1, status); //Test fails because of unknown section type
+        fclose(desc); desc=NULL;
 
         /* Invalid return type */
         desc = fopen("descriptors/invalids/invalidMethodReturnType.descriptor", "r");
+        assert(desc != NULL);
         status = dynInterface_parse(desc, &dynIntf);
-        CHECK_EQUAL(1, status); //Test fails because of invalid return type (D instead of N)
-        fclose(desc);
         dynInterface_destroy(dynIntf);
+        CHECK_EQUAL(1, status); //Test fails because of invalid return type (D instead of N)
+        fclose(desc); desc=NULL;
 
         /* Invalid  method section */
         desc = fopen("descriptors/invalids/invalidMethod.descriptor", "r");
+        assert(desc != NULL);
         status = dynInterface_parse(desc, &dynIntf);
-        CHECK_EQUAL(1, status); //Test fails because of space at the end of the method
-        fclose(desc);
         dynInterface_destroy(dynIntf);
+        CHECK_EQUAL(1, status); //Test fails because of space at the end of the method
+        fclose(desc); desc=NULL;
 
         /* Invalid type */
         desc = fopen("descriptors/invalids/invalidType.descriptor", "r");
+        assert(desc != NULL);
         status = dynInterface_parse(desc, &dynIntf);
-        CHECK_EQUAL(1, status); //Test fails because of space at the end of the type
-        fclose(desc);
         dynInterface_destroy(dynIntf);
+        CHECK_EQUAL(1, status); //Test fails because of space at the end of the type
+        fclose(desc); desc=NULL;
 
         /* Invalid metatype in method description */
         desc = fopen("descriptors/invalids/invalidMetaType.descriptor", "r");
+        assert(desc != NULL);
         status = dynInterface_parse(desc, &dynIntf);
-        CHECK_EQUAL(0, status); //Invalid meta type doesn't generate errors, just warnings
-        fclose(desc);
         dynInterface_destroy(dynIntf);
+        CHECK_EQUAL(0, status); //Invalid meta type doesn't generate errors, just warnings
+        fclose(desc); desc=NULL;
 
         /* Invalid version section */
         desc = fopen("descriptors/invalids/invalidVersion.descriptor", "r");
+        assert(desc != NULL);
         status = dynInterface_parse(desc, &dynIntf);
         CHECK_EQUAL(1, status); //Invalid meta type doesn't generate errors, just warnings
-        fclose(desc);
+        fclose(desc); desc=NULL;
+
     }
 }
 

http://git-wip-us.apache.org/repos/asf/celix/blob/777b8311/examples/locking/mutex_benchmark/private/src/mutex_benchmark.c
----------------------------------------------------------------------
diff --git a/examples/locking/mutex_benchmark/private/src/mutex_benchmark.c b/examples/locking/mutex_benchmark/private/src/mutex_benchmark.c
index 615b98e..07c9c5c 100644
--- a/examples/locking/mutex_benchmark/private/src/mutex_benchmark.c
+++ b/examples/locking/mutex_benchmark/private/src/mutex_benchmark.c
@@ -17,6 +17,7 @@
  *under the License.
  */
 #include <stdlib.h>
+#include <string.h>
 #include <pthread.h>
 #include <sys/time.h>
 #include <stdio.h>
@@ -60,6 +61,7 @@ benchmark_result_t benchmark_run(benchmark_pt benchmark, int nrOfThreads, int nr
 	pthread_t threads[nrOfThreads];
 	thread_info_t infos[nrOfThreads];
 	benchmark_result_t result;
+	memset(&result,0,sizeof(benchmark_result_t));
 	unsigned long elapsedTime = 0;
 
 	result.skips =0;

http://git-wip-us.apache.org/repos/asf/celix/blob/777b8311/examples/mongoose/private/src/mongoose.c
----------------------------------------------------------------------
diff --git a/examples/mongoose/private/src/mongoose.c b/examples/mongoose/private/src/mongoose.c
index 34eb2c6..b1f0a4b 100644
--- a/examples/mongoose/private/src/mongoose.c
+++ b/examples/mongoose/private/src/mongoose.c
@@ -2203,6 +2203,7 @@ int mg_modify_passwords_file(struct mg_context *ctx, const char *fname,
     return 0;
   } else if ((fp2 = mg_fopen(tmp, "w+")) == NULL) {
     cry(fc(ctx), "Cannot open %s: %s", tmp, strerror(errno));
+    fclose(fp);
     return 0;
   }
 
@@ -2366,6 +2367,7 @@ static void handle_directory_request(struct mg_connection *conn,
     if (entries == NULL) {
       send_http_error(conn, 500, "Cannot open directory",
           "%s", "Error: cannot allocate memory");
+      closedir(dirp);
       return;
     }
 
@@ -3476,7 +3478,9 @@ static int load_dll(struct mg_context *ctx, const char *dll_name,
     return 0;
   }
 
-  for (fp = sw; fp->name != NULL; fp++) {
+  int ret = 1;
+
+  for (fp = sw; fp->name != NULL && ret==1; fp++) {
 #ifdef _WIN32
     // GetProcAddress() returns pointer to function
     u.fp = (void (*)(void)) dlsym(dll_handle, fp->name);
@@ -3487,13 +3491,15 @@ static int load_dll(struct mg_context *ctx, const char *dll_name,
 #endif /* _WIN32 */
     if (u.fp == NULL) {
       cry(fc(ctx), "%s: %s: cannot find %s", __func__, dll_name, fp->name);
-      return 0;
+      ret=0;
     } else {
       fp->ptr = u.fp;
     }
   }
 
-  return 1;
+  dlclose(dll_handle);
+
+  return ret;
 }
 #endif // NO_SSL_DL
 
@@ -3804,9 +3810,9 @@ static void worker_thread(struct mg_context *ctx) {
   struct mg_connection *conn;
   int buf_size = atoi(ctx->config[MAX_REQUEST_SIZE]);
 
-  conn = calloc(1, sizeof(*conn) + buf_size);
+  conn = calloc(1, sizeof(*conn));
   conn->buf_size = buf_size;
-  conn->buf = (char *) (conn + 1);
+  conn->buf = calloc(buf_size + 1, sizeof(char));
   assert(conn != NULL);
 
   while (ctx->stop_flag == 0 && consume_socket(ctx, &conn->client)) {
@@ -3829,6 +3835,7 @@ static void worker_thread(struct mg_context *ctx) {
 
     close_connection(conn);
   }
+  free(conn->buf);
   free(conn);
 
   // Signal master that we're done with connection and exiting
@@ -3863,7 +3870,8 @@ static void produce_socket(struct mg_context *ctx, const struct socket *sp) {
 static void accept_new_connection(const struct socket *listener,
                                   struct mg_context *ctx) {
   struct socket accepted;
-  int allowed;
+  memset(&accepted,0,sizeof(struct socket));
+  int allowed = 0;
 
   accepted.rsa.len = sizeof(accepted.rsa.u.sin);
   accepted.lsa = listener->lsa;

http://git-wip-us.apache.org/repos/asf/celix/blob/777b8311/examples/osgi-in-action/chapter04-correct-listener/private/src/listener_example.c
----------------------------------------------------------------------
diff --git a/examples/osgi-in-action/chapter04-correct-listener/private/src/listener_example.c b/examples/osgi-in-action/chapter04-correct-listener/private/src/listener_example.c
index a0e118b..adbf027 100644
--- a/examples/osgi-in-action/chapter04-correct-listener/private/src/listener_example.c
+++ b/examples/osgi-in-action/chapter04-correct-listener/private/src/listener_example.c
@@ -102,6 +102,7 @@ celix_status_t bundleActivator_start(void * userData, bundle_context_pt context)
                 event->type = OSGI_FRAMEWORK_SERVICE_EVENT_REGISTERED;
 
                 listenerExample_serviceChanged(listener, event);
+                free(event);
             }
             arrayList_destroy(logServices);
         }
@@ -145,7 +146,7 @@ void listenerExample_serviceChanged(service_listener_pt listener, service_event_
 //		// only the service metadata has changed, so no need to do anything here
 //		break;
     case OSGI_FRAMEWORK_SERVICE_EVENT_UNREGISTERING:
-        arrayList_remove(activator->logServiceReferences, arrayList_indexOf(activator->logServiceReferences, event->reference));
+        arrayList_removeElement(activator->logServiceReferences, event->reference);
         break;
     default:
         break;

http://git-wip-us.apache.org/repos/asf/celix/blob/777b8311/examples/producer_consumer/database/private/src/activator.c
----------------------------------------------------------------------
diff --git a/examples/producer_consumer/database/private/src/activator.c b/examples/producer_consumer/database/private/src/activator.c
index e0f2791..babb2b5 100644
--- a/examples/producer_consumer/database/private/src/activator.c
+++ b/examples/producer_consumer/database/private/src/activator.c
@@ -83,32 +83,41 @@ celix_status_t bundleActivator_start(void * userData, bundle_context_pt context)
 
 	if (readerService && writerService && databaseHandler)
 	{
-	    status = celixThreadMutex_create(&databaseHandler->lock, NULL);
+		status = celixThreadMutex_create(&databaseHandler->lock, NULL);
 
-	    if (status == CELIX_SUCCESS)
-	    {
-            arrayList_create(&databaseHandler->data);
-            databaseHandler->dataIndex = 0;
+		if (status == CELIX_SUCCESS)
+		{
+			arrayList_create(&databaseHandler->data);
+			databaseHandler->dataIndex = 0;
 
-            readerService->handler = databaseHandler;
-            readerService->readerService_getFirstData = readerService_getFirstData;
-            readerService->readerService_getNextData = readerService_getNextData;
+			readerService->handler = databaseHandler;
+			readerService->readerService_getFirstData = readerService_getFirstData;
+			readerService->readerService_getNextData = readerService_getNextData;
 
-            writerService->handler = databaseHandler;
-            writerService->writerService_storeData = writerService_storeData;
-            writerService->writerService_removeData = writerService_removeData;
+			writerService->handler = databaseHandler;
+			writerService->writerService_storeData = writerService_storeData;
+			writerService->writerService_removeData = writerService_removeData;
 
-            activator->readerService = readerService;
-            activator->writerService = writerService;
+			activator->readerService = readerService;
+			activator->writerService = writerService;
 
-            status = bundleContext_registerService(context, READER_SERVICE_NAME, activator->readerService, NULL,  &activator->readerRegistration);
+			status = bundleContext_registerService(context, READER_SERVICE_NAME, activator->readerService, NULL,  &activator->readerRegistration);
 
-            if (status == CELIX_SUCCESS)
-                status = bundleContext_registerService(context, WRITER_SERVICE_NAME, activator->writerService, NULL,  &activator->writerRegistration);
-	    }
+			if (status == CELIX_SUCCESS)
+				status = bundleContext_registerService(context, WRITER_SERVICE_NAME, activator->writerService, NULL,  &activator->writerRegistration);
+		}
 	}
 	else
 	{
+		if(readerService!=NULL){
+			free(readerService);
+		}
+		if(writerService!=NULL){
+			free(writerService);
+		}
+		if(databaseHandler!=NULL){
+			free(databaseHandler);
+		}
 		status = CELIX_ENOMEM;
 	}
 
@@ -129,6 +138,16 @@ celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt contex
 	celix_status_t status = CELIX_SUCCESS;
 	struct activator *activator = userData;
 
+	database_handler_pt dbh = (database_handler_pt)activator->writerService->handler;
+	if(dbh != NULL){
+		celixThreadMutex_destroy(&dbh->lock);
+		if(dbh->data != NULL){
+			arrayList_destroy(dbh->data);
+		}
+		free(dbh);
+		activator->writerService->handler=NULL;
+	}
+
 	free(activator->readerService);
 	free(activator->writerService);
 	free(activator);

http://git-wip-us.apache.org/repos/asf/celix/blob/777b8311/framework/private/mock/celix_log_mock.c
----------------------------------------------------------------------
diff --git a/framework/private/mock/celix_log_mock.c b/framework/private/mock/celix_log_mock.c
index 7904553..81e635d 100644
--- a/framework/private/mock/celix_log_mock.c
+++ b/framework/private/mock/celix_log_mock.c
@@ -49,6 +49,8 @@ void framework_logCode(framework_logger_pt logger, framework_log_level_t level,
     vsprintf(msg, fmsg, listPointer);
 
     test_logger_log(logger, level, func, file, line, "%s [%d]: %s", message, code, msg);
+
+    va_end(listPointer);
 }
 
 celix_status_t frameworkLogger_log(framework_log_level_t level, const char *func, const char *file, int line, char *msg) {


Mime
View raw message