celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pnol...@apache.org
Subject [2/3] celix git commit: CELIX-357: Fixes coverity warnings. Medium priority
Date Fri, 29 Apr 2016 16:58:13 GMT
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;
 }
 


Mime
View raw message