celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pnol...@apache.org
Subject [37/38] celix git commit: CELIX-272: Fix some small (lint warning) issues
Date Tue, 17 Nov 2015 11:57:54 GMT
CELIX-272: Fix some small (lint warning) issues


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

Branch: refs/heads/develop
Commit: 5eb0321ca22f92a55a5ac8ea600503918f5ac26f
Parents: 47fe773
Author: Pepijn Noltes <pepijnnoltes@gmail.com>
Authored: Tue Nov 17 11:25:15 2015 +0100
Committer: Pepijn Noltes <pepijnnoltes@gmail.com>
Committed: Tue Nov 17 11:25:15 2015 +0100

----------------------------------------------------------------------
 framework/private/src/service_registration.c | 34 +++++++++++------------
 framework/private/src/service_registry.c     |  2 +-
 2 files changed, 17 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/5eb0321c/framework/private/src/service_registration.c
----------------------------------------------------------------------
diff --git a/framework/private/src/service_registration.c b/framework/private/src/service_registration.c
index f1fea32..d9c5752 100644
--- a/framework/private/src/service_registration.c
+++ b/framework/private/src/service_registration.c
@@ -148,13 +148,13 @@ void serviceRegistration_invalidate(service_registration_pt registration)
{
 
 bool serviceRegistration_isValid(service_registration_pt registration) {
     bool isValid;
-    celixThreadRwlock_readLock(&registration->lock);
     if (registration != NULL) {
+        celixThreadRwlock_readLock(&registration->lock);
         isValid = registration->svcObj != NULL;
+        celixThreadRwlock_unlock(&registration->lock);
     } else {
         isValid = false;
     }
-    celixThreadRwlock_unlock(&registration->lock);
     return isValid;
 }
 
@@ -216,14 +216,13 @@ celix_status_t serviceRegistration_ungetService(service_registration_pt
registra
 celix_status_t serviceRegistration_getProperties(service_registration_pt registration, properties_pt
*properties) {
 	celix_status_t status = CELIX_SUCCESS;
 
-    celixThreadRwlock_readLock(&registration->lock);
     if (registration != NULL && *properties == NULL) {
-		*properties = registration->properties;
+        celixThreadRwlock_readLock(&registration->lock);
+        *properties = registration->properties;
+        celixThreadRwlock_unlock(&registration->lock);
 	} else {
 		status = CELIX_ILLEGAL_ARGUMENT;
 	}
-    celixThreadRwlock_unlock(&registration->lock);
-
 
     framework_logIfError(logger, status, NULL, "Cannot get registration properties");
 
@@ -231,11 +230,10 @@ celix_status_t serviceRegistration_getProperties(service_registration_pt
registr
 }
 
 celix_status_t serviceRegistration_setProperties(service_registration_pt registration, properties_pt
properties) {
-    celix_status_t status = CELIX_SUCCESS;
+    celix_status_t status;
 
     properties_pt oldProperties = NULL;
     registry_callback_t callback;
-    callback.modified = NULL;
 
     celixThreadRwlock_writeLock(&registration->lock);
     oldProperties = registration->properties;
@@ -247,21 +245,20 @@ celix_status_t serviceRegistration_setProperties(service_registration_pt
registr
         callback.modified(callback.handle, registration, oldProperties);
     }
 
-	return CELIX_SUCCESS;
+	return status;
 }
 
 
 celix_status_t serviceRegistration_getBundle(service_registration_pt registration, bundle_pt
*bundle) {
 	celix_status_t status = CELIX_SUCCESS;
 
-    celixThreadRwlock_readLock(&registration->lock);
     if (registration != NULL && *bundle == NULL) {
-		*bundle = registration->bundle;
+        celixThreadRwlock_readLock(&registration->lock);
+        *bundle = registration->bundle;
+        celixThreadRwlock_unlock(&registration->lock);
 	} else {
 		status = CELIX_ILLEGAL_ARGUMENT;
 	}
-    celixThreadRwlock_unlock(&registration->lock);
-
 
     framework_logIfError(logger, status, NULL, "Cannot get bundle");
 
@@ -271,13 +268,14 @@ celix_status_t serviceRegistration_getBundle(service_registration_pt
registratio
 celix_status_t serviceRegistration_getServiceName(service_registration_pt registration, char
**serviceName) {
 	celix_status_t status = CELIX_SUCCESS;
 
-    celixThreadRwlock_readLock(&registration->lock);
     if (registration != NULL && *serviceName == NULL) {
-		*serviceName = registration->className;
+        celixThreadRwlock_readLock(&registration->lock);
+        *serviceName = registration->className;
+        celixThreadRwlock_unlock(&registration->lock);
 	} else {
-		status = CELIX_ILLEGAL_ARGUMENT;
-	}
-    celixThreadRwlock_unlock(&registration->lock);
+        status = CELIX_ILLEGAL_ARGUMENT;
+    }
+
 
     framework_logIfError(logger, status, NULL, "Cannot get service name");
 

http://git-wip-us.apache.org/repos/asf/celix/blob/5eb0321c/framework/private/src/service_registry.c
----------------------------------------------------------------------
diff --git a/framework/private/src/service_registry.c b/framework/private/src/service_registry.c
index 277fe77..4155854 100644
--- a/framework/private/src/service_registry.c
+++ b/framework/private/src/service_registry.c
@@ -99,7 +99,7 @@ celix_status_t serviceRegistry_destroy(service_registry_pt registry) {
     hashMap_destroy(registry->serviceRegistrations, false, false);
 
     //destroy service references (double) map);
-    size = hashMap_size(registry->serviceReferences);
+    //size = hashMap_size(registry->serviceReferences);
     //assert(size == 0); FIXME This gives a problem in the remote_service_admin_dfi test.
seems that the bundleActivator_stop of the calculator is activated twice ??
     hashMap_destroy(registry->serviceReferences, false, false);
 


Mime
View raw message