You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by pn...@apache.org on 2016/04/29 18:58:12 UTC

[1/3] celix git commit: CELIX-282: Adds pnoltes public key to KEYS

Repository: celix
Updated Branches:
  refs/heads/develop b6ac4103c -> 137fdf5c3


CELIX-282: Adds pnoltes public key to KEYS


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

Branch: refs/heads/develop
Commit: 6990fce356d242d2fc214f77d0fb68db454d8f14
Parents: b6ac410
Author: Pepijn Noltes <pe...@gmail.com>
Authored: Fri Apr 29 18:56:25 2016 +0200
Committer: Pepijn Noltes <pe...@gmail.com>
Committed: Fri Apr 29 18:56:25 2016 +0200

----------------------------------------------------------------------
 KEYS | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/6990fce3/KEYS
----------------------------------------------------------------------
diff --git a/KEYS b/KEYS
index 0e7133e..fc22f80 100644
--- a/KEYS
+++ b/KEYS
@@ -68,3 +68,62 @@ jtrA7VPWWYYbDAyqdtY0zq50YHfu4d9Ur8eBtZh8hRkV/Yzan0WBSyk2R66rkJxF
 lgk16W9izi4Ig9MKh8xZwd7hYY/a4+PumxM/Wvc0nX0sqTDWUlKu1R3GRU54zA==
 =Zm9I
 -----END PGP PUBLIC KEY BLOCK-----
+
+pub   4096R/9F60113D 2016-04-29
+uid                  Pepijn Noltes (CODE SIGNING KEY) <pn...@apache.org>
+sig 3        9F60113D 2016-04-29  Pepijn Noltes (CODE SIGNING KEY) <pn...@apache.org>
+sub   4096R/F613B74E 2016-04-29
+sig          9F60113D 2016-04-29  Pepijn Noltes (CODE SIGNING KEY) <pn...@apache.org>
+
+-----BEGIN PGP PUBLIC KEY BLOCK-----
+Version: GnuPG v2
+
+mQINBFcjZGABEACyJI0jM79pJt73v3NJ+2rSTcS7mdrWNubzojGtPAaegihjYdgh
+f/v5IO/Zq9OMKUkhdx9JeMdhRPHYpnelebTAmF4vDYz9z4CIOQ7wD+0dhUS1933P
+e3OAIp3Km75svRRCPY9rqc9l8XYaBi20pGx2xdELjkDe3KMiwwRrGh3Go9ZAuWhC
+WhtrsGPqa89oiejf+yT0FswUXoIxNOw8G1TLifwvd3mjqipd5ApjDCXPVJKng63q
+TGCFJr+C9PESEkchTvwVqZvFe7FJ1nsVvPi3+SrrFUK2G35qnHvaImJW7umJEGpo
+JblEfSIo6ut8Oc+SYrGIJVRHXI67ZMQIxvs1V4cq2SiS9yaSfD+RSorhIyXdP/Ws
++gblzDlFiP/1fTAGTS4hwbpPIbjRtx8c+xLmngu/fGltHhpnRZbsvlbLzg5SmP6L
+y3g2isifU+T8rd8gmTPXPoEgOceMQ470U9YOGhggwl8/jdocOkeqMkQgDiZhXbk+
+pz7kewDkGKL7HZiKIUvK1ID+bsTsvbFLZt74CaFQULeMaVxp8VBY56drTdt+yC9u
+y5JkTleSR4BV9vNynoNTVmdGUn/A7FuhyzVAsgxwZ2pKDQmwLpzoBVm4hldDNw9H
+KisU7PxUwlnFe6TlOtWLl1byNImeUYSyawZ1zDHUb9rZoKzk0mwgD+A7yQARAQAB
+tDVQZXBpam4gTm9sdGVzIChDT0RFIFNJR05JTkcgS0VZKSA8cG5vbHRlc0BhcGFj
+aGUub3JnPokCNwQTAQoAIQUCVyNkYAIbAwULCQgHAwUVCgkICwUWAgMBAAIeAQIX
+gAAKCRDoWoGsn2ARPfa6D/sGNKgSKxssW2lV4YjYppMyNTlXUWnBhDLeM0q2zaIL
+B/yiWi/Sz1QWGyDH5bII2slG4mukGQ5yPdBaA9Q4WnCkPc4ZGsxi/aRelOqicJaz
+tXZmiX8Y8jrf7wZ1dV7kbkLm3RTU9sv6o7g9k525z4R4Wtdcb8OeaLEpl3dbg8fH
+RiIREDKiRU2TRcLxq/9NI89BM8jGUw9zMitYcMDlU7Fv8F9OKBzK8/BM7zKMb6fe
+wmo/C8MeqMjM6ObpMzLREF7DuY+tO3OlX0JcPa8kO3vRXQiXOWIqz0Y9xaal99Xk
+zfghwX0Blzom/pbr/slaKo/TJ+O2vlKcdmYgxHtK3xciZNC3llvGqtXgTqzFCMFs
+triYLDj7wSSYZBZmG4PZKA5DE9qCVxWJiU5G/j5x/XZfyrB5CiDki67RfrbTrQdz
+UWhwmga4QyrECUTormYag2x0qoACLaq8fdsTpfjSKgW4yeYfxs45i9CY7TiGSZhL
+YqrwyzOqxS8oM+xBvqH0nHhfFZIrcOhjb4hYRJGhBKPpyCiZw8/Ptq6XcoMAoav/
+8DRbs5/cCliEC19dpy/eWDERmQCyJPW0NjztX5ZScQJW1S697NDIYGlz5um3srzg
+yMa6o/pcen8UdQYT9iwZiujOLMl670gc//ck6LV1HyMFTFGT4ENyWqCYwKN7OAjy
+zrkCDQRXI2RgARAAxbDRwFDBZ8gqrf+7HVw9GhIe02etMc7abAycxzZ05n0Z0k6G
+46VSQB7ixOcBrVaB8VQtfpRNOHABwCvFG+jutH9pK1N3cXcke2hToGcuTUuU28zn
+T6PtlSpCmZoh2JZSgSuRtR/C7l6AgA/2ifSx0PIj/fv7fcIkNv6PQ0mFXdfAUuhW
+a8uqyg6l0HkpDPzA6LMyriDGIkdiBC6hkBQKo4erLDwBoMsW2sOiJIylrcXpOORT
+dOfdAfgJYf+G/hYLnLadMw0sefNjyVex6DkTVFEoXBFFE/yGLiGrl339nEdfEtUI
+SLaet/IrGljiO+4TLj9PHIINTYtEHx7tI8pwk90lqU4cuwCtxWqwpfJGd5YCdcPm
+lxevWpBHZtb7+2H8wKU9r7b7IM7wZ6zjPR1Yzh8NGje7e0rfpuG1EJ3Wo5NTWS4z
+YlXhbdDtme7+r18pnLkhMkeET1ZaAgqTYjfntvQiFqkH1WzUtKx1l8vKjRBVrbeX
+K0VoAZPpXFi3goq5zSYyLMXCOERYsHfKgPg6P9XUleNQt/5Hwbog7DcQFZ8B4lOO
+BhZ5kBs4sggv2rnEdPORHgrw5OApItY4be3xNRv7y2dBGLYeW9VO8ETBjjvUryx5
+HPOgUVYOTlMkipCuf4tB2DBmgTTDT5mLkTe2KeLF1ysWOD90JJmVjnUXg2UAEQEA
+AYkCHwQYAQoACQUCVyNkYAIbDAAKCRDoWoGsn2ARPXNnD/9/tyX83VxafeUOmHLo
+ilnoPssdB+qlpW3+vAO7FjTuB+YwG2sW0g/RuJZG4cmq3L7NVEWwG1+G1kUAeqVA
+OMgQyhjHqfPja1Iy8sbCYlraIRMbEm23Y2nV+2Y7s8wuBXqOY5ELuxFpmgCRl4Uu
+UvrJV6eZ+TKNDZ3qUm/WRVfPBZ/AhPdPse5XItSs538k2bELoTl/ZvJy1kWTdyjz
+ptaeuDpZeSOg0FrXSAlkj2B4SAjPw3UaeFoLVL8lzltGC4xV/ikKYQV5JJYc5UTr
+CN4y8sV0Mi3REYiZ5a25SYduvspjOW6HMRWhelPoEbjUEChVR0qWbKvPVFV0PmI3
+xPMAeH6VWx9TQ+PAg+V0bqJso8cS4WUlNm+bHG6w1tNPkF/fUCmGZqAjB2rRZXJy
+AbrsEDtYI/plCXE4YNZpKrRR2r7hvoJPFY+HbBuwgKNA92uI1AWYRhqjGjNmQ7Lt
+nKQAR8oqiMUSoBtakd9akiN3uezgUZkDoOj1VXEHPlihsrToMwkWjZIONXOfeF9x
+vyh0dz13F4TbdhVioaLs/7VOiFbCdQ2RjglEEV4jCfWi+hOue/tCdQ1W9Ny+NdnT
+wmzm0Np85+1mjPpBpcgpjZ97vBDv/MzUKYTO0UPhy8AMuI7kASruD2f3GHuPxdXD
+NnVt2h/2kW18Z3P8yJJuLaEMLg==
+=HfMZ
+-----END PGP PUBLIC KEY BLOCK-----


[3/3] celix git commit: CELIX-357: Fixes coverity warnings. Medium priority

Posted by pn...@apache.org.
CELIX-357: Fixes coverity warnings. Medium priority


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

Branch: refs/heads/develop
Commit: 137fdf5c3cf86c3357c1f0cac6163ded561df297
Parents: 6990fce
Author: Pepijn Noltes <pe...@gmail.com>
Authored: Fri Apr 29 18:59:07 2016 +0200
Committer: Pepijn Noltes <pe...@gmail.com>
Committed: Fri Apr 29 18:59:07 2016 +0200

----------------------------------------------------------------------
 .../private/src/dm_activator_base.c             |   4 +
 .../private/src/dm_component_impl.c             |  55 +-
 .../private/src/dm_service_dependency.c         |   6 +-
 .../private/src/dm_shell_activator.c            |  23 +-
 .../private/src/dm_shell_list_command.c         |   8 +-
 deployment_admin/private/src/deployment_admin.c |   8 +-
 .../device_access/private/src/device_manager.c  |   4 +-
 .../driver_locator/private/src/activator.c      |  35 +-
 dfi/private/src/dyn_function.c                  |  13 +-
 dfi/private/src/dyn_interface.c                 |  13 +-
 dfi/private/src/dyn_message.c                   |  10 +-
 dfi/private/src/dyn_type.c                      |   7 +-
 dfi/private/src/json_rpc.c                      | 571 ++++++++++---------
 dfi/private/src/json_serializer.c               |  10 +-
 .../test/avro_descriptor_translator_tests.cpp   |   1 +
 dfi/private/test/dyn_closure_tests.cpp          |   1 +
 dfi/private/test/dyn_function_tests.cpp         |   1 +
 dfi/private/test/dyn_message_tests.cpp          |   1 +
 dfi/private/test/dyn_type_tests.cpp             |   1 +
 dfi/private/test/json_rpc_tests.cpp             |   9 +-
 dfi/private/test/json_serializer_tests.cpp      |   1 +
 examples/embedding/private/src/main.c           |  67 ++-
 .../private/src/benchmark_runner_activator.c    |   9 +-
 .../private/src/mutex_benchmark.c               |   2 +
 examples/mongoose/private/src/mongoose.c        |  18 +-
 .../private/src/listener_example.c              |   2 +-
 .../private/src/activator.c                     |   2 +-
 framework/private/mock/celix_log_mock.c         |   2 +
 framework/private/src/bundle_archive.c          |   4 +-
 framework/private/src/bundle_cache.c            |   9 +-
 framework/private/src/celix_launcher.c          | 208 +++----
 framework/private/src/celix_log.c               |   4 +
 framework/private/src/framework.c               | 126 ++--
 framework/private/src/resolver.c                |  12 +-
 framework/private/test/bundle_cache_test.cpp    |  25 +-
 framework/private/test/bundle_test.cpp          |   2 +-
 log_service/private/src/log.c                   |  10 +-
 .../private/src/log_reader_service_impl.c       |   2 +-
 log_service/private/src/log_service_impl.c      |   8 +-
 log_service/public/src/log_helper.c             |  27 +-
 .../private/src/endpoint_descriptor_reader.c    |   5 +-
 .../private/src/endpoint_discovery_poller.c     |  24 +-
 .../discovery_shm/private/src/discovery_shm.c   |  11 +-
 .../calculator_shell/private/src/add_command.c  |  45 +-
 .../calculator_shell/private/src/sqrt_command.c |  31 +-
 .../calculator_shell/private/src/sub_command.c  |  13 +-
 .../rsa/private/src/import_registration_dfi.c   |   6 +-
 .../rsa/private/src/remote_service_admin_dfi.c  |  14 +-
 .../private/src/remote_service_admin_impl.c     |  20 +-
 .../private/src/remote_service_admin_impl.c     |   4 +-
 .../private/src/topology_manager.c              |  34 +-
 remote_services/utils/private/src/civetweb.c    |  14 +-
 remote_shell/private/src/remote_shell.c         |   2 +-
 remote_shell/private/src/shell_mediator.c       |   2 +-
 shell/private/src/shell.c                       |   2 +-
 utils/private/src/thpool.c                      |   4 +-
 utils/private/test/celix_threads_test.cpp       |  13 +-
 57 files changed, 818 insertions(+), 747 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/dependency_manager/private/src/dm_activator_base.c
----------------------------------------------------------------------
diff --git a/dependency_manager/private/src/dm_activator_base.c b/dependency_manager/private/src/dm_activator_base.c
index a7e6500..cbd1762 100644
--- a/dependency_manager/private/src/dm_activator_base.c
+++ b/dependency_manager/private/src/dm_activator_base.c
@@ -112,6 +112,10 @@ celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt contex
 	celix_status_t status = CELIX_SUCCESS;
 	dependency_activator_base_pt dependency_activator = (dependency_activator_base_pt) userData;
 
+	if(dependency_activator==NULL){
+		return CELIX_ILLEGAL_ARGUMENT;
+	}
+
     status = dm_destroy(dependency_activator->userData, dependency_activator->context,
                         dependency_activator->manager);
 

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/dependency_manager/private/src/dm_component_impl.c
----------------------------------------------------------------------
diff --git a/dependency_manager/private/src/dm_component_impl.c b/dependency_manager/private/src/dm_component_impl.c
index 0d9745e..ef46811 100644
--- a/dependency_manager/private/src/dm_component_impl.c
+++ b/dependency_manager/private/src/dm_component_impl.c
@@ -503,6 +503,7 @@ celix_status_t component_handleChanged(dm_component_pt component, dm_service_dep
     array_list_pt events = hashMap_get(component->dependencyEvents, dependency);
     int index = arrayList_indexOf(events, event);
     if (index < 0) {
+	pthread_mutex_unlock(&component->mutex);
         status = CELIX_BUNDLE_EXCEPTION;
     } else {
         dm_event_pt old = arrayList_remove(events, (unsigned int) index);
@@ -556,6 +557,7 @@ celix_status_t component_handleRemoved(dm_component_pt component, dm_service_dep
     pthread_mutex_lock(&component->mutex);
     int index = arrayList_indexOf(events, event);
     if (index < 0) {
+	pthread_mutex_unlock(&component->mutex);
         status = CELIX_BUNDLE_EXCEPTION;
     } else {
         dm_event_pt old = arrayList_remove(events, (unsigned int) index);
@@ -608,6 +610,7 @@ celix_status_t component_handleSwapped(dm_component_pt component, dm_service_dep
     array_list_pt events = hashMap_get(component->dependencyEvents, dependency);
     int index = arrayList_indexOf(events, event);
     if (index < 0) {
+	pthread_mutex_unlock(&component->mutex);
         status = CELIX_BUNDLE_EXCEPTION;
     } else {
         dm_event_pt old = arrayList_remove(events, (unsigned int) index);
@@ -1340,37 +1343,35 @@ celix_status_t component_getComponentInfo(dm_component_pt component, dm_componen
     dm_component_info_pt info = NULL;
     info = calloc(1, sizeof(*info));
 
+    if(info==NULL){
+	return CELIX_ENOMEM;
+    }
 
-    if (info != NULL) {
-        arrayList_create(&info->dependency_list);
-        component_getInterfaces(component, &info->interfaces);
-        info->active = false;
-        memcpy(info->id, component->id, DM_COMPONENT_MAX_ID_LENGTH);
-        memcpy(info->name, component->name, DM_COMPONENT_MAX_NAME_LENGTH);
+    arrayList_create(&info->dependency_list);
+    component_getInterfaces(component, &info->interfaces);
+    info->active = false;
+    memcpy(info->id, component->id, DM_COMPONENT_MAX_ID_LENGTH);
+    memcpy(info->name, component->name, DM_COMPONENT_MAX_NAME_LENGTH);
 
-        switch (component->state) {
-            case DM_CMP_STATE_INACTIVE :
-                info->state = strdup("INACTIVE");
-                break;
-            case DM_CMP_STATE_WAITING_FOR_REQUIRED :
-                info->state = strdup("WAITING_FOR_REQUIRED");
-                break;
-            case DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED :
-                info->state = strdup("INSTANTIATED_AND_WAITING_FOR_REQUIRED");
-                break;
-            case DM_CMP_STATE_TRACKING_OPTIONAL :
-                info->state = strdup("TRACKING_OPTIONAL");
-                info->active = true;
-                break;
-            default :
-                info->state = strdup("UNKNOWN");
-                break;
-        }
-    } else {
-        status = CELIX_ENOMEM;
+    switch (component->state) {
+    case DM_CMP_STATE_INACTIVE :
+	info->state = strdup("INACTIVE");
+	break;
+    case DM_CMP_STATE_WAITING_FOR_REQUIRED :
+	info->state = strdup("WAITING_FOR_REQUIRED");
+	break;
+    case DM_CMP_STATE_INSTANTIATED_AND_WAITING_FOR_REQUIRED :
+	info->state = strdup("INSTANTIATED_AND_WAITING_FOR_REQUIRED");
+	break;
+    case DM_CMP_STATE_TRACKING_OPTIONAL :
+	info->state = strdup("TRACKING_OPTIONAL");
+	info->active = true;
+	break;
+    default :
+	info->state = strdup("UNKNOWN");
+	break;
     }
 
-
     celixThreadMutex_lock(&component->mutex);
     size = arrayList_size(component->dependencies);
     for (i = 0; i < size; i += 1) {

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/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 733f7fd..4f63c6d 100644
--- a/dependency_manager/private/src/dm_service_dependency.c
+++ b/dependency_manager/private/src/dm_service_dependency.c
@@ -150,7 +150,7 @@ celix_status_t serviceDependency_getStrategy(dm_service_dependency_pt dependency
 
 celix_status_t serviceDependency_setService(dm_service_dependency_pt dependency, char *serviceName, char *serviceVersionRange, char *filter) {
 	celix_status_t status = CELIX_SUCCESS;
-	if (!dependency) {
+	if (!dependency || !serviceName) {
 		status = CELIX_ILLEGAL_ARGUMENT;
 	}
 
@@ -158,9 +158,7 @@ celix_status_t serviceDependency_setService(dm_service_dependency_pt dependency,
 		array_list_pt filterElements = NULL;
 		arrayList_create(&filterElements);
 
-		if (serviceName != NULL) {
-			dependency->tracked_service = strdup(serviceName);
-		}
+		dependency->tracked_service = strdup(serviceName);
 
 		if (serviceVersionRange != NULL) {
 			version_range_pt versionRange = NULL;

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/dependency_manager/private/src/dm_shell_activator.c
----------------------------------------------------------------------
diff --git a/dependency_manager/private/src/dm_shell_activator.c b/dependency_manager/private/src/dm_shell_activator.c
index fcb42cd..89234c7 100644
--- a/dependency_manager/private/src/dm_shell_activator.c
+++ b/dependency_manager/private/src/dm_shell_activator.c
@@ -39,26 +39,19 @@ typedef struct bundle_instance * bundle_instance_pt;
 
 celix_status_t bundleActivator_create(bundle_context_pt context, void **userData) {
 
+	if(userData==NULL){
+		return CELIX_ILLEGAL_ARGUMENT;
+	}
+
     struct bundle_instance *bi = calloc(sizeof (struct bundle_instance), 1);
-    celix_status_t status = CELIX_SUCCESS;
 
-    if (!bi) {
-        status = CELIX_ENOMEM;
-    }
-    else if (userData == NULL) {
-        status = CELIX_ILLEGAL_ARGUMENT;
-        free(bi);
+    if (bi==NULL) {
+        return CELIX_ENOMEM;
     }
-    else {
-        if (status != CELIX_SUCCESS) {
-            printf("DM:LIST Create failed\n");
-            free(bi);
-        }
 
-        (*userData) = bi;
-    }
+    (*userData) = bi;
 
-    return status;
+    return CELIX_SUCCESS;
 }
 
 celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/dependency_manager/private/src/dm_shell_list_command.c
----------------------------------------------------------------------
diff --git a/dependency_manager/private/src/dm_shell_list_command.c b/dependency_manager/private/src/dm_shell_list_command.c
index 6f95eb9..be4eaf4 100644
--- a/dependency_manager/private/src/dm_shell_list_command.c
+++ b/dependency_manager/private/src/dm_shell_list_command.c
@@ -43,6 +43,12 @@ void dmListCommand_execute(bundle_context_pt context, char * line, FILE *out, FI
     array_list_pt servRefs = NULL;
     int i;
     bundleContext_getServiceReferences(context, DM_INFO_SERVICE_NAME ,NULL, &servRefs);
+
+    if(servRefs==NULL){
+	fprintf(out, "Invalid dm_info ServiceReferences List\n");
+	return;
+    }
+
     char *term = getenv("TERM");
     bool colors = false;
     if (strcmp("xterm-256color", term) == 0) {
@@ -109,7 +115,7 @@ void dmListCommand_execute(bundle_context_pt context, char * line, FILE *out, FI
 		bundleContext_ungetService(context,servRef,NULL);
 		bundleContext_ungetServiceReference(context,servRef);
 
-        }
+    }
 
 	if(servRefs!=NULL){
 		arrayList_destroy(servRefs);

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/deployment_admin/private/src/deployment_admin.c
----------------------------------------------------------------------
diff --git a/deployment_admin/private/src/deployment_admin.c b/deployment_admin/private/src/deployment_admin.c
index 97cc7e1..2c4b9ee 100644
--- a/deployment_admin/private/src/deployment_admin.c
+++ b/deployment_admin/private/src/deployment_admin.c
@@ -295,7 +295,9 @@ static void *deploymentAdmin_poll(void *deploymentAdmin) {
 					uuid_generate(uid);
 					uuid_unparse(uid, uuid);
                     snprintf(tmpDir, 256, "%s%s", entry, uuid);
-                    mkdir(tmpDir, S_IRWXU);
+                    if( mkdir(tmpDir, S_IRWXU) == -1){
+			fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Failed creating directory %s",tmpDir);
+                    }
 
 					// TODO: update to use bundle cache DataFile instead of module entries.
 					unzip_extractDeploymentPackage(inputFilename, tmpDir);
@@ -338,7 +340,9 @@ static void *deploymentAdmin_poll(void *deploymentAdmin) {
 
 					deploymentAdmin_deleteTree(repoCache);
 					deploymentAdmin_deleteTree(tmpDir);
-					remove(inputFilename);
+					if( remove(inputFilename) == -1){
+						fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Remove of %s failed",inputFilename);
+					}
 					admin->current = strdup(last);
 					hashMap_put(admin->packages, name, source);
 				}

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/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 b39e5af..dea4513 100644
--- a/device_access/device_access/private/src/device_manager.c
+++ b/device_access/device_access/private/src/device_manager.c
@@ -75,9 +75,11 @@ celix_status_t deviceManager_create(bundle_context_pt context, log_helper_pt log
 		(*manager)->loghelper = logHelper;
 
 		status = arrayList_create(&(*manager)->locators);
+
+		logHelper_log((*manager)->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Initialized");
 	}
 
-	logHelper_log((*manager)->loghelper, OSGI_LOGSERVICE_DEBUG, "DEVICE_MANAGER: Initialized");
+
 	return status;
 }
 

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/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 f17ae67..6c13e10 100644
--- a/device_access/driver_locator/private/src/activator.c
+++ b/device_access/driver_locator/private/src/activator.c
@@ -51,23 +51,28 @@ celix_status_t bundleActivator_create(bundle_context_pt context, void **userData
 celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) {
     celix_status_t status = CELIX_SUCCESS;
     bundle_instance_pt bi = (bundle_instance_pt)userData;
-    if (status == CELIX_SUCCESS) {
-        bi->service = calloc(1, sizeof(*(bi->service)));
-        bi->service->findDrivers = driverLocator_findDrivers;
-        bi->service->loadDriver = driverLocator_loadDriver;
 
-        bi->locator = calloc(1, sizeof(*(bi->locator)));
-        bi->service->locator = bi->locator;
-        bi->locator->drivers = NULL;
-        arrayList_create(&bi->locator->drivers);
-        bundleContext_getProperty(context, "DRIVER_LOCATOR_PATH", &bi->locator->path);
-        if (bi->locator->path == NULL ) {
-        	bi->locator->path = (char *)DEFAULT_LOCATOR_PATH;
-        }
-        bundleContext_registerService(context, OSGI_DEVICEACCESS_DRIVER_LOCATOR_SERVICE_NAME, bi->service, NULL, &bi->locatorRegistration);
-    } else {
-        status = CELIX_START_ERROR;
+    bi->service = calloc(1, sizeof(*(bi->service)));
+    bi->locator = calloc(1, sizeof(*(bi->locator)));
+    if(bi->service != NULL && bi->locator != NULL){
+	bi->service->findDrivers = driverLocator_findDrivers;
+	bi->service->loadDriver = driverLocator_loadDriver;
+
+	bi->service->locator = bi->locator;
+	bi->locator->drivers = NULL;
+	arrayList_create(&bi->locator->drivers);
+	bundleContext_getProperty(context, "DRIVER_LOCATOR_PATH", &bi->locator->path);
+	if (bi->locator->path == NULL ) {
+		bi->locator->path = (char *)DEFAULT_LOCATOR_PATH;
+	}
+	status = bundleContext_registerService(context, OSGI_DEVICEACCESS_DRIVER_LOCATOR_SERVICE_NAME, bi->service, NULL, &bi->locatorRegistration);
     }
+    else{
+	if(bi->service!=NULL) free(bi->service);
+	if(bi->locator!=NULL) free(bi->locator);
+	status = CELIX_ENOMEM;
+    }
+
     return status;
 }
 

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/dfi/private/src/dyn_function.c
----------------------------------------------------------------------
diff --git a/dfi/private/src/dyn_function.c b/dfi/private/src/dyn_function.c
index 3727f8a..615ad16 100644
--- a/dfi/private/src/dyn_function.c
+++ b/dfi/private/src/dyn_function.c
@@ -157,7 +157,7 @@ static int dynFunction_parseDescriptor(dyn_function_type *dynFunc, FILE *descrip
         dyn_function_argument_type *arg = NULL;
 
         status = dynType_parse(descriptor, NULL, dynFunc->refTypes, &type);
-        if (status == 0) {
+        if (status == OK) {
             arg = calloc(1, sizeof(*arg));
             if (arg != NULL) {
                 arg->index = index;
@@ -174,15 +174,8 @@ static int dynFunction_parseDescriptor(dyn_function_type *dynFunc, FILE *descrip
 
         if (status == OK) {
             TAILQ_INSERT_TAIL(&dynFunc->arguments, arg, entries);
-        } else {
-            if (arg != NULL) {
-                free(arg->name);
-                if (arg->type != NULL) {
-                    dynType_destroy(arg->type);
-                }
-                free(arg);
-            }
         }
+
         nextChar = fgetc(descriptor);
     }
 
@@ -217,7 +210,7 @@ static int dynFunction_initCif(dyn_function_type *dynFunc) {
         count +=1;
     }
 
-    dynFunc->ffiArguments = calloc(count, sizeof(ffi_type));
+    dynFunc->ffiArguments = calloc(count, sizeof(ffi_type*));
 
     TAILQ_FOREACH(entry, &dynFunc->arguments, entries) {
         dynFunc->ffiArguments[entry->index] = dynType_ffiType(entry->type);

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/dfi/private/src/dyn_interface.c
----------------------------------------------------------------------
diff --git a/dfi/private/src/dyn_interface.c b/dfi/private/src/dyn_interface.c
index fdd872d..cbd675b 100644
--- a/dfi/private/src/dyn_interface.c
+++ b/dfi/private/src/dyn_interface.c
@@ -57,12 +57,12 @@ int dynInterface_parse(FILE *descriptor, dyn_interface_type **out) {
         TAILQ_INIT(&intf->types);
         TAILQ_INIT(&intf->methods);
 
-        char peek = fgetc(descriptor);
+        char peek = (char)fgetc(descriptor);
         while (peek == ':') {
             ungetc(peek, descriptor);
             status = dynInterface_parseSection(intf, descriptor);
             if (status == OK) {
-                peek = fgetc(descriptor);
+                peek = (char)fgetc(descriptor);
             } else {
                 break;
             }
@@ -217,9 +217,6 @@ static int dynInterface_parseNameValueSection(dyn_interface_type *intf, FILE *st
             if (value != NULL) {
                 free(value);
             }
-            if (entry != NULL) {
-                free(entry);
-            }
             break;
         }
         peek = fgetc(stream);
@@ -272,9 +269,6 @@ static int dynInterface_parseTypes(dyn_interface_type *intf, FILE *stream) {
             if (type != NULL) {
                 dynType_destroy(type);
             }
-            if (entry != NULL) {
-                free(entry);
-            }
             break;
         }
         peek = fgetc(stream);
@@ -344,9 +338,6 @@ static int dynInterface_parseMethods(dyn_interface_type *intf, FILE *stream) {
                 dynFunction_destroy(func);
                 //TODO free strIdentier, name
             }
-            if (entry != NULL) {
-                free(entry);
-            }
             break;
         }
         peek = fgetc(stream);

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/dfi/private/src/dyn_message.c
----------------------------------------------------------------------
diff --git a/dfi/private/src/dyn_message.c b/dfi/private/src/dyn_message.c
index 5ec6c7a..3e2ca99 100644
--- a/dfi/private/src/dyn_message.c
+++ b/dfi/private/src/dyn_message.c
@@ -55,12 +55,12 @@ int dynMessage_parse(FILE *descriptor, dyn_message_type **out) {
         TAILQ_INIT(&msg->annotations);
         TAILQ_INIT(&msg->types);
 
-        char peek = fgetc(descriptor);
+        char peek = (char)fgetc(descriptor);
         while (peek == ':') {
             ungetc(peek, descriptor);
             status = dynMessage_parseSection(msg, descriptor);
             if (status == OK) {
-                peek = fgetc(descriptor);
+                peek = (char)fgetc(descriptor);
             } else {
                 break;
             }
@@ -205,9 +205,6 @@ static int dynMessage_parseNameValueSection(dyn_message_type *msg, FILE *stream,
             if (value != NULL) {
                 free(value);
             }
-            if (entry != NULL) {
-                free(entry);
-            }
             break;
         }
         peek = fgetc(stream);
@@ -260,9 +257,6 @@ static int dynMessage_parseTypes(dyn_message_type *msg, FILE *stream) {
             if (type != NULL) {
                 dynType_destroy(type);
             }
-            if (entry != NULL) {
-                free(entry);
-            }
             break;
         }
         peek = fgetc(stream);

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/dfi/private/src/dyn_type.c
----------------------------------------------------------------------
diff --git a/dfi/private/src/dyn_type.c b/dfi/private/src/dyn_type.c
index 24fd09c..2b83f25 100644
--- a/dfi/private/src/dyn_type.c
+++ b/dfi/private/src/dyn_type.c
@@ -313,7 +313,7 @@ static int dynType_parseComplex(FILE *stream, dyn_type *type) {
 
     if (status == OK) {
         type->complex.structType.type =  FFI_TYPE_STRUCT;
-        type->complex.structType.elements = calloc(count + 1, sizeof(ffi_type));
+        type->complex.structType.elements = calloc(count + 1, sizeof(ffi_type*));
         if (type->complex.structType.elements != NULL) {
             type->complex.structType.elements[count] = NULL;
             int index = 0;
@@ -328,7 +328,7 @@ static int dynType_parseComplex(FILE *stream, dyn_type *type) {
 
     if (status == OK) {
         type->complex.types = calloc(count, sizeof(dyn_type *));
-        if (type != NULL) {
+        if (type->complex.types != NULL) {
             int index = 0;
             TAILQ_FOREACH(entry, &type->complex.entriesHead, entries) {
                 type->complex.types[index++] = entry->type;
@@ -635,6 +635,7 @@ int dynType_complex_indexForName(dyn_type *type, const char *name) {
 
 int dynType_complex_dynTypeAt(dyn_type *type, int index, dyn_type **result) {
     assert(type->type == DYN_TYPE_COMPLEX);
+    assert(index >= 0);
     dyn_type *sub = type->complex.types[index];
     if (sub->type == DYN_TYPE_REF) {
         sub = sub->ref.ref;
@@ -656,7 +657,7 @@ int dynType_complex_valLocAt(dyn_type *type, int index, void *inst, void **resul
     char *l = (char *)inst;
     void *loc = (void *)(l + dynType_getOffset(type, index));
     *result = loc;
-    return 0;
+    return OK;
 }
 
 int dynType_complex_entries(dyn_type *type, struct complex_type_entries_head **entries) {

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/dfi/private/src/json_rpc.c
----------------------------------------------------------------------
diff --git a/dfi/private/src/json_rpc.c b/dfi/private/src/json_rpc.c
index 20d453d..72e3c7e 100644
--- a/dfi/private/src/json_rpc.c
+++ b/dfi/private/src/json_rpc.c
@@ -35,302 +35,305 @@ DFI_SETUP_LOG(jsonRpc);
 typedef void (*gen_func_type)(void);
 
 struct generic_service_layout {
-    void *handle;
-    gen_func_type methods[];
+	void *handle;
+	gen_func_type methods[];
 };
 
 int jsonRpc_call(dyn_interface_type *intf, void *service, const char *request, char **out) {
-    int status = OK;
-
-    dyn_type* returnType = NULL;
-
-    LOG_DEBUG("Parsing data: %s\n", request);
-    json_error_t error;
-    json_t *js_request = json_loads(request, 0, &error);
-    json_t *arguments = NULL;
-    const char *sig;
-    if (js_request) {
-        if (json_unpack(js_request, "{s:s}", "m", &sig) != 0) {
-            LOG_ERROR("Got json error '%s'\n", error.text);
-        } else {
-            arguments = json_object_get(js_request, "a");
-        }
-    } else {
-        LOG_ERROR("Got json error '%s' for '%s'\n", error.text, request);
-        return 0;
-    }
-
-    LOG_DEBUG("Looking for method %s\n", sig);
-    struct methods_head *methods = NULL;
-    dynInterface_methods(intf, &methods);
-    struct method_entry *entry = NULL;
-    struct method_entry *method = NULL;
-    TAILQ_FOREACH(entry, methods, entries) {
-        if (strcmp(sig, entry->id) == 0) {
-            method = entry;
-            break;
-        }
-    }
-
-    if (method == NULL) {
-        status = ERROR;
-        LOG_ERROR("Cannot find method with sig '%s'", sig);
-    }
-
-    if (status == OK) {
-        LOG_DEBUG("RSA: found method '%s'\n", entry->id);
-        returnType = dynFunction_returnType(method->dynFunc);
-    }
-
-    void (*fp)(void) = NULL;
-    void *handle = NULL;
-    if (status == OK) {
-        struct generic_service_layout *serv = service;
-        handle = serv->handle;
-        fp = serv->methods[method->index];
-    }
-
-    dyn_function_type *func = NULL;
-    int nrOfArgs = 0;
-    if (status == OK) {
-        nrOfArgs = dynFunction_nrOfArguments(entry->dynFunc);
-        func = entry->dynFunc;
-    }
-
-    void *args[nrOfArgs];
-
-    json_t *value = NULL;
-
-    int i;
-    int index = 0;
-
-    void *ptr = NULL;
-    void *ptrToPtr = &ptr;
-
-    for (i = 0; i < nrOfArgs; i += 1) {
-        dyn_type *argType = dynFunction_argumentTypeForIndex(func, i);
-        enum dyn_function_argument_meta  meta = dynFunction_argumentMetaForIndex(func, i);
-        if (meta == DYN_FUNCTION_ARGUMENT_META__STD) {
-            value = json_array_get(arguments, index++);
-            status = jsonSerializer_deserializeJson(argType, value, &(args[i]));
-        } else if (meta == DYN_FUNCTION_ARGUMENT_META__PRE_ALLOCATED_OUTPUT) {
-            dynType_alloc(argType, &args[i]);
-        } else if (meta == DYN_FUNCTION_ARGUMENT_META__OUTPUT) {
-            args[i] = &ptrToPtr;
-        } else if (meta == DYN_FUNCTION_ARGUMENT_META__HANDLE) {
-            args[i] = &handle;
-        }
-
-        if (status != OK) {
-            break;
-        }
-    }
-    json_decref(js_request);
-
-    if (status == OK) {
+	int status = OK;
+
+	dyn_type* returnType = NULL;
+
+	LOG_DEBUG("Parsing data: %s\n", request);
+	json_error_t error;
+	json_t *js_request = json_loads(request, 0, &error);
+	json_t *arguments = NULL;
+	const char *sig;
+	if (js_request) {
+		if (json_unpack(js_request, "{s:s}", "m", &sig) != 0) {
+			LOG_ERROR("Got json error '%s'\n", error.text);
+		} else {
+			arguments = json_object_get(js_request, "a");
+		}
+	} else {
+		LOG_ERROR("Got json error '%s' for '%s'\n", error.text, request);
+		return 0;
+	}
+
+	LOG_DEBUG("Looking for method %s\n", sig);
+	struct methods_head *methods = NULL;
+	dynInterface_methods(intf, &methods);
+	struct method_entry *entry = NULL;
+	struct method_entry *method = NULL;
+	TAILQ_FOREACH(entry, methods, entries) {
+		if (strcmp(sig, entry->id) == 0) {
+			method = entry;
+			break;
+		}
+	}
+
+	if (method == NULL) {
+		status = ERROR;
+		LOG_ERROR("Cannot find method with sig '%s'", sig);
+	}
+	else if (status == OK) {
+		LOG_DEBUG("RSA: found method '%s'\n", entry->id);
+		returnType = dynFunction_returnType(method->dynFunc);
+	}
+
+	void (*fp)(void) = NULL;
+	void *handle = NULL;
+	if (status == OK) {
+		struct generic_service_layout *serv = service;
+		handle = serv->handle;
+		fp = serv->methods[method->index];
+	}
+
+	dyn_function_type *func = NULL;
+	int nrOfArgs = 0;
+	if (status == OK) {
+		nrOfArgs = dynFunction_nrOfArguments(entry->dynFunc);
+		func = entry->dynFunc;
+	}
+
+	void *args[nrOfArgs];
+
+	json_t *value = NULL;
+
+	int i;
+	int index = 0;
+
+	void *ptr = NULL;
+	void *ptrToPtr = &ptr;
+
+	for (i = 0; i < nrOfArgs; i += 1) {
+		dyn_type *argType = dynFunction_argumentTypeForIndex(func, i);
+		enum dyn_function_argument_meta  meta = dynFunction_argumentMetaForIndex(func, i);
+		if (meta == DYN_FUNCTION_ARGUMENT_META__STD) {
+			value = json_array_get(arguments, index++);
+			status = jsonSerializer_deserializeJson(argType, value, &(args[i]));
+		} else if (meta == DYN_FUNCTION_ARGUMENT_META__PRE_ALLOCATED_OUTPUT) {
+			dynType_alloc(argType, &args[i]);
+		} else if (meta == DYN_FUNCTION_ARGUMENT_META__OUTPUT) {
+			args[i] = &ptrToPtr;
+		} else if (meta == DYN_FUNCTION_ARGUMENT_META__HANDLE) {
+			args[i] = &handle;
+		}
+
+		if (status != OK) {
+			break;
+		}
+	}
+	json_decref(js_request);
+
+	if (status == OK) {
 		if (dynType_descriptorType(returnType) != 'N') {
 			//NOTE To be able to handle exception only N as returnType is supported
 			LOG_ERROR("Only interface methods with a native int are supported. Found type '%c'", (char)dynType_descriptorType(returnType));
 			status = ERROR;
 		}
-    }
-
-    ffi_sarg returnVal = 1;
-
-    if (status == OK) {
-        dynFunction_call(func, fp, (void *) &returnVal, args);
-    }
-
-    int funcCallStatus = (int)returnVal;
-    if (funcCallStatus != 0) {
-        LOG_WARNING("Error calling remote endpoint function, got error code %i", funcCallStatus);
-    }
-
-    json_t *jsonResult = NULL;
-    for(i = 0; i < nrOfArgs; i += 1) {
-        dyn_type *argType = dynFunction_argumentTypeForIndex(func, i);
-        enum dyn_function_argument_meta  meta = dynFunction_argumentMetaForIndex(func, i);
-        if (meta == DYN_FUNCTION_ARGUMENT_META__STD) {
-            dynType_free(argType, args[i]);
-        }
-    }
-
-    if (funcCallStatus == 0 && status == OK) {
-        for (i = 0; i < nrOfArgs; i += 1) {
-            dyn_type *argType = dynFunction_argumentTypeForIndex(func, i);
-            enum dyn_function_argument_meta  meta = dynFunction_argumentMetaForIndex(func, i);
-            if (meta == DYN_FUNCTION_ARGUMENT_META__PRE_ALLOCATED_OUTPUT) {
-                if (status == OK) {
-                    status = jsonSerializer_serializeJson(argType, args[i], &jsonResult);
-                }
-                dynType_free(argType, args[i]);
-            } else if (meta == DYN_FUNCTION_ARGUMENT_META__OUTPUT) {
-                if (ptr != NULL) {
-                    dyn_type *typedType = NULL;
-                    if (status == OK) {
-                        status = dynType_typedPointer_getTypedType(argType, &typedType);
-                    }
-                    if (dynType_descriptorType(typedType) == 't') {
-                        status = jsonSerializer_serializeJson(typedType, (void*) &ptr, &jsonResult);
-                        free(ptr);
-                    } else {
-                        dyn_type *typedTypedType = NULL;
-                        if (status == OK) {
-                            status = dynType_typedPointer_getTypedType(typedType, &typedTypedType);
-                        }
-
-                        status = jsonSerializer_serializeJson(typedTypedType, ptr, &jsonResult);
-
-                        if (status == OK) {
-                            dynType_free(typedTypedType, ptr);
-                        }
-                    }
-
-                } else {
-                    LOG_DEBUG("Output ptr is null");
-                }
-            }
-
-            if (status != OK) {
-                break;
-            }
-        }
-    }
-
-    char *response = NULL;
-    if (status == OK) {
-        LOG_DEBUG("creating payload\n");
-        json_t *payload = json_object();
-        if (funcCallStatus == 0) {
-            if (jsonResult == NULL) {
-                //ignore -> no result
-            } else {
-                LOG_DEBUG("Setting result payload");
-                json_object_set_new(payload, "r", jsonResult);
-            }
-        } else {
-            LOG_DEBUG("Setting error payload");
-            json_object_set_new(payload, "e", json_integer(funcCallStatus));
-        }
-        response = json_dumps(payload, JSON_DECODE_ANY);
-        json_decref(payload);
-        LOG_DEBUG("status ptr is %p. response is '%s'\n", status, response);
-    }
-
-    if (status == OK) {
-        *out = response;
-    } else {
-        free(response);
-    }
-
-    return status;
+	}
+
+	ffi_sarg returnVal = 1;
+
+	if (status == OK) {
+		dynFunction_call(func, fp, (void *) &returnVal, args);
+	}
+
+	int funcCallStatus = (int)returnVal;
+	if (funcCallStatus != 0) {
+		LOG_WARNING("Error calling remote endpoint function, got error code %i", funcCallStatus);
+	}
+
+	json_t *jsonResult = NULL;
+	for(i = 0; i < nrOfArgs; i += 1) {
+		dyn_type *argType = dynFunction_argumentTypeForIndex(func, i);
+		enum dyn_function_argument_meta  meta = dynFunction_argumentMetaForIndex(func, i);
+		if (meta == DYN_FUNCTION_ARGUMENT_META__STD) {
+			dynType_free(argType, args[i]);
+		}
+	}
+
+	if (funcCallStatus == 0 && status == OK) {
+		for (i = 0; i < nrOfArgs; i += 1) {
+			dyn_type *argType = dynFunction_argumentTypeForIndex(func, i);
+			enum dyn_function_argument_meta  meta = dynFunction_argumentMetaForIndex(func, i);
+			if (meta == DYN_FUNCTION_ARGUMENT_META__PRE_ALLOCATED_OUTPUT) {
+				if (status == OK) {
+					status = jsonSerializer_serializeJson(argType, args[i], &jsonResult);
+				}
+				dynType_free(argType, args[i]);
+			} else if (meta == DYN_FUNCTION_ARGUMENT_META__OUTPUT) {
+				if (ptr != NULL) {
+					dyn_type *typedType = NULL;
+					if (status == OK) {
+						status = dynType_typedPointer_getTypedType(argType, &typedType);
+					}
+					if (dynType_descriptorType(typedType) == 't') {
+						status = jsonSerializer_serializeJson(typedType, (void*) &ptr, &jsonResult);
+						free(ptr);
+					} else {
+						dyn_type *typedTypedType = NULL;
+						if (status == OK) {
+							status = dynType_typedPointer_getTypedType(typedType, &typedTypedType);
+						}
+
+						status = jsonSerializer_serializeJson(typedTypedType, ptr, &jsonResult);
+
+						if (status == OK) {
+							dynType_free(typedTypedType, ptr);
+						}
+					}
+
+				} else {
+					LOG_DEBUG("Output ptr is null");
+				}
+			}
+
+			if (status != OK) {
+				break;
+			}
+		}
+	}
+
+	char *response = NULL;
+	if (status == OK) {
+		LOG_DEBUG("creating payload\n");
+		json_t *payload = json_object();
+		if (funcCallStatus == 0) {
+			if (jsonResult == NULL) {
+				//ignore -> no result
+			} else {
+				LOG_DEBUG("Setting result payload");
+				json_object_set_new(payload, "r", jsonResult);
+			}
+		} else {
+			LOG_DEBUG("Setting error payload");
+			json_object_set_new(payload, "e", json_integer(funcCallStatus));
+		}
+		response = json_dumps(payload, JSON_DECODE_ANY);
+		json_decref(payload);
+		LOG_DEBUG("status ptr is %p. response is '%s'\n", status, response);
+	}
+
+	if (status == OK) {
+		*out = response;
+	} else {
+		free(response);
+	}
+
+	return status;
 }
 
 int jsonRpc_prepareInvokeRequest(dyn_function_type *func, const char *id, void *args[], char **out) {
-    int status = OK;
-
-
-    LOG_DEBUG("Calling remote function '%s'\n", id);
-    json_t *invoke = json_object();
-    json_object_set_new(invoke, "m", json_string(id));
-
-    json_t *arguments = json_array();
-    json_object_set_new(invoke, "a", arguments);
-
-    int i;
-    int nrOfArgs = dynFunction_nrOfArguments(func);
-    for (i = 0; i < nrOfArgs; i +=1) {
-        dyn_type *type = dynFunction_argumentTypeForIndex(func, i);
-        enum dyn_function_argument_meta  meta = dynFunction_argumentMetaForIndex(func, i);
-        if (meta == DYN_FUNCTION_ARGUMENT_META__STD) {
-            json_t *val = NULL;
-
-            int rc = jsonSerializer_serializeJson(type, args[i], &val);
-            if (rc == 0) {
-                json_array_append_new(arguments, val);
-            } else {
-                status = ERROR;
-                break;
-            }
-        } else {
-            //skip handle / output types
-        }
-    }
-
-    char *invokeStr = json_dumps(invoke, JSON_DECODE_ANY);
-    json_decref(invoke);
-
-    if (status == OK) {
-        *out = invokeStr;
-    }
-
-    return status;
+	int status = OK;
+
+
+	LOG_DEBUG("Calling remote function '%s'\n", id);
+	json_t *invoke = json_object();
+	json_object_set_new(invoke, "m", json_string(id));
+
+	json_t *arguments = json_array();
+	json_object_set_new(invoke, "a", arguments);
+
+	int i;
+	int nrOfArgs = dynFunction_nrOfArguments(func);
+	for (i = 0; i < nrOfArgs; i +=1) {
+		dyn_type *type = dynFunction_argumentTypeForIndex(func, i);
+		enum dyn_function_argument_meta  meta = dynFunction_argumentMetaForIndex(func, i);
+		if (meta == DYN_FUNCTION_ARGUMENT_META__STD) {
+			json_t *val = NULL;
+
+			int rc = jsonSerializer_serializeJson(type, args[i], &val);
+			if (rc == 0) {
+				json_array_append_new(arguments, val);
+			} else {
+				status = ERROR;
+				break;
+			}
+		} else {
+			//skip handle / output types
+		}
+	}
+
+	char *invokeStr = json_dumps(invoke, JSON_DECODE_ANY);
+	json_decref(invoke);
+
+	if (status == OK) {
+		*out = invokeStr;
+	}
+
+	return status;
 }
 
 int jsonRpc_handleReply(dyn_function_type *func, const char *reply, void *args[]) {
-    int status = OK;
-
-    json_error_t error;
-    json_t *replyJson = json_loads(reply, JSON_DECODE_ANY, &error);
-    if (replyJson == NULL) {
-        status = ERROR;
-        LOG_ERROR("Error parsing json '%s', got error '%s'", reply, error.text);
-    }
-
-    json_t *result = NULL;
-    if (status == OK) {
-        result = json_object_get(replyJson, "r"); //TODO check
-        if (result == NULL) {
-            status = ERROR;
-            LOG_ERROR("Cannot find r entry in json reply '%s'", reply);
-        }
-    }
-
-    if (status == OK) {
-        int nrOfArgs = dynFunction_nrOfArguments(func);
-        int i;
-        for (i = 0; i < nrOfArgs; i += 1) {
-            dyn_type *argType = dynFunction_argumentTypeForIndex(func, i);
-            enum dyn_function_argument_meta meta = dynFunction_argumentMetaForIndex(func, i);
-            if (meta == DYN_FUNCTION_ARGUMENT_META__PRE_ALLOCATED_OUTPUT) {
-                void *tmp = NULL;
-                void **out = (void **) args[i];
-
-                size_t size = 0;
-
-                if (dynType_descriptorType(argType) == 't') {
-                    status = jsonSerializer_deserializeJson(argType, result, &tmp);
-                    size = strnlen(((char *) *(char**) tmp), 1024 * 1024);
-                    memcpy(*out, *(void**) tmp, size);
-                } else {
-                    dynType_typedPointer_getTypedType(argType, &argType);
-                    status = jsonSerializer_deserializeJson(argType, result, &tmp);
-                    size = dynType_size(argType);
-                    memcpy(*out, tmp, size);
-                }
-
-                dynType_free(argType, tmp);
-            } else if (meta == DYN_FUNCTION_ARGUMENT_META__OUTPUT) {
-                dyn_type *subType = NULL;
-
-                dynType_typedPointer_getTypedType(argType, &subType);
-
-                if (dynType_descriptorType(subType) == 't') {
-                    void ***out = (void ***) args[i];
-                    status = jsonSerializer_deserializeJson(subType, result, *out);
-                } else {
-                    dyn_type *subSubType = NULL;
-                    dynType_typedPointer_getTypedType(subType, &subSubType);
-                    void ***out = (void ***) args[i];
-                    status = jsonSerializer_deserializeJson(subSubType, result, *out);
-                }
-            } else {
-                //skip
-            }
-        }
-    }
-
-    json_decref(replyJson);
-
-    return status;
+	int status = OK;
+
+	json_error_t error;
+	json_t *replyJson = json_loads(reply, JSON_DECODE_ANY, &error);
+	if (replyJson == NULL) {
+		status = ERROR;
+		LOG_ERROR("Error parsing json '%s', got error '%s'", reply, error.text);
+	}
+
+	json_t *result = NULL;
+	if (status == OK) {
+		result = json_object_get(replyJson, "r"); //TODO check
+		if (result == NULL) {
+			status = ERROR;
+			LOG_ERROR("Cannot find r entry in json reply '%s'", reply);
+		}
+	}
+
+	if (status == OK) {
+		int nrOfArgs = dynFunction_nrOfArguments(func);
+		int i;
+		for (i = 0; i < nrOfArgs; i += 1) {
+			dyn_type *argType = dynFunction_argumentTypeForIndex(func, i);
+			enum dyn_function_argument_meta meta = dynFunction_argumentMetaForIndex(func, i);
+			if (meta == DYN_FUNCTION_ARGUMENT_META__PRE_ALLOCATED_OUTPUT) {
+				void *tmp = NULL;
+				void **out = (void **) args[i];
+
+				size_t size = 0;
+
+				if (dynType_descriptorType(argType) == 't') {
+					status = jsonSerializer_deserializeJson(argType, result, &tmp);
+					if(tmp!=NULL){
+						size = strnlen(((char *) *(char**) tmp), 1024 * 1024);
+						memcpy(*out, *(void**) tmp, size);
+					}
+				} else {
+					dynType_typedPointer_getTypedType(argType, &argType);
+					status = jsonSerializer_deserializeJson(argType, result, &tmp);
+					if(tmp!=NULL){
+						size = dynType_size(argType);
+						memcpy(*out, tmp, size);
+					}
+				}
+
+				dynType_free(argType, tmp);
+			} else if (meta == DYN_FUNCTION_ARGUMENT_META__OUTPUT) {
+				dyn_type *subType = NULL;
+
+				dynType_typedPointer_getTypedType(argType, &subType);
+
+				if (dynType_descriptorType(subType) == 't') {
+					void ***out = (void ***) args[i];
+					status = jsonSerializer_deserializeJson(subType, result, *out);
+				} else {
+					dyn_type *subSubType = NULL;
+					dynType_typedPointer_getTypedType(subType, &subSubType);
+					void ***out = (void ***) args[i];
+					status = jsonSerializer_deserializeJson(subSubType, result, *out);
+				}
+			} else {
+				//skip
+			}
+		}
+	}
+
+	json_decref(replyJson);
+
+	return status;
 }

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/dfi/private/src/json_serializer.c
----------------------------------------------------------------------
diff --git a/dfi/private/src/json_serializer.c b/dfi/private/src/json_serializer.c
index 85ba782..0c06998 100644
--- a/dfi/private/src/json_serializer.c
+++ b/dfi/private/src/json_serializer.c
@@ -448,8 +448,14 @@ static int jsonSerializer_writeComplex(dyn_type *type, void *input, json_t **out
             json_t *subVal = NULL;
             dyn_type *subType = NULL;
             index = dynType_complex_indexForName(type, entry->name);
-            status = dynType_complex_valLocAt(type, index, input, &subLoc);
-            if (status == OK ) {
+            if (index < 0) {
+		LOG_ERROR("Cannot find index for member '%s'", entry->name);
+                status = ERROR;
+            }
+            if(status == OK){
+		status = dynType_complex_valLocAt(type, index, input, &subLoc);
+            }
+            if (status == OK) {
                 status = dynType_complex_dynTypeAt(type, index, &subType);
             }
             if (status == OK) {

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/dfi/private/test/avro_descriptor_translator_tests.cpp
----------------------------------------------------------------------
diff --git a/dfi/private/test/avro_descriptor_translator_tests.cpp b/dfi/private/test/avro_descriptor_translator_tests.cpp
index c29932e..5bab518 100644
--- a/dfi/private/test/avro_descriptor_translator_tests.cpp
+++ b/dfi/private/test/avro_descriptor_translator_tests.cpp
@@ -40,6 +40,7 @@ extern "C" {
         va_start(ap, msg);
         vfprintf(stderr, msg, ap);
         fprintf(stderr, "\n");
+        va_end(ap);
     }
 
 

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/dfi/private/test/dyn_closure_tests.cpp
----------------------------------------------------------------------
diff --git a/dfi/private/test/dyn_closure_tests.cpp b/dfi/private/test/dyn_closure_tests.cpp
index ce70f93..5f13de4 100644
--- a/dfi/private/test/dyn_closure_tests.cpp
+++ b/dfi/private/test/dyn_closure_tests.cpp
@@ -39,6 +39,7 @@ static void stdLog(void *handle, int level, const char *file, int line, const ch
     va_start(ap, msg);
     vfprintf(stderr, msg, ap);
     fprintf(stderr, "\n");
+    va_end(ap);
 }
 
 #define EXAMPLE1_DESCRIPTOR "example(III)I"

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/dfi/private/test/dyn_function_tests.cpp
----------------------------------------------------------------------
diff --git a/dfi/private/test/dyn_function_tests.cpp b/dfi/private/test/dyn_function_tests.cpp
index 1b65be8..34d7116 100644
--- a/dfi/private/test/dyn_function_tests.cpp
+++ b/dfi/private/test/dyn_function_tests.cpp
@@ -37,6 +37,7 @@ extern "C" {
         va_start(ap, msg);
         vfprintf(stderr, msg, ap);
         fprintf(stderr, "\n");
+        va_end(ap);
     }
 
     #define EXAMPLE1_DESCRIPTOR "example(III)I"

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/dfi/private/test/dyn_message_tests.cpp
----------------------------------------------------------------------
diff --git a/dfi/private/test/dyn_message_tests.cpp b/dfi/private/test/dyn_message_tests.cpp
index 7aafcc3..18c5505 100644
--- a/dfi/private/test/dyn_message_tests.cpp
+++ b/dfi/private/test/dyn_message_tests.cpp
@@ -43,6 +43,7 @@ static void stdLog(void *handle, int level, const char *file, int line, const ch
 	va_start(ap, msg);
 	vfprintf(stderr, msg, ap);
 	fprintf(stderr, "\n");
+	va_end(ap);
 }
 
 static void checkMessageVersion(dyn_message_type* dynMsg, const char* v){

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/dfi/private/test/dyn_type_tests.cpp
----------------------------------------------------------------------
diff --git a/dfi/private/test/dyn_type_tests.cpp b/dfi/private/test/dyn_type_tests.cpp
index db95da4..e65c2b9 100644
--- a/dfi/private/test/dyn_type_tests.cpp
+++ b/dfi/private/test/dyn_type_tests.cpp
@@ -32,6 +32,7 @@ extern "C" {
 	    va_start(ap, msg);
 	    vfprintf(stderr, msg, ap);
 	    fprintf(stderr, "\n");
+	    va_end(ap);
 	}
 
     static void runTest(const char *descriptorStr, const char *exName) {

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/dfi/private/test/json_rpc_tests.cpp
----------------------------------------------------------------------
diff --git a/dfi/private/test/json_rpc_tests.cpp b/dfi/private/test/json_rpc_tests.cpp
index 8b4044d..10097ec 100644
--- a/dfi/private/test/json_rpc_tests.cpp
+++ b/dfi/private/test/json_rpc_tests.cpp
@@ -42,6 +42,7 @@ static void stdLog(void *handle, int level, const char *file, int line, const ch
     va_start(ap, msg);
     vfprintf(stderr, msg, ap);
     fprintf(stderr, "\n");
+    va_end(ap);
 }
 
 
@@ -138,7 +139,9 @@ static void stdLog(void *handle, int level, const char *file, int line, const ch
         }
 
         struct tst_StatsResult *result = (struct tst_StatsResult *) calloc(1, sizeof(*result));
-        result->average = total / count;
+        if(count>0){
+		result->average = total / count;
+        }
         result->min = min;
         result->max = max;
         double *buf = (double *)calloc(input.len, sizeof(double));
@@ -367,7 +370,9 @@ static void stdLog(void *handle, int level, const char *file, int line, const ch
         args[0] = NULL;
         args[1] = &out;
 
-        rc = jsonRpc_handleReply(func, reply, args);
+        if(func!=NULL){ // Check needed just to satisfy Coverity
+		rc = jsonRpc_handleReply(func, reply, args);
+        }
 
         STRCMP_EQUAL("this is a test string", result);
 

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/dfi/private/test/json_serializer_tests.cpp
----------------------------------------------------------------------
diff --git a/dfi/private/test/json_serializer_tests.cpp b/dfi/private/test/json_serializer_tests.cpp
index f4e9f2d..bd65b23 100644
--- a/dfi/private/test/json_serializer_tests.cpp
+++ b/dfi/private/test/json_serializer_tests.cpp
@@ -39,6 +39,7 @@ static void stdLog(void *handle, int level, const char *file, int line, const ch
 	va_start(ap, msg);
 	vfprintf(stderr, msg, ap);
 	fprintf(stderr, "\n");
+	va_end(ap);
 }
 
 /*********** example 1 ************************/

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/examples/embedding/private/src/main.c
----------------------------------------------------------------------
diff --git a/examples/embedding/private/src/main.c b/examples/embedding/private/src/main.c
index c04099e..f785121 100644
--- a/examples/embedding/private/src/main.c
+++ b/examples/embedding/private/src/main.c
@@ -35,59 +35,64 @@ struct foo {
 };
 
 struct fooSrv {
-    struct foo *handle;
-    celix_status_t (*foo)(struct foo *handle);
+	struct foo *handle;
+	celix_status_t (*foo)(struct foo *handle);
 };
 
 celix_status_t embedded_foo();
 
 int main(void) {
 
-    framework_pt framework = NULL;
+	framework_pt framework = NULL;
 
-    properties_pt config = properties_create();
-    int rc = celixLauncher_launchWithProperties(config, &framework);
+	properties_pt config = properties_create();
+	int rc = celixLauncher_launchWithProperties(config, &framework);
 
-    if (rc == 0) {
-        bundle_pt fwBundle = NULL;
-        framework_getFrameworkBundle(framework, &fwBundle);
-        bundle_start(fwBundle);
+	if (rc == 0) {
+		bundle_pt fwBundle = NULL;
+		if(framework_getFrameworkBundle(framework, &fwBundle) == CELIX_SUCCESS){
 
-        bundle_context_pt context = NULL;
-        bundle_getContext(fwBundle, &context);
+			if(bundle_start(fwBundle) == CELIX_SUCCESS){
 
-        struct foo *f = calloc(1, sizeof(*f));
-        struct fooSrv *fs = calloc(1, sizeof(*fs));
+				bundle_context_pt context = NULL;
+				bundle_getContext(fwBundle, &context);
 
-        fs->handle = f;
-        fs->foo = embedded_foo;
+				struct foo *f = calloc(1, sizeof(*f));
+				struct fooSrv *fs = calloc(1, sizeof(*fs));
 
-        service_registration_pt reg = NULL;
-        bundleContext_registerService(context, "foo", fs, NULL, &reg);
+				fs->handle = f;
+				fs->foo = embedded_foo;
 
-        service_reference_pt ref = NULL;
-        bundleContext_getServiceReference(context, "foo", &ref);
+				service_registration_pt reg = NULL;
 
-        void *fs2 = NULL;
-        bundleContext_getService(context, ref, &fs2);
+				if(bundleContext_registerService(context, "foo", fs, NULL, &reg) == CELIX_SUCCESS){
 
-        ((struct fooSrv*) fs2)->foo(((struct fooSrv*) fs2)->handle);
+					service_reference_pt ref = NULL;
+					if(bundleContext_getServiceReference(context, "foo", &ref) == CELIX_SUCCESS){
 
-        bundleContext_ungetServiceReference(context, ref);
-        serviceRegistration_unregister(reg);
+						void *fs2 = NULL;
+						bundleContext_getService(context, ref, &fs2);
 
-        free(f);
-        free(fs);
+						((struct fooSrv*) fs2)->foo(((struct fooSrv*) fs2)->handle);
 
-        celixLauncher_destroy(framework);
-    }
+						bundleContext_ungetServiceReference(context, ref);
+						serviceRegistration_unregister(reg);
+					}
+				}
 
-    return rc;
+				free(f);
+				free(fs);
+			}
+		}
+		celixLauncher_destroy(framework);
+	}
+
+	return rc;
 
 }
 
 celix_status_t embedded_foo() {
-    printf("foo\n");
-    return CELIX_SUCCESS;
+	printf("foo\n");
+	return CELIX_SUCCESS;
 }
 

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/examples/locking/benchmark/private/src/benchmark_runner_activator.c
----------------------------------------------------------------------
diff --git a/examples/locking/benchmark/private/src/benchmark_runner_activator.c b/examples/locking/benchmark/private/src/benchmark_runner_activator.c
index 99af502..c91d68f 100644
--- a/examples/locking/benchmark/private/src/benchmark_runner_activator.c
+++ b/examples/locking/benchmark/private/src/benchmark_runner_activator.c
@@ -209,16 +209,17 @@ static void benchmarkRunner_runBenchmark(struct activator *activator, FILE *out)
 	updateFrequency = 1000;
 	nrOfUpdateThreads = 100;
 
+	benchmarkServ = activator->benchmark;
+	name = benchmarkServ->name(benchmarkServ->handler);
+	sampleFactor = benchmarkServ->getSampleFactor(benchmarkServ->handler);
+
 	pthread_mutex_lock(&activator->mutex);
 	if (activator->freqService != NULL) {
 		activator->freqService->setFrequency(activator->freqService->handle, updateFrequency);
 		activator->freqService->setNrOfThreads(activator->freqService->handle, nrOfUpdateThreads);
+		activator->freqService->setBenchmarkName(activator->freqService->handle, name);
 	}
 
-	benchmarkServ = activator->benchmark;
-	name = benchmarkServ->name(benchmarkServ->handler);
-	sampleFactor = benchmarkServ->getSampleFactor(benchmarkServ->handler);
-	activator->freqService->setBenchmarkName(activator->freqService->handle, name);
 	usleep(1000);
     benchmarkRunner_printHeader(name, nrOfSamples * (int)sampleFactor, out);
 	for (k = 0 ; k < nrOfThreadRuns ; k +=1) {

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/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 07c9c5c..02470b3 100644
--- a/examples/locking/mutex_benchmark/private/src/mutex_benchmark.c
+++ b/examples/locking/mutex_benchmark/private/src/mutex_benchmark.c
@@ -81,8 +81,10 @@ benchmark_result_t benchmark_run(benchmark_pt benchmark, int nrOfThreads, int nr
 	}
 
     unsigned int actualSamples = (nrOfSamples * nrOfThreads) - result.skips;
+    if(elapsedTime != 0){
 	result.averageCallTimeInNanoseconds = actualSamples == 0 ? NAN : ((double)elapsedTime * 1000) / (nrOfSamples * nrOfThreads);
 	result.callFrequencyInMhz = ((double)(actualSamples * nrOfThreads) / elapsedTime);
+    }
 	result.nrOfThreads = nrOfThreads;
 	result.nrOfsamples = actualSamples;
     result.requestedNrOfSamples = (nrOfSamples * nrOfThreads);

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/examples/mongoose/private/src/mongoose.c
----------------------------------------------------------------------
diff --git a/examples/mongoose/private/src/mongoose.c b/examples/mongoose/private/src/mongoose.c
index b1f0a4b..d133ab3 100644
--- a/examples/mongoose/private/src/mongoose.c
+++ b/examples/mongoose/private/src/mongoose.c
@@ -1930,7 +1930,7 @@ static void MD5Final(unsigned char digest[16], MD5_CTX *ctx) {
   MD5Transform(ctx->buf, (uint32_t *) ctx->in);
   byteReverse((unsigned char *) ctx->buf, 4);
   memcpy(digest, ctx->buf, 16);
-  memset((char *) ctx, 0, sizeof(ctx));
+  memset((char *) ctx, 0, sizeof(*ctx));
 }
 #endif // !HAVE_MD5
 
@@ -2406,12 +2406,14 @@ static void handle_directory_request(struct mg_connection *conn,
       conn->request_info.uri, "..", "Parent directory", "-", "-");
 
   // Sort and print directory entries
-  qsort(entries, num_entries, sizeof(entries[0]), compare_dir_entries);
-  for (i = 0; i < num_entries; i++) {
-    print_dir_entry(&entries[i]);
-    free(entries[i].file_name);
+  if(entries!=NULL){
+	  qsort(entries, num_entries, sizeof(entries[0]), compare_dir_entries);
+	  for (i = 0; i < num_entries; i++) {
+		  print_dir_entry(&entries[i]);
+		  free(entries[i].file_name);
+	  }
+	  free(entries);
   }
-  free(entries);
 
   conn->num_bytes_sent += mg_printf(conn, "%s", "</table></body></html>");
   conn->request_info.status_code = 200;
@@ -3293,7 +3295,9 @@ static int set_ports_option(struct mg_context *ctx) {
 #endif // !_WIN32
                bind(sock, &so.lsa.u.sa, so.lsa.len) != 0 ||
                listen(sock, 20) != 0) {
-      closesocket(sock);
+      if(sock != INVALID_SOCKET ){
+	  closesocket(sock);
+      }
       cry(fc(ctx), "%s: cannot bind to %.*s: %s", __func__,
           vec.len, vec.ptr, strerror(ERRNO));
       success = 0;

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/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 adbf027..7903ad1 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
@@ -77,7 +77,7 @@ celix_status_t bundleActivator_start(void * userData, bundle_context_pt context)
     celix_status_t status = CELIX_SUCCESS;
     struct listenerActivator *activator = userData;
 
-    service_listener_pt listener = calloc(1, sizeof(struct listenerActivator));
+    service_listener_pt listener = calloc(1, sizeof(*listener));
     if (!listener) {
         status = CELIX_ENOMEM;
     } else {

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/examples/osgi-in-action/chapter04-correct-lookup/private/src/activator.c
----------------------------------------------------------------------
diff --git a/examples/osgi-in-action/chapter04-correct-lookup/private/src/activator.c b/examples/osgi-in-action/chapter04-correct-lookup/private/src/activator.c
index 2ada02f..19cf093 100644
--- a/examples/osgi-in-action/chapter04-correct-lookup/private/src/activator.c
+++ b/examples/osgi-in-action/chapter04-correct-lookup/private/src/activator.c
@@ -59,7 +59,7 @@ celix_status_t bundleActivator_create(bundle_context_pt context, void **userData
 
     *userData = calloc(1, sizeof(struct threadData));
 
-    if (!userData) {
+    if ((*userData)==NULL) {
         status = CELIX_ENOMEM;
     } else {
         ((thread_data_pt) (*userData))->service = "chapter04-correct-lookup";

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/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 81e635d..38dd0ae 100644
--- a/framework/private/mock/celix_log_mock.c
+++ b/framework/private/mock/celix_log_mock.c
@@ -69,6 +69,8 @@ static void test_logger_log(framework_logger_pt logger, framework_log_level_t le
     vsprintf(msg, fmsg, listPointer);
 
     test_logger_print(level, func, file, line, msg);
+
+    va_end(listPointer);
 }
 
 static void test_logger_print(framework_log_level_t level, const char *func, const char *file, int line, char *msg) {

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/framework/private/src/bundle_archive.c
----------------------------------------------------------------------
diff --git a/framework/private/src/bundle_archive.c b/framework/private/src/bundle_archive.c
index 74c5dd4..4c838a6 100644
--- a/framework/private/src/bundle_archive.c
+++ b/framework/private/src/bundle_archive.c
@@ -211,8 +211,8 @@ celix_status_t bundleArchive_recreate(char * archiveRoot, bundle_archive_pt *bun
 				while (rc == 0 && result != NULL) {
 					char subdir[512];
 					snprintf(subdir, 512, "%s/%s", archiveRoot, dent.d_name);
-					stat(subdir, &st);
-					if (S_ISDIR(st.st_mode) && (strncmp(dent.d_name, "version", 7) == 0)) {
+					int rv = stat(subdir, &st);
+					if (rv == 0 && S_ISDIR(st.st_mode) && (strncmp(dent.d_name, "version", 7) == 0)) {
 						sscanf(dent.d_name, "version%*d.%ld", &idx);
 						if (idx > highestId) {
 							highestId = idx;

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/framework/private/src/bundle_cache.c
----------------------------------------------------------------------
diff --git a/framework/private/src/bundle_cache.c b/framework/private/src/bundle_cache.c
index 5e5d5dd..6641d5c 100644
--- a/framework/private/src/bundle_cache.c
+++ b/framework/private/src/bundle_cache.c
@@ -86,8 +86,9 @@ celix_status_t bundleCache_getArchives(bundle_cache_pt cache, array_list_pt *arc
 	dir = opendir(cache->cacheDir);
 
 	if (dir == NULL && errno == ENOENT) {
-		mkdir(cache->cacheDir, S_IRWXU);
-		dir = opendir(cache->cacheDir);
+		if(mkdir(cache->cacheDir, S_IRWXU) == 0 ){
+			dir = opendir(cache->cacheDir);
+		}
 	}
 
 	if (dir != NULL) {
@@ -119,7 +120,7 @@ celix_status_t bundleCache_getArchives(bundle_cache_pt cache, array_list_pt *arc
 				}
 			}
 
-			readdir_r(dir, &dp, &result);
+			rc = readdir_r(dir, &dp, &result);
 		}
 
 		if (rc != 0) {
@@ -195,7 +196,7 @@ static celix_status_t bundleCache_deleteTree(bundle_cache_pt cache, char * direc
 					}
 				}
 			}
-			readdir_r(dir, &dp, &result);
+			rc = readdir_r(dir, &dp, &result);
 		}
 
 		if (closedir(dir) != 0) {

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/framework/private/src/celix_launcher.c
----------------------------------------------------------------------
diff --git a/framework/private/src/celix_launcher.c b/framework/private/src/celix_launcher.c
index 144c8dc..7221cc3 100644
--- a/framework/private/src/celix_launcher.c
+++ b/framework/private/src/celix_launcher.c
@@ -40,127 +40,131 @@
 #include "linked_list_iterator.h"
 
 int celixLauncher_launch(const char *configFile, framework_pt *framework) {
-    int status = 0;
-    FILE *config = fopen(configFile, "r");
-    if (config != NULL) {
-        status = celixLauncher_launchWithStream(config, framework);
-    } else {
-        fprintf(stderr, "Error: invalid or non-existing configuration file: '%s'.", configFile);
-        perror("");
-        status = 1;
-    }
-    return status;
+	int status = 0;
+	FILE *config = fopen(configFile, "r");
+	if (config != NULL) {
+		status = celixLauncher_launchWithStream(config, framework);
+	} else {
+		fprintf(stderr, "Error: invalid or non-existing configuration file: '%s'.", configFile);
+		perror("");
+		status = 1;
+	}
+	return status;
 }
 
 int celixLauncher_launchWithStream(FILE *stream, framework_pt *framework) {
-    int status = 0;
-
-    properties_pt config = properties_loadWithStream(stream);
-    fclose(stream);
-    // Make sure we've read it and that nothing went wrong with the file access...
-    if (config == NULL) {
-        fprintf(stderr, "Error: invalid configuration file");
-        perror(NULL);
-        status = 1;
-    }
-    else {
-        status = celixLauncher_launchWithProperties(config, framework);
-    }
-
-    return status;
+	int status = 0;
+
+	properties_pt config = properties_loadWithStream(stream);
+	fclose(stream);
+	// Make sure we've read it and that nothing went wrong with the file access...
+	if (config == NULL) {
+		fprintf(stderr, "Error: invalid configuration file");
+		perror(NULL);
+		status = 1;
+	}
+	else {
+		status = celixLauncher_launchWithProperties(config, framework);
+	}
+
+	return status;
 }
 
 
 int celixLauncher_launchWithProperties(properties_pt config, framework_pt *framework) {
-    celix_status_t status;
+	celix_status_t status;
 #ifndef CELIX_NO_CURLINIT
-    // Before doing anything else, let's setup Curl
-    curl_global_init(CURL_GLOBAL_NOTHING);
+	// Before doing anything else, let's setup Curl
+	curl_global_init(CURL_GLOBAL_NOTHING);
 #endif
 
-    char *autoStart = properties_get(config, "cosgi.auto.start.1");
-
-    status = framework_create(framework, config);
-    bundle_pt fwBundle = NULL;
-    if (status == CELIX_SUCCESS) {
-        status = fw_init(*framework);
-        if (status == CELIX_SUCCESS) {
-            // Start the system bundle
-            framework_getFrameworkBundle(*framework, &fwBundle);
-            bundle_start(fwBundle);
-
-            char delims[] = " ";
-            char *result = NULL;
-            char *save_ptr = NULL;
-            linked_list_pt bundles;
-            array_list_pt installed = NULL;
-            bundle_context_pt context = NULL;
-            linked_list_iterator_pt iter = NULL;
-            unsigned int i;
-
-            linkedList_create(&bundles);
-            result = strtok_r(autoStart, delims, &save_ptr);
-            while (result != NULL) {
-                char *location = strdup(result);
-                linkedList_addElement(bundles, location);
-                result = strtok_r(NULL, delims, &save_ptr);
-            }
-            // First install all bundles
-            // Afterwards start them
-            arrayList_create(&installed);
-            bundle_getContext(fwBundle, &context);
-            iter = linkedListIterator_create(bundles, 0);
-            while (linkedListIterator_hasNext(iter)) {
-                bundle_pt current = NULL;
-                char *location = (char *) linkedListIterator_next(iter);
-                if (bundleContext_installBundle(context, location, &current) == CELIX_SUCCESS) {
-                    // Only add bundle if it is installed correctly
-                    arrayList_add(installed, current);
-                } else {
-                    printf("Could not install bundle from %s\n", location);
-                }
-                linkedListIterator_remove(iter);
-                free(location);
-            }
-            linkedListIterator_destroy(iter);
-            linkedList_destroy(bundles);
-
-            for (i = 0; i < arrayList_size(installed); i++) {
-                bundle_pt installedBundle = (bundle_pt) arrayList_get(installed, i);
-                bundle_startWithOptions(installedBundle, 0);
-            }
-
-            arrayList_destroy(installed);
-        }
-    }
-
-    if (status != CELIX_SUCCESS) {
-        printf("Problem creating framework\n");
-    }
-
-    printf("Launcher: Framework Started\n");
-
-
-    return status;
+	char *autoStart = properties_get(config, "cosgi.auto.start.1");
+
+	status = framework_create(framework, config);
+	bundle_pt fwBundle = NULL;
+	if (status == CELIX_SUCCESS) {
+		status = fw_init(*framework);
+		if (status == CELIX_SUCCESS) {
+			// Start the system bundle
+			status = framework_getFrameworkBundle(*framework, &fwBundle);
+
+			if(status == CELIX_SUCCESS){
+				bundle_start(fwBundle);
+
+				char delims[] = " ";
+				char *result = NULL;
+				char *save_ptr = NULL;
+				linked_list_pt bundles;
+				array_list_pt installed = NULL;
+				bundle_context_pt context = NULL;
+				linked_list_iterator_pt iter = NULL;
+				unsigned int i;
+
+				linkedList_create(&bundles);
+				result = strtok_r(autoStart, delims, &save_ptr);
+				while (result != NULL) {
+					char *location = strdup(result);
+					linkedList_addElement(bundles, location);
+					result = strtok_r(NULL, delims, &save_ptr);
+				}
+				// First install all bundles
+				// Afterwards start them
+				arrayList_create(&installed);
+				bundle_getContext(fwBundle, &context);
+				iter = linkedListIterator_create(bundles, 0);
+				while (linkedListIterator_hasNext(iter)) {
+					bundle_pt current = NULL;
+					char *location = (char *) linkedListIterator_next(iter);
+					if (bundleContext_installBundle(context, location, &current) == CELIX_SUCCESS) {
+						// Only add bundle if it is installed correctly
+						arrayList_add(installed, current);
+					} else {
+						printf("Could not install bundle from %s\n", location);
+					}
+					linkedListIterator_remove(iter);
+					free(location);
+				}
+				linkedListIterator_destroy(iter);
+				linkedList_destroy(bundles);
+
+				for (i = 0; i < arrayList_size(installed); i++) {
+					bundle_pt installedBundle = (bundle_pt) arrayList_get(installed, i);
+					bundle_startWithOptions(installedBundle, 0);
+				}
+
+				arrayList_destroy(installed);
+			}
+		}
+	}
+
+	if (status != CELIX_SUCCESS) {
+		printf("Problem creating framework\n");
+	}
+
+	printf("Launcher: Framework Started\n");
+
+
+	return status;
 }
 
 void celixLauncher_waitForShutdown(framework_pt framework) {
-    framework_waitForStop(framework);
+	framework_waitForStop(framework);
 }
 
 void celixLauncher_destroy(framework_pt framework) {
-    framework_destroy(framework);
+	framework_destroy(framework);
 
-    #ifndef CELIX_NO_CURLINIT
-        // Cleanup Curl
-        curl_global_cleanup();
-    #endif
+#ifndef CELIX_NO_CURLINIT
+	// Cleanup Curl
+	curl_global_cleanup();
+#endif
 
-    printf("Launcher: Exit\n");
+	printf("Launcher: Exit\n");
 }
 
 void celixLauncher_stop(framework_pt framework) {
-    bundle_pt fwBundle = NULL;
-    framework_getFrameworkBundle(framework, &fwBundle);
-    bundle_stop(fwBundle);
+	bundle_pt fwBundle = NULL;
+	if( framework_getFrameworkBundle(framework, &fwBundle) == CELIX_SUCCESS){
+		bundle_stop(fwBundle);
+	}
 }

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/framework/private/src/celix_log.c
----------------------------------------------------------------------
diff --git a/framework/private/src/celix_log.c b/framework/private/src/celix_log.c
index d2e222e..7c7e14f 100644
--- a/framework/private/src/celix_log.c
+++ b/framework/private/src/celix_log.c
@@ -38,6 +38,8 @@ void framework_log(framework_logger_pt logger, framework_log_level_t level, cons
     if (logger != NULL && logger->logFunction != NULL) {
         logger->logFunction(level, func, file, line, msg);
     }
+
+    va_end(listPointer);
 }
 
 void framework_logCode(framework_logger_pt logger, framework_log_level_t level, const char *func, const char *file, int line, celix_status_t code, char *fmsg, ...) {
@@ -49,6 +51,8 @@ void framework_logCode(framework_logger_pt logger, framework_log_level_t level,
     vsprintf(msg, fmsg, listPointer);
 
     framework_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) {

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/framework/private/src/framework.c
----------------------------------------------------------------------
diff --git a/framework/private/src/framework.c b/framework/private/src/framework.c
index 2c99f57..3df30c9 100644
--- a/framework/private/src/framework.c
+++ b/framework/private/src/framework.c
@@ -272,10 +272,12 @@ celix_status_t framework_destroy(framework_pt framework) {
                     array_list_pt handles = NULL;
                     status = CELIX_DO_IF(status, bundleArchive_getCurrentRevision(archive, &revision));
                     status = CELIX_DO_IF(status, bundleRevision_getHandles(revision, &handles));
-                    for (int i = arrayList_size(handles) - 1; i >= 0; i--) {
-                        void *handle = arrayList_get(handles, i);
-                        fw_closeLibrary(handle);
-                    }
+                    if(handles != NULL){
+			for (int i = arrayList_size(handles) - 1; i >= 0; i--) {
+			    void *handle = arrayList_get(handles, i);
+			    fw_closeLibrary(handle);
+			}
+						  }
                 }
 
                 bundleArchive_destroy(archive);
@@ -518,7 +520,6 @@ celix_status_t fw_getProperty(framework_pt framework, const char *name, char **v
 
 	if (framework == NULL || name == NULL || *value != NULL) {
 		status = CELIX_ILLEGAL_ARGUMENT;
-		fw_logCode(framework->logger, OSGI_FRAMEWORK_LOG_ERROR, status, "Missing required arguments");
 	} else {
 		if (framework->configurationMap != NULL) {
 			*value = properties_get(framework->configurationMap, (char *) name);
@@ -792,10 +793,12 @@ celix_status_t framework_updateBundle(framework_pt framework, bundle_pt bundle,
 	array_list_pt handles = NULL;
 	status = CELIX_DO_IF(status, bundleArchive_getCurrentRevision(archive, &revision));
     status = CELIX_DO_IF(status, bundleRevision_getHandles(revision, &handles));
-    for (int i = arrayList_size(handles) - 1; i >= 0; i--) {
-        void *handle = arrayList_get(handles, i);
-        fw_closeLibrary(handle);
-    }
+    if(handles != NULL){
+	for (int i = arrayList_size(handles) - 1; i >= 0; i--) {
+	    void *handle = arrayList_get(handles, i);
+	    fw_closeLibrary(handle);
+	}
+	 }
 
 
 	status = CELIX_DO_IF(status, fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_UNRESOLVED, bundle));
@@ -994,9 +997,11 @@ celix_status_t fw_uninstallBundle(framework_pt framework, bundle_pt bundle) {
 	array_list_pt handles = NULL;
 	status = CELIX_DO_IF(status, bundleArchive_getCurrentRevision(archive, &revision));
 	status = CELIX_DO_IF(status, bundleRevision_getHandles(revision, &handles));
-	for (int i = arrayList_size(handles) - 1; i >= 0; i--) {
-		void *handle = arrayList_get(handles, i);
-		fw_closeLibrary(handle);
+	if(handles != NULL){
+		for (int i = arrayList_size(handles) - 1; i >= 0; i--) {
+			void *handle = arrayList_get(handles, i);
+			fw_closeLibrary(handle);
+		}
 	}
 
     status = CELIX_DO_IF(status, fw_fireBundleEvent(framework, OSGI_FRAMEWORK_BUNDLE_EVENT_UNRESOLVED, bundle));
@@ -1168,26 +1173,28 @@ celix_status_t fw_refreshHelper_restart(struct fw_refreshHelper * refreshHelper)
 celix_status_t fw_getDependentBundles(framework_pt framework, bundle_pt exporter, array_list_pt *list) {
     celix_status_t status = CELIX_SUCCESS;
 
-    if (*list == NULL && exporter != NULL && framework != NULL) {
-		array_list_pt modules;
-		unsigned int modIdx = 0;
-        arrayList_create(list);
-
-        modules = bundle_getModules(exporter);
-        for (modIdx = 0; modIdx < arrayList_size(modules); modIdx++) {
-            module_pt module = (module_pt) arrayList_get(modules, modIdx);
-            array_list_pt dependents = module_getDependents(module);
-            unsigned int depIdx = 0;
-            for (depIdx = 0; (dependents != NULL) && (depIdx < arrayList_size(dependents)); depIdx++) {
-                module_pt dependent = (module_pt) arrayList_get(dependents, depIdx);
-                arrayList_add(*list, module_getBundle(dependent));
-            }
-            arrayList_destroy(dependents);
-        }
-    } else {
-        status = CELIX_ILLEGAL_ARGUMENT;
+    if (*list != NULL || exporter == NULL || framework == NULL) {
+	return CELIX_ILLEGAL_ARGUMENT;
     }
 
+	 array_list_pt modules;
+	 unsigned int modIdx = 0;
+	 arrayList_create(list);
+
+	 modules = bundle_getModules(exporter);
+	 for (modIdx = 0; modIdx < arrayList_size(modules); modIdx++) {
+				module_pt module = (module_pt) arrayList_get(modules, modIdx);
+				array_list_pt dependents = module_getDependents(module);
+			if(dependents!=NULL){
+					unsigned int depIdx = 0;
+					for (depIdx = 0; depIdx < arrayList_size(dependents); depIdx++) {
+							  module_pt dependent = (module_pt) arrayList_get(dependents, depIdx);
+							  arrayList_add(*list, module_getBundle(dependent));
+					}
+					arrayList_destroy(dependents);
+				}
+	 }
+
     framework_logIfError(framework->logger, status, NULL, "Cannot get dependent bundles");
 
     return status;
@@ -1196,20 +1203,22 @@ celix_status_t fw_getDependentBundles(framework_pt framework, bundle_pt exporter
 celix_status_t fw_populateDependentGraph(framework_pt framework, bundle_pt exporter, hash_map_pt *map) {
     celix_status_t status = CELIX_SUCCESS;
 
-    if (exporter != NULL && framework != NULL) {
-        array_list_pt dependents = NULL;
-        if ((status = fw_getDependentBundles(framework, exporter, &dependents)) == CELIX_SUCCESS) {
-            unsigned int depIdx = 0;
-            for (depIdx = 0; (dependents != NULL) && (depIdx < arrayList_size(dependents)); depIdx++) {
-                if (!hashMap_containsKey(*map, arrayList_get(dependents, depIdx))) {
-                    hashMap_put(*map, arrayList_get(dependents, depIdx), arrayList_get(dependents, depIdx));
-                    fw_populateDependentGraph(framework, (bundle_pt) arrayList_get(dependents, depIdx), map);
-                }
-            }
-            arrayList_destroy(dependents);
-        }
-    } else {
-        status = CELIX_ILLEGAL_ARGUMENT;
+    if(framework == NULL || exporter == NULL){
+	return CELIX_ILLEGAL_ARGUMENT;
+    }
+
+    array_list_pt dependents = NULL;
+    if ((status = fw_getDependentBundles(framework, exporter, &dependents)) == CELIX_SUCCESS) {
+		  if(dependents!=NULL){
+         unsigned int depIdx = 0;
+		for (depIdx = 0; depIdx < arrayList_size(dependents); depIdx++) {
+		    if (!hashMap_containsKey(*map, arrayList_get(dependents, depIdx))) {
+		        hashMap_put(*map, arrayList_get(dependents, depIdx), arrayList_get(dependents, depIdx));
+		        fw_populateDependentGraph(framework, (bundle_pt) arrayList_get(dependents, depIdx), map);
+		    }
+		}
+		arrayList_destroy(dependents);
+		  }
     }
 
     framework_logIfError(framework->logger, status, NULL, "Cannot populate dependent graph");
@@ -1930,16 +1939,17 @@ celix_status_t framework_acquireBundleLock(framework_pt framework, bundle_pt bun
 
 		while (!lockable
 				|| (( celixThread_initalized(framework->globalLockThread) == true)
-				&& !isSelf)) {
+				&& !isSelf))
+		{
 			bundle_state_e state;
 			bundle_getState(bundle, &state);
 			if ((desiredStates & state) == 0) {
 				status = CELIX_ILLEGAL_STATE;
 				break;
-			} else
-				bundle_getLockingThread(bundle, &lockingThread);
-				if (isSelf
-					&& (celixThread_initalized(lockingThread) == true)
+			}
+
+			bundle_getLockingThread(bundle, &lockingThread);
+			if (isSelf && (celixThread_initalized(lockingThread) == true)
 					&& arrayList_contains(framework->globalLockWaitersList, &lockingThread)) {
 				framework->interrupted = true;
 //				celixThreadCondition_signal_thread_np(&framework->condition, bundle_getLockingThread(bundle));
@@ -1952,7 +1962,7 @@ celix_status_t framework_acquireBundleLock(framework_pt framework, bundle_pt bun
 			if (status != CELIX_SUCCESS) {
 				break;
 			}
-		}
+	}
 
 		if (status == CELIX_SUCCESS) {
 			bundle_state_e state;
@@ -2170,8 +2180,6 @@ celix_status_t framework_getFrameworkBundle(framework_pt framework, bundle_pt *b
 		status = CELIX_ILLEGAL_ARGUMENT;
 	}
 
-	framework_logIfError(framework->logger, status, NULL, "Failed to get framework bundle");
-
 	return status;
 }
 
@@ -2289,12 +2297,10 @@ celix_status_t fw_fireFrameworkEvent(framework_pt framework, framework_event_typ
             status = CELIX_FRAMEWORK_EXCEPTION;
         } else {
             arrayList_add(framework->requests, request);
-            if (celixThreadCondition_broadcast(&framework->dispatcher)) {
-                status = CELIX_FRAMEWORK_EXCEPTION;
-            } else {
-                if (celixThreadMutex_unlock(&framework->dispatcherLock)) {
-                    status = CELIX_FRAMEWORK_EXCEPTION;
-                }
+            celix_status_t bcast_status = celixThreadCondition_broadcast(&framework->dispatcher);
+            celix_status_t unlock_status = celixThreadMutex_unlock(&framework->dispatcherLock);
+            if (bcast_status!=0 || unlock_status!=0) {
+		status = CELIX_FRAMEWORK_EXCEPTION;
             }
         }
     }
@@ -2582,7 +2588,9 @@ static celix_status_t framework_loadLibrary(framework_pt framework, char *librar
 			status = CELIX_DO_IF(status, bundleArchive_getCurrentRevision(archive, &revision));
 			status = CELIX_DO_IF(status, bundleRevision_getHandles(revision, &handles));
 
-			arrayList_add(handles, *handle);
+			if(handles != NULL){
+				arrayList_add(handles, *handle);
+			}
 		}
     }
 

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/framework/private/src/resolver.c
----------------------------------------------------------------------
diff --git a/framework/private/src/resolver.c b/framework/private/src/resolver.c
index 416ca7c..02d371c 100644
--- a/framework/private/src/resolver.c
+++ b/framework/private/src/resolver.c
@@ -278,7 +278,9 @@ void resolver_addModule(module_pt module) {
                     }
                 }
             }
-            linkedList_addElement(list->capabilities, cap);
+            if(list != NULL){
+		linkedList_addElement(list->capabilities, cap);
+            }
         }
     }
 }
@@ -352,7 +354,9 @@ void resolver_moduleResolved(module_pt module) {
                 capability_list_pt list;
                 capability_getServiceName(cap, &serviceName);
                 list = resolver_getCapabilityList(m_unresolvedServices, serviceName);
-                linkedList_removeElement(list->capabilities, cap);
+                if(list != NULL){
+			linkedList_removeElement(list->capabilities, cap);
+                }
 
                 linkedList_addElement(capsCopy, cap);
             }
@@ -397,7 +401,9 @@ void resolver_moduleResolved(module_pt module) {
                             }
                         }
                     }
-                    linkedList_addElement(list->capabilities, cap);
+                    if(list != NULL){
+			linkedList_addElement(list->capabilities, cap);
+                    }
                 }
             }
 

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/framework/private/test/bundle_cache_test.cpp
----------------------------------------------------------------------
diff --git a/framework/private/test/bundle_cache_test.cpp b/framework/private/test/bundle_cache_test.cpp
index 1d543d0..f61186c 100644
--- a/framework/private/test/bundle_cache_test.cpp
+++ b/framework/private/test/bundle_cache_test.cpp
@@ -76,11 +76,18 @@ TEST(bundle_cache, deleteTree) {
 	char cacheFile[] = "bundle_cache_test_directory/tempXXXXXX";
 	cache->cacheDir = cacheDir;
 
-	mkdir(cacheDir, S_IRWXU);
-	mkdir(cacheDir2, S_IRWXU);
-	//mkstemp opens the file for safety, but bundlecache_delete needs to reopen the file
-	close(mkstemp(cacheFile));
+	int rv = 0;
+	rv += mkdir(cacheDir, S_IRWXU);
+	rv += mkdir(cacheDir2, S_IRWXU);
 
+	/* Check previous mkdir calls were fine*/
+	LONGS_EQUAL(rv,0);
+
+	//mkstemp opens the file for safety, but bundlecache_delete needs to reopen the file
+	int fd = mkstemp(cacheFile);
+	if(fd>=0){
+		close(fd);
+	}
 
 	LONGS_EQUAL(CELIX_SUCCESS, bundleCache_delete(cache));
 
@@ -94,9 +101,13 @@ TEST(bundle_cache, getArchive) {
 
 	char bundle0[] = "bundle_cache_test_directory/bundle0";
 	char bundle1[] = "bundle_cache_test_directory/bundle1";
-	mkdir(cacheDir, S_IRWXU);
-	mkdir(bundle0, S_IRWXU);
-	mkdir(bundle1, S_IRWXU);
+	int rv = 0;
+	rv += mkdir(cacheDir, S_IRWXU);
+	rv += mkdir(bundle0, S_IRWXU);
+	rv += mkdir(bundle1, S_IRWXU);
+
+	/* Check previous mkdir calls were fine*/
+	LONGS_EQUAL(rv,0);
 
 	bundle_archive_pt archive = (bundle_archive_pt) 0x10;
 	mock().expectOneCall("bundleArchive_recreate")

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/framework/private/test/bundle_test.cpp
----------------------------------------------------------------------
diff --git a/framework/private/test/bundle_test.cpp b/framework/private/test/bundle_test.cpp
index af23dbc..5dfb2be 100644
--- a/framework/private/test/bundle_test.cpp
+++ b/framework/private/test/bundle_test.cpp
@@ -634,7 +634,7 @@ TEST(bundle, revise) {
 	bundle_pt bundle = (bundle_pt) malloc(sizeof(*bundle));
 	arrayList_create(&bundle->modules);
 	bundle_archive_pt actual_archive = (bundle_archive_pt) 0x02;
-	bundle_revision_pt actual_revision = (bundle_revision_pt) malloc(sizeof(actual_revision));
+	bundle_revision_pt actual_revision = (bundle_revision_pt) malloc(sizeof(*actual_revision));
 	manifest_pt actual_manifest = (manifest_pt) malloc(sizeof(*actual_manifest));
 	int actual_id = 666;
 	const char * actual_module_id = "666.0";

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/log_service/private/src/log.c
----------------------------------------------------------------------
diff --git a/log_service/private/src/log.c b/log_service/private/src/log.c
index a6c3887..5b29318 100644
--- a/log_service/private/src/log.c
+++ b/log_service/private/src/log.c
@@ -252,8 +252,8 @@ celix_status_t log_addLogListener(log_pt logger, log_listener_pt listener) {
 celix_status_t log_removeLogListener(log_pt logger, log_listener_pt listener) {
 	celix_status_t status = CELIX_SUCCESS;
 
-    status = CELIX_DO_IF(status, celixThreadMutex_lock(&logger->deliverLock));
-    status = CELIX_DO_IF(status, celixThreadMutex_lock(&logger->listenerLock));
+    status += celixThreadMutex_lock(&logger->deliverLock);
+    status += celixThreadMutex_lock(&logger->listenerLock);
 
 	if (status == CELIX_SUCCESS) {
 	    bool last = false;
@@ -264,11 +264,11 @@ celix_status_t log_removeLogListener(log_pt logger, log_listener_pt listener) {
 			last = true;
 		}
 
-        status = CELIX_DO_IF(status, celixThreadMutex_unlock(&logger->listenerLock));
-        status = CELIX_DO_IF(status, celixThreadMutex_unlock(&logger->deliverLock));
+        status += celixThreadMutex_unlock(&logger->listenerLock);
+        status += celixThreadMutex_unlock(&logger->deliverLock);
 
 		if (last) {
-		    status = CELIX_DO_IF(status, celixThread_join(logger->listenerThread, NULL));
+		    status += celixThread_join(logger->listenerThread, NULL);
 		}
 	}
 

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/log_service/private/src/log_reader_service_impl.c
----------------------------------------------------------------------
diff --git a/log_service/private/src/log_reader_service_impl.c b/log_service/private/src/log_reader_service_impl.c
index cddb2a8..2a46ea7 100644
--- a/log_service/private/src/log_reader_service_impl.c
+++ b/log_service/private/src/log_reader_service_impl.c
@@ -39,7 +39,7 @@ celix_status_t logReaderService_create(log_pt log, log_reader_data_pt *reader) {
 
     *reader = (log_reader_data_pt) calloc(1, sizeof(**reader));
 
-    if (reader == NULL) {
+    if (*reader == NULL) {
         status = CELIX_ENOMEM;
     } else {
         (*reader)->log = log;

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/log_service/private/src/log_service_impl.c
----------------------------------------------------------------------
diff --git a/log_service/private/src/log_service_impl.c b/log_service/private/src/log_service_impl.c
index ad6313b..c7fa850 100644
--- a/log_service/private/src/log_service_impl.c
+++ b/log_service/private/src/log_service_impl.c
@@ -87,8 +87,10 @@ celix_status_t logService_logSr(log_service_data_pt logger, service_reference_pt
         }
     }
 
-    logEntry_create(bundleId, symbolicName, reference, level, message, 0, &entry);
-    log_addEntry(logger->log, entry);
+    if(status == CELIX_SUCCESS && symbolicName != NULL && message != NULL){
+	status = logEntry_create(bundleId, symbolicName, reference, level, message, 0, &entry);
+	log_addEntry(logger->log, entry);
+    }
 
-    return CELIX_SUCCESS;
+    return status;
 }

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/log_service/public/src/log_helper.c
----------------------------------------------------------------------
diff --git a/log_service/public/src/log_helper.c b/log_service/public/src/log_helper.c
index 91554a9..12ebe0b 100644
--- a/log_service/public/src/log_helper.c
+++ b/log_service/public/src/log_helper.c
@@ -162,27 +162,25 @@ celix_status_t logHelper_log(log_helper_pt loghelper, log_level_t level, char* m
     msg[0] = '\0';
     bool logged = false;
 
+    if(loghelper == NULL){
+	return CELIX_ILLEGAL_ARGUMENT;
+    }
+
 	va_start(listPointer, message);
 	vsnprintf(msg, 1024, message, listPointer);
 
-	if (loghelper != NULL) {
-		pthread_mutex_lock(&loghelper->logListLock);
-
-		int i = 0;
-
-		for (; i < arrayList_size(loghelper->logServices); i++) {
-
-			log_service_pt logService = arrayList_get(loghelper->logServices, i);
+	pthread_mutex_lock(&loghelper->logListLock);
 
-			if (logService != NULL) {
-				(logService->log)(logService->logger, level, msg);
-				logged = true;
-			}
+	int i = 0;
+	for (; i < arrayList_size(loghelper->logServices); i++) {
+		log_service_pt logService = arrayList_get(loghelper->logServices, i);
+		if (logService != NULL) {
+			(logService->log)(logService->logger, level, msg);
+			logged = true;
 		}
-
-		pthread_mutex_unlock(&loghelper->logListLock);
 	}
 
+	pthread_mutex_unlock(&loghelper->logListLock);
 
     if (!logged && loghelper->stdOutFallback) {
         char *levelStr = NULL;
@@ -206,6 +204,7 @@ celix_status_t logHelper_log(log_helper_pt loghelper, log_level_t level, char* m
         printf("%s: %s\n", levelStr, msg);
     }
 
+    va_end(listPointer);
 
 	return status;
 }


[2/3] celix git commit: CELIX-357: Fixes coverity warnings. Medium priority

Posted by pn...@apache.org.
http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/remote_services/discovery/private/src/endpoint_descriptor_reader.c
----------------------------------------------------------------------
diff --git a/remote_services/discovery/private/src/endpoint_descriptor_reader.c b/remote_services/discovery/private/src/endpoint_descriptor_reader.c
index 2f30d9e..cd13dc0 100644
--- a/remote_services/discovery/private/src/endpoint_descriptor_reader.c
+++ b/remote_services/discovery/private/src/endpoint_descriptor_reader.c
@@ -203,8 +203,9 @@ celix_status_t endpointDescriptorReader_parseDocument(endpoint_descriptor_reader
                 } else if (xmlStrcmp(localname, ENDPOINT_DESCRIPTION) == 0) {
                     endpoint_description_pt endpointDescription = NULL;
                     // Completely parsed endpoint description, add it to our list of results...
-                    endpointDescription_create(endpointProperties, &endpointDescription);
-                    arrayList_add(endpointDescriptions, endpointDescription);
+                    if(endpointDescription_create(endpointProperties, &endpointDescription) == CELIX_SUCCESS){
+			arrayList_add(endpointDescriptions, endpointDescription);
+                    }
 
                     endpointProperties = properties_create();
                 } else if (xmlStrcmp(localname, PROPERTY) == 0) {

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/remote_services/discovery/private/src/endpoint_discovery_poller.c
----------------------------------------------------------------------
diff --git a/remote_services/discovery/private/src/endpoint_discovery_poller.c b/remote_services/discovery/private/src/endpoint_discovery_poller.c
index 95dc847..202f061 100644
--- a/remote_services/discovery/private/src/endpoint_discovery_poller.c
+++ b/remote_services/discovery/private/src/endpoint_discovery_poller.c
@@ -103,13 +103,12 @@ celix_status_t endpointDiscoveryPoller_create(discovery_pt discovery, bundle_con
 
 	(*poller)->running = true;
 
-	status = celixThread_create(&(*poller)->pollerThread, NULL, endpointDiscoveryPoller_performPeriodicPoll, *poller);
-	if (status != CELIX_SUCCESS) {
-		return status;
-	}
+	status += celixThread_create(&(*poller)->pollerThread, NULL, endpointDiscoveryPoller_performPeriodicPoll, *poller);
+	status += celixThreadMutex_unlock(&(*poller)->pollerLock);
 
-
-	status = celixThreadMutex_unlock(&(*poller)->pollerLock);
+	if(status != CELIX_SUCCESS){
+		status = CELIX_BUNDLE_EXCEPTION;
+	}
 
 	return status;
 }
@@ -219,14 +218,13 @@ celix_status_t endpointDiscoveryPoller_removeDiscoveryEndpoint(endpoint_discover
 
 			array_list_pt entries = hashMap_remove(poller->entries, url);
 
-			for (unsigned int i = arrayList_size(entries); i > 0; i--) {
-				endpoint_description_pt endpoint = arrayList_get(entries, i - 1);
-				discovery_removeDiscoveredEndpoint(poller->discovery, endpoint);
-				arrayList_remove(entries, i - 1);
-				endpointDescription_destroy(endpoint);
-			}
-
 			if (entries != NULL) {
+				for (unsigned int i = arrayList_size(entries); i > 0; i--) {
+					endpoint_description_pt endpoint = arrayList_get(entries, i - 1);
+					discovery_removeDiscoveredEndpoint(poller->discovery, endpoint);
+					arrayList_remove(entries, i - 1);
+					endpointDescription_destroy(endpoint);
+				}
 				arrayList_destroy(entries);
 			}
 

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/remote_services/discovery_shm/private/src/discovery_shm.c
----------------------------------------------------------------------
diff --git a/remote_services/discovery_shm/private/src/discovery_shm.c b/remote_services/discovery_shm/private/src/discovery_shm.c
index 9567401..1b1170e 100644
--- a/remote_services/discovery_shm/private/src/discovery_shm.c
+++ b/remote_services/discovery_shm/private/src/discovery_shm.c
@@ -125,8 +125,13 @@ celix_status_t discoveryShm_attach(shmData_pt* data) {
         status = CELIX_BUNDLE_EXCEPTION;
     }
 
-    if (((*data) = shmat(shmId, 0, 0)) < 0) {
-        status = CELIX_BUNDLE_EXCEPTION;
+    /* shmat has a curious return value of (void*)-1 in case of error */
+    void *mem=shmat(shmId, 0, 0);
+    if(mem==((void*)-1)){
+	status = CELIX_BUNDLE_EXCEPTION;
+    }
+    else{
+	(*data)=mem;
     }
 
     return status;
@@ -166,7 +171,7 @@ celix_status_t discoveryShm_getKeys(shmData_pt data, char** keys, int* size) {
         for (i = 0; i < data->numOfEntries; i++) {
             shmEntry entry = data->entries[i];
 
-            if (entry.key) {
+            if (strlen(entry.key)>0) {
                 snprintf(keys[i], SHM_ENTRY_MAX_KEY_LENGTH, "%s", entry.key);
             }
         }

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/remote_services/examples/calculator_shell/private/src/add_command.c
----------------------------------------------------------------------
diff --git a/remote_services/examples/calculator_shell/private/src/add_command.c b/remote_services/examples/calculator_shell/private/src/add_command.c
index b003a5b..b2520ae 100644
--- a/remote_services/examples/calculator_shell/private/src/add_command.c
+++ b/remote_services/examples/calculator_shell/private/src/add_command.c
@@ -52,37 +52,36 @@ void addCommand_execute(bundle_context_pt context, char *line, FILE *out, FILE *
     if (status == CELIX_SUCCESS) {
     	char *token = line;
     	strtok_r(line, " ", &token);
-		char *aStr = strtok_r(NULL, " ", &token);
-		bool numeric;
-		addCommand_isNumeric(aStr, &numeric);
-		if (aStr != NULL && numeric) {
-			char *bStr = strtok_r(NULL, " ", &token);
-			addCommand_isNumeric(bStr, &numeric);
-			if (bStr != NULL && numeric) {
-				calculator_service_pt calculator = NULL;
-				status = bundleContext_getService(context, calculatorService, (void *) &calculator);
-                if (status == CELIX_SUCCESS && calculator != NULL) {
-					double a = atof(aStr);
-					double b = atof(bStr);
-					double result = 0;
-					status = calculator->add(calculator->calculator, a, b, &result);
-					if (status == CELIX_SUCCESS) {
-						fprintf(out, "CALCULATOR_SHELL: Add: %f + %f = %f\n", a, b, result);
-					} else {
-						fprintf(err, "ADD: Unexpected exception in Calc service\n");
-					}
+	char *aStr = strtok_r(NULL, " ", &token);
+	char *bStr = strtok_r(NULL, " ", &token);
+	bool aNumeric, bNumeric;
+	if (aStr != NULL && bStr != NULL) {
+		addCommand_isNumeric(aStr, &aNumeric);
+		addCommand_isNumeric(bStr, &bNumeric);
+		if(aNumeric && bNumeric){
+			calculator_service_pt calculator = NULL;
+			status = bundleContext_getService(context, calculatorService, (void *) &calculator);
+			if (status == CELIX_SUCCESS && calculator != NULL) {
+				double a = atof(aStr);
+				double b = atof(bStr);
+				double result = 0;
+				status = calculator->add(calculator->calculator, a, b, &result);
+				if (status == CELIX_SUCCESS) {
+					fprintf(out, "CALCULATOR_SHELL: Add: %f + %f = %f\n", a, b, result);
 				} else {
-					fprintf(err, "No calc service available\n");
+					fprintf(err, "ADD: Unexpected exception in Calc service\n");
 				}
 			} else {
-				fprintf(err, "ADD: Requires 2 numerical parameter\n");
+				fprintf(err, "No calc service available\n");
 			}
 		} else {
 			fprintf(err, "ADD: Requires 2 numerical parameter\n");
-			status = CELIX_ILLEGAL_ARGUMENT;
 		}
+	} else {
+		fprintf(err, "ADD: Requires 2 numerical parameter\n");
+	}
     } else {
-		fprintf(err, "No calc service available\n");
+	fprintf(err, "No calc service available\n");
     }
 
     //return status;

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/remote_services/examples/calculator_shell/private/src/sqrt_command.c
----------------------------------------------------------------------
diff --git a/remote_services/examples/calculator_shell/private/src/sqrt_command.c b/remote_services/examples/calculator_shell/private/src/sqrt_command.c
index 8c53896..2e7238c 100644
--- a/remote_services/examples/calculator_shell/private/src/sqrt_command.c
+++ b/remote_services/examples/calculator_shell/private/src/sqrt_command.c
@@ -51,26 +51,29 @@ void sqrtCommand_execute(bundle_context_pt context, char *line, FILE *out, FILE
     	char *token = line;
     	strtok_r(line, " ", &token);
 		char *aStr = strtok_r(NULL, " ", &token);
-		bool numeric;
-		sqrtCommand_isNumeric(aStr, &numeric);
-		if (aStr != NULL && numeric) {
-			calculator_service_pt calculator = NULL;
-			status = bundleContext_getService(context, calculatorService, (void *) &calculator);
-			if (status == CELIX_SUCCESS && calculator != NULL) {
-				double a = atof(aStr);
-				double result = 0;
-				status = calculator->sqrt(calculator->calculator, a, &result);
-				if (status == CELIX_SUCCESS) {
-					fprintf(out, "CALCULATOR_SHELL: Sqrt: %f = %f\n", a, result);
+		if(aStr != NULL){
+			bool numeric;
+			sqrtCommand_isNumeric(aStr, &numeric);
+			if (numeric) {
+				calculator_service_pt calculator = NULL;
+				status = bundleContext_getService(context, calculatorService, (void *) &calculator);
+				if (status == CELIX_SUCCESS && calculator != NULL) {
+					double a = atof(aStr);
+					double result = 0;
+					status = calculator->sqrt(calculator->calculator, a, &result);
+					if (status == CELIX_SUCCESS) {
+						fprintf(out, "CALCULATOR_SHELL: Sqrt: %f = %f\n", a, result);
+					} else {
+						fprintf(err, "SQRT: Unexpected exception in Calc service\n");
+					}
 				} else {
-					fprintf(err, "SQRT: Unexpected exception in Calc service\n");
+					fprintf(err, "No calc service available\n");
 				}
 			} else {
-				fprintf(err, "No calc service available\n");
+				fprintf(err, "SQRT: Requires 1 numerical parameter\n");
 			}
 		} else {
 			fprintf(err, "SQRT: Requires 1 numerical parameter\n");
-			status = CELIX_ILLEGAL_ARGUMENT;
 		}
     } else {
 		fprintf(err, "No calc service available\n");

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/remote_services/examples/calculator_shell/private/src/sub_command.c
----------------------------------------------------------------------
diff --git a/remote_services/examples/calculator_shell/private/src/sub_command.c b/remote_services/examples/calculator_shell/private/src/sub_command.c
index 7cdc394..672ea4c 100644
--- a/remote_services/examples/calculator_shell/private/src/sub_command.c
+++ b/remote_services/examples/calculator_shell/private/src/sub_command.c
@@ -51,12 +51,12 @@ void subCommand_execute(bundle_context_pt context, char *line, FILE *out, FILE *
     	char *token = line;
     	strtok_r(line, " ", &token);
 		char *aStr = strtok_r(NULL, " ", &token);
-		bool numeric;
-		subCommand_isNumeric(aStr, &numeric);
-		if (aStr != NULL && numeric) {
-			char *bStr = strtok_r(NULL, " ", &token);
-			subCommand_isNumeric(bStr, &numeric);
-			if (bStr != NULL && numeric) {
+		char *bStr = strtok_r(NULL, " ", &token);
+		if(aStr != NULL && bStr != NULL ){
+			bool aNumeric, bNumeric;
+			subCommand_isNumeric(aStr, &aNumeric);
+			subCommand_isNumeric(bStr, &bNumeric);
+			if (aNumeric && bNumeric) {
 				calculator_service_pt calculator = NULL;
 				status = bundleContext_getService(context, calculatorService, (void *) &calculator);
 				if (status == CELIX_SUCCESS && calculator != NULL) {
@@ -77,7 +77,6 @@ void subCommand_execute(bundle_context_pt context, char *line, FILE *out, FILE *
 			}
 		} else {
 			fprintf(err, "SUB: Requires 2 numerical parameter\n");
-			status = CELIX_ILLEGAL_ARGUMENT;
 		}
     } else {
 		fprintf(err, "No calc service available\n");

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/remote_services/remote_service_admin_dfi/rsa/private/src/import_registration_dfi.c
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin_dfi/rsa/private/src/import_registration_dfi.c b/remote_services/remote_service_admin_dfi/rsa/private/src/import_registration_dfi.c
index 4c6f7b4..7660f3e 100644
--- a/remote_services/remote_service_admin_dfi/rsa/private/src/import_registration_dfi.c
+++ b/remote_services/remote_service_admin_dfi/rsa/private/src/import_registration_dfi.c
@@ -206,16 +206,16 @@ static celix_status_t importRegistration_createProxy(import_registration_pt impo
     status = dfi_findDescriptor(import->context, bundle, import->classObject, &descriptor);
 
     if (status != CELIX_SUCCESS || descriptor == NULL) {
-        status = CELIX_BUNDLE_EXCEPTION;
         //TODO use log helper logHelper_log(helper, OSGI_LOGSERVICE_ERROR, "Cannot find/open descriptor for '%s'", import->classObject);
         fprintf(stderr, "RSA_DFI: Cannot find/open descriptor for '%s'", import->classObject);
+        return CELIX_BUNDLE_EXCEPTION;
     }
 
     if (status == CELIX_SUCCESS) {
         int rc = dynInterface_parse(descriptor, &intf);
         fclose(descriptor);
-        if (rc != 0) {
-            status = CELIX_BUNDLE_EXCEPTION;
+        if (rc != 0 || intf==NULL) {
+            return CELIX_BUNDLE_EXCEPTION;
         }
     }
 

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/remote_services/remote_service_admin_dfi/rsa/private/src/remote_service_admin_dfi.c
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin_dfi/rsa/private/src/remote_service_admin_dfi.c b/remote_services/remote_service_admin_dfi/rsa/private/src/remote_service_admin_dfi.c
index 1ac5470..f1f518a 100644
--- a/remote_services/remote_service_admin_dfi/rsa/private/src/remote_service_admin_dfi.c
+++ b/remote_services/remote_service_admin_dfi/rsa/private/src/remote_service_admin_dfi.c
@@ -459,7 +459,7 @@ celix_status_t remoteServiceAdmin_removeExportedService(remote_service_admin_pt
     export_reference_pt  ref = NULL;
     status = exportRegistration_getExportReference(registration, &ref);
 
-    if (status == CELIX_SUCCESS) {
+    if (status == CELIX_SUCCESS && ref != NULL) {
     	service_reference_pt servRef;
         celixThreadMutex_lock(&admin->exportedServicesLock);
     	exportReference_getExportedService(ref, &servRef);
@@ -474,9 +474,8 @@ celix_status_t remoteServiceAdmin_removeExportedService(remote_service_admin_pt
 
         celixThreadMutex_unlock(&admin->exportedServicesLock);
 
-        if (ref != NULL) {
-        	free(ref);
-        }
+        free(ref);
+
     } else {
     	logHelper_log(admin->loghelper, OSGI_LOGSERVICE_ERROR, "Cannot find reference for registration");
     }
@@ -626,11 +625,11 @@ celix_status_t remoteServiceAdmin_importService(remote_service_admin_pt admin, e
     if (objectClass != NULL) {
         status = importRegistration_create(admin->context, endpointDescription, objectClass, serviceVersion, &import);
     }
-    if (status == CELIX_SUCCESS) {
+    if (status == CELIX_SUCCESS && import != NULL) {
         importRegistration_setSendFn(import, (send_func_type) remoteServiceAdmin_send, admin);
     }
 
-    if (status == CELIX_SUCCESS) {
+    if (status == CELIX_SUCCESS && import != NULL) {
         status = importRegistration_start(import);
     }
 
@@ -709,7 +708,7 @@ static celix_status_t remoteServiceAdmin_send(void *handle, endpoint_description
     } else {
         curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
         curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout);
-        curl_easy_setopt(curl, CURLOPT_URL, &url[0]);
+        curl_easy_setopt(curl, CURLOPT_URL, url);
         curl_easy_setopt(curl, CURLOPT_POST, 1L);
         curl_easy_setopt(curl, CURLOPT_READFUNCTION, remoteServiceAdmin_readCallback);
         curl_easy_setopt(curl, CURLOPT_READDATA, &post);
@@ -771,4 +770,5 @@ static void remoteServiceAdmin_log(remote_service_admin_pt admin, int level, con
     char buf2[256];
     vsnprintf(buf2, 256, msg, ap);
     logHelper_log(admin->loghelper, levels[level], "%s%s", buf1, buf2);
+    va_end(ap);
 }

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c b/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c
index 7be7571..e508c0f 100644
--- a/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c
+++ b/remote_services/remote_service_admin_http/private/src/remote_service_admin_impl.c
@@ -387,12 +387,11 @@ celix_status_t remoteServiceAdmin_exportService(remote_service_admin_pt admin, c
 
 	bundleContext_getServiceReferences(admin->context, NULL, filter, &references);
 
-	if (arrayList_size(references) >= 1) {
-		reference = arrayList_get(references, 0);
-	}
-
-    if(references!=NULL){
-        arrayList_destroy(references);
+	if(references!=NULL){
+		if (arrayList_size(references) >= 1) {
+			reference = arrayList_get(references, 0);
+		}
+		arrayList_destroy(references);
     }
 
 	if (reference == NULL) {
@@ -467,7 +466,7 @@ celix_status_t remoteServiceAdmin_removeExportedService(remote_service_admin_pt
 
     status = exportRegistration_getExportReference(registration, &ref);
 
-    if (status == CELIX_SUCCESS) {
+    if (status == CELIX_SUCCESS && ref != NULL) {
     	service_reference_pt servRef;
         celixThreadMutex_lock(&admin->exportedServicesLock);
     	exportReference_getExportedService(ref, &servRef);
@@ -482,9 +481,8 @@ celix_status_t remoteServiceAdmin_removeExportedService(remote_service_admin_pt
 
         celixThreadMutex_unlock(&admin->exportedServicesLock);
 
-        if (ref != NULL) {
-        	free(ref);
-        }
+        free(ref);
+
     } else {
     	 logHelper_log(admin->loghelper, OSGI_LOGSERVICE_ERROR, "Cannot find reference for registration");
     }
@@ -766,7 +764,7 @@ celix_status_t remoteServiceAdmin_send(remote_service_admin_pt rsa, endpoint_des
 		} else {
 		    curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1);
 			curl_easy_setopt(curl, CURLOPT_TIMEOUT, timeout);
-			curl_easy_setopt(curl, CURLOPT_URL, &url[0]);
+			curl_easy_setopt(curl, CURLOPT_URL, url);
 			curl_easy_setopt(curl, CURLOPT_POST, 1L);
 			curl_easy_setopt(curl, CURLOPT_READFUNCTION, remoteServiceAdmin_readCallback);
 			curl_easy_setopt(curl, CURLOPT_READDATA, &post);

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/remote_services/remote_service_admin_shm/private/src/remote_service_admin_impl.c
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin_shm/private/src/remote_service_admin_impl.c b/remote_services/remote_service_admin_shm/private/src/remote_service_admin_impl.c
index 014e5a0..5b1ffa8 100644
--- a/remote_services/remote_service_admin_shm/private/src/remote_service_admin_impl.c
+++ b/remote_services/remote_service_admin_shm/private/src/remote_service_admin_impl.c
@@ -368,7 +368,9 @@ celix_status_t remoteServiceAdmin_getSharedIdentifierFile(remote_service_admin_p
 
 		snprintf(tmpDir, RSA_FILEPATH_LENGTH, "%s/%s", P_tmpdir, fwUuid);
 
-		mkdir(tmpDir, 0755);
+		if(mkdir(tmpDir, 0755) == -1 ){
+			logHelper_log(admin->loghelper, OSGI_LOGSERVICE_ERROR, "error while creating directory %s (%s)", tmpDir, strerror(errno));
+		}
 		FILE *shid_file = fopen(outFile, "wb");
 		if (shid_file == NULL) {
 			logHelper_log(admin->loghelper, OSGI_LOGSERVICE_ERROR, "error while creating shared identifier file %s (%s)", outFile, strerror(errno));

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/remote_services/topology_manager/private/src/topology_manager.c
----------------------------------------------------------------------
diff --git a/remote_services/topology_manager/private/src/topology_manager.c b/remote_services/topology_manager/private/src/topology_manager.c
index 16afdc0..f4d27a8 100644
--- a/remote_services/topology_manager/private/src/topology_manager.c
+++ b/remote_services/topology_manager/private/src/topology_manager.c
@@ -151,25 +151,25 @@ celix_status_t topologyManager_closeImports(topology_manager_pt manager) {
 		endpoint_description_pt ep = hashMapEntry_getKey(entry);
 		hash_map_pt imports = hashMapEntry_getValue(entry);
 
-		logHelper_log(manager->loghelper, OSGI_LOGSERVICE_INFO, "TOPOLOGY_MANAGER: Remove imported service (%s; %s).", ep->service, ep->id);
-		hash_map_iterator_pt importsIter = hashMapIterator_create(imports);
+		if (imports != NULL) {
+			logHelper_log(manager->loghelper, OSGI_LOGSERVICE_INFO, "TOPOLOGY_MANAGER: Remove imported service (%s; %s).", ep->service, ep->id);
+			hash_map_iterator_pt importsIter = hashMapIterator_create(imports);
 
-		while (hashMapIterator_hasNext(importsIter)) {
-			hash_map_entry_pt entry = hashMapIterator_nextEntry(importsIter);
+			while (hashMapIterator_hasNext(importsIter)) {
+				hash_map_entry_pt entry = hashMapIterator_nextEntry(importsIter);
 
-			remote_service_admin_service_pt rsa = hashMapEntry_getKey(entry);
-			import_registration_pt import = hashMapEntry_getValue(entry);
+				remote_service_admin_service_pt rsa = hashMapEntry_getKey(entry);
+				import_registration_pt import = hashMapEntry_getValue(entry);
 
-			status = rsa->importRegistration_close(rsa->admin, import);
-			if (status == CELIX_SUCCESS) {
-				hashMapIterator_remove(importsIter);
+				status = rsa->importRegistration_close(rsa->admin, import);
+				if (status == CELIX_SUCCESS) {
+					hashMapIterator_remove(importsIter);
+				}
 			}
-		}
-		hashMapIterator_destroy(importsIter);
+			hashMapIterator_destroy(importsIter);
 
-		hashMapIterator_remove(iter);
+			hashMapIterator_remove(iter);
 
-		if (imports != NULL) {
 			hashMap_destroy(imports, false, false);
 		}
 	}
@@ -563,7 +563,7 @@ celix_status_t topologyManager_removeImportedService(void *handle, endpoint_desc
 			endpoint_description_pt ep = hashMapEntry_getKey(entry);
 			hash_map_pt imports = hashMapEntry_getValue(entry);
 
-			if (strcmp(endpoint->id, ep->id) == 0) {
+			if (imports != NULL && strcmp(endpoint->id, ep->id) == 0) {
 				hash_map_iterator_pt importsIter = hashMapIterator_create(imports);
 
 				while (hashMapIterator_hasNext(importsIter)) {
@@ -571,7 +571,7 @@ celix_status_t topologyManager_removeImportedService(void *handle, endpoint_desc
 					remote_service_admin_service_pt rsa = hashMapEntry_getKey(entry);
 					import_registration_pt import = hashMapEntry_getValue(entry);
 					celix_status_t substatus = rsa->importRegistration_close(rsa->admin, import);
-					if (status == CELIX_SUCCESS) {
+					if (substatus == CELIX_SUCCESS) {
 						hashMapIterator_remove(importsIter);
 					} else {
 						status = substatus;
@@ -580,9 +580,7 @@ celix_status_t topologyManager_removeImportedService(void *handle, endpoint_desc
 				hashMapIterator_destroy(importsIter);
 				hashMapIterator_remove(iter);
 
-				if (imports != NULL) {
-					hashMap_destroy(imports, false, false);
-				}
+				hashMap_destroy(imports, false, false);
 			}
 		}
 		hashMapIterator_destroy(iter);

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/remote_services/utils/private/src/civetweb.c
----------------------------------------------------------------------
diff --git a/remote_services/utils/private/src/civetweb.c b/remote_services/utils/private/src/civetweb.c
index 94009c9..b87be74 100644
--- a/remote_services/utils/private/src/civetweb.c
+++ b/remote_services/utils/private/src/civetweb.c
@@ -3903,7 +3903,7 @@ static int remove_directory(struct mg_connection *conn, const char *dir)
                 if(de.file.is_directory) {
                     remove_directory(conn, path);
                 } else {
-                    mg_remove(path);
+                    (void) mg_remove(path);
                 }
             }
 
@@ -5992,14 +5992,20 @@ int mg_upload2(struct mg_connection *conn, const char *destination_dir, int time
         } while (!eof && (n = mg_read(conn, buf + len, sizeof(buf) - len)) > 0);
         fclose(fp);
         if (eof) {
-            remove(path);
-            rename(tmp_path, path);
+            if( remove(path) == -1){
+		mg_cry(conn,"Unable to remove %s",path);
+            }
+            if( rename(tmp_path, path) == -1){
+		mg_cry(conn,"Unable to rename %s to %s",tmp_path,path);
+            }
             num_uploaded_files++;
             if (conn->ctx->callbacks.upload != NULL) {
                 conn->ctx->callbacks.upload(conn, path);
             }
         } else {
-            remove(tmp_path);
+            if( remove(tmp_path) == -1){
+		mg_cry(conn,"Unable to remove %s",tmp_path);
+            }
         }
     }
 

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/remote_shell/private/src/remote_shell.c
----------------------------------------------------------------------
diff --git a/remote_shell/private/src/remote_shell.c b/remote_shell/private/src/remote_shell.c
index 73b76d4..8f42778 100644
--- a/remote_shell/private/src/remote_shell.c
+++ b/remote_shell/private/src/remote_shell.c
@@ -123,7 +123,7 @@ celix_status_t remoteShell_addConnection(remote_shell_pt instance, int socket) {
 		status = CELIX_ENOMEM;
 	}
 
-	if (status != CELIX_SUCCESS) {
+	if (status != CELIX_SUCCESS && connection != NULL) {
 		if (connection->socketStream != NULL) {
 			fclose(connection->socketStream);
 		}

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/remote_shell/private/src/shell_mediator.c
----------------------------------------------------------------------
diff --git a/remote_shell/private/src/shell_mediator.c b/remote_shell/private/src/shell_mediator.c
index ae4de10..d9722a9 100644
--- a/remote_shell/private/src/shell_mediator.c
+++ b/remote_shell/private/src/shell_mediator.c
@@ -66,7 +66,7 @@ celix_status_t shellMediator_create(bundle_context_pt context, shell_mediator_pt
 		status = CELIX_ENOMEM;
 	}
 
-	if (status != CELIX_SUCCESS) {
+	if ((status != CELIX_SUCCESS) && ((*instance) != NULL)){
 		logHelper_log((*instance)->loghelper, OSGI_LOGSERVICE_ERROR, "Error creating shell_mediator, error code is %i\n", status);
 	}
 	return status;

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/shell/private/src/shell.c
----------------------------------------------------------------------
diff --git a/shell/private/src/shell.c b/shell/private/src/shell.c
index 8f8241e..9956ce2 100644
--- a/shell/private/src/shell.c
+++ b/shell/private/src/shell.c
@@ -113,7 +113,7 @@ celix_status_t shell_addCommand(shell_pt shell_ptr, service_reference_pt referen
     char *name_str = NULL;
 
     if (!shell_ptr || !reference_ptr) {
-        status = CELIX_ILLEGAL_ARGUMENT;
+        return CELIX_ILLEGAL_ARGUMENT;
     }
 
     if (status == CELIX_SUCCESS) {

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/utils/private/src/thpool.c
----------------------------------------------------------------------
diff --git a/utils/private/src/thpool.c b/utils/private/src/thpool.c
index 5a58218..5121fca 100644
--- a/utils/private/src/thpool.c
+++ b/utils/private/src/thpool.c
@@ -135,7 +135,7 @@ struct thpool_* thpool_init(int num_threads){
 	}
 
 	/* Make threads in pool */
-	thpool_p->threads = (struct thread**)malloc(num_threads * sizeof(struct thread));
+	thpool_p->threads = (struct thread**)malloc(num_threads * sizeof(struct thread*));
 	if (thpool_p->threads == NULL){
 		fprintf(stderr, "thpool_init(): Could not allocate memory for threads\n");
 		jobqueue_destroy(thpool_p);
@@ -264,7 +264,7 @@ void thpool_resume(thpool_* thpool_p) {
 static void thread_init (thpool_* thpool_p, struct thread** thread_p, int id){
 	
 	*thread_p = (struct thread*)malloc(sizeof(struct thread));
-	if (thread_p == NULL){
+	if (*thread_p == NULL){
 		fprintf(stderr, "thpool_init(): Could not allocate memory for thread\n");
 		exit(1);
 	}

http://git-wip-us.apache.org/repos/asf/celix/blob/137fdf5c/utils/private/test/celix_threads_test.cpp
----------------------------------------------------------------------
diff --git a/utils/private/test/celix_threads_test.cpp b/utils/private/test/celix_threads_test.cpp
index f75f8db..ff9d277 100644
--- a/utils/private/test/celix_threads_test.cpp
+++ b/utils/private/test/celix_threads_test.cpp
@@ -343,6 +343,7 @@ TEST(celix_thread_condition, wait) {
 
 	celixThreadCondition_wait(&param->cond, &param->mu);
 	LONGS_EQUAL(666, param->i);
+	celixThreadMutex_unlock(&param->mu);
 
 	celixThread_join(thread, NULL);
 	free(param);
@@ -360,17 +361,17 @@ TEST(celix_thread_condition, broadcast) {
 	celixThread_create(&thread2, NULL, thread_test_func_cond_broadcast, param);
 
 	sleep(1);
-	celixThreadMutex_lock(&param->mu2);
+	celixThreadMutex_lock(&param->mu);
 	LONGS_EQUAL(0, param->i);
-	celixThreadMutex_unlock(&param->mu2);
+	celixThreadMutex_unlock(&param->mu);
 
 	celixThreadMutex_lock(&param->mu);
 	celixThreadCondition_broadcast(&param->cond);
 	celixThreadMutex_unlock(&param->mu);
 	sleep(1);
-	celixThreadMutex_lock(&param->mu2);
+	celixThreadMutex_lock(&param->mu);
 	LONGS_EQUAL(2, param->i);
-	celixThreadMutex_unlock(&param->mu2);
+	celixThreadMutex_unlock(&param->mu);
 
 	celixThread_join(thread, NULL);
 	celixThread_join(thread2, NULL);
@@ -494,9 +495,9 @@ static void * thread_test_func_cond_broadcast(void *arg) {
 	celixThreadMutex_lock(&param->mu);
 	celixThreadCondition_wait(&param->cond, &param->mu);
 	celixThreadMutex_unlock(&param->mu);
-	celixThreadMutex_lock(&param->mu2);
+	celixThreadMutex_lock(&param->mu);
 	param->i++;
-	celixThreadMutex_unlock(&param->mu2);
+	celixThreadMutex_unlock(&param->mu);
 	return NULL;
 }