celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pnol...@apache.org
Subject [35/50] [abbrv] celix git commit: CELIX-376: Use of serviceId as hashMap index instead of registration pointer
Date Wed, 26 Oct 2016 12:15:58 GMT
CELIX-376: Use of serviceId as hashMap index instead of registration pointer


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

Branch: refs/heads/master
Commit: 652741c911a7f47886da35b8be263e4cf217490f
Parents: 73ffc04
Author: gricciardi <gricciardi@apache.org>
Authored: Fri Oct 14 17:17:41 2016 +0200
Committer: gricciardi <gricciardi@apache.org>
Committed: Fri Oct 14 17:17:41 2016 +0200

----------------------------------------------------------------------
 dependency_manager/private/include/dm_event.h   |  2 +-
 dependency_manager/private/src/dm_event.c       |  2 +-
 .../include/service_registration_private.h      |  6 +-
 .../private/include/service_registry_private.h  |  4 +-
 .../private/mock/service_registration_mock.c    |  8 +--
 framework/private/src/service_registration.c    | 10 +--
 framework/private/src/service_registry.c        | 18 ++---
 framework/private/src/utils.c                   |  2 +-
 .../private/test/service_registration_test.cpp  |  9 +--
 .../private/test/service_registry_test.cpp      | 75 ++++++++++++++------
 framework/public/include/utils.h                |  2 +-
 .../private/src/endpoint_descriptor_reader.c    |  2 +-
 .../private/src/endpoint_description.c          | 10 +--
 .../public/include/endpoint_description.h       |  2 +-
 .../rsa/private/src/remote_service_admin_dfi.c  |  4 +-
 .../private/src/remote_service_admin_impl.c     |  2 +-
 16 files changed, 94 insertions(+), 64 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/652741c9/dependency_manager/private/include/dm_event.h
----------------------------------------------------------------------
diff --git a/dependency_manager/private/include/dm_event.h b/dependency_manager/private/include/dm_event.h
index 8ba1be7..1cccd47 100644
--- a/dependency_manager/private/include/dm_event.h
+++ b/dependency_manager/private/include/dm_event.h
@@ -46,7 +46,7 @@ typedef enum dm_event_type dm_event_type_e;
 
 struct dm_event {
 	const void* service;
-	long serviceId;
+	unsigned long serviceId;
 	long ranking;
 	service_reference_pt reference;
 	bundle_context_pt context;

http://git-wip-us.apache.org/repos/asf/celix/blob/652741c9/dependency_manager/private/src/dm_event.c
----------------------------------------------------------------------
diff --git a/dependency_manager/private/src/dm_event.c b/dependency_manager/private/src/dm_event.c
index e30720d..9341832 100644
--- a/dependency_manager/private/src/dm_event.c
+++ b/dependency_manager/private/src/dm_event.c
@@ -41,7 +41,7 @@ celix_status_t event_create(dm_event_type_e event_type, bundle_pt bundle,
bundle
 
 	const char* serviceIdStr = NULL;
 	serviceReference_getProperty(reference, OSGI_FRAMEWORK_SERVICE_ID, &serviceIdStr);
-	long servId = atol(serviceIdStr);
+	unsigned long servId = strtoul(serviceIdStr,NULL,10);
 
 	//FIXME service ranking can dynamicly change, but service reference can be removed at any
time.
 	const char* rankingStr = NULL;

http://git-wip-us.apache.org/repos/asf/celix/blob/652741c9/framework/private/include/service_registration_private.h
----------------------------------------------------------------------
diff --git a/framework/private/include/service_registration_private.h b/framework/private/include/service_registration_private.h
index d6967fb..ca0cb67 100644
--- a/framework/private/include/service_registration_private.h
+++ b/framework/private/include/service_registration_private.h
@@ -38,7 +38,7 @@ struct serviceRegistration {
 	bundle_pt bundle;
 	properties_pt properties;
 	const void * svcObj;
-	long serviceId;
+	unsigned long serviceId;
 
 	bool isUnregistering;
 
@@ -53,8 +53,8 @@ struct serviceRegistration {
 	celix_thread_rwlock_t lock;
 };
 
-service_registration_pt serviceRegistration_create(registry_callback_t callback, bundle_pt
bundle, const char* serviceName, long serviceId, const void * serviceObject, properties_pt
dictionary);
-service_registration_pt serviceRegistration_createServiceFactory(registry_callback_t callback,
bundle_pt bundle, const char* serviceName, long serviceId, const void * serviceObject, properties_pt
dictionary);
+service_registration_pt serviceRegistration_create(registry_callback_t callback, bundle_pt
bundle, const char* serviceName, unsigned long serviceId, const void * serviceObject, properties_pt
dictionary);
+service_registration_pt serviceRegistration_createServiceFactory(registry_callback_t callback,
bundle_pt bundle, const char* serviceName, unsigned long serviceId, const void * serviceObject,
properties_pt dictionary);
 
 void serviceRegistration_retain(service_registration_pt registration);
 void serviceRegistration_release(service_registration_pt registration);

http://git-wip-us.apache.org/repos/asf/celix/blob/652741c9/framework/private/include/service_registry_private.h
----------------------------------------------------------------------
diff --git a/framework/private/include/service_registry_private.h b/framework/private/include/service_registry_private.h
index 8726ff7..d68fe11 100644
--- a/framework/private/include/service_registry_private.h
+++ b/framework/private/include/service_registry_private.h
@@ -36,13 +36,13 @@ struct serviceRegistry {
 	registry_callback_t callback;
 
 	hash_map_pt serviceRegistrations; //key = bundle (reg owner), value = list ( registration
)
-	hash_map_pt serviceReferences; //key = bundle, value = map (key = registration, value =
reference)
+	hash_map_pt serviceReferences; //key = bundle, value = map (key = serviceId, value = reference)
 
 	bool checkDeletedReferences; //If enabled. check if provided service references are still
valid
 	hash_map_pt deletedServiceReferences; //key = ref pointer, value = bool
 
 	serviceChanged_function_pt serviceChanged;
-	long currentServiceId;
+	unsigned long currentServiceId;
 
 	array_list_pt listenerHooks;
 

http://git-wip-us.apache.org/repos/asf/celix/blob/652741c9/framework/private/mock/service_registration_mock.c
----------------------------------------------------------------------
diff --git a/framework/private/mock/service_registration_mock.c b/framework/private/mock/service_registration_mock.c
index d4accbf..934e11b 100644
--- a/framework/private/mock/service_registration_mock.c
+++ b/framework/private/mock/service_registration_mock.c
@@ -28,23 +28,23 @@
 #include "service_registration.h"
 #include "service_registration_private.h"
 
-service_registration_pt serviceRegistration_create(registry_callback_t callback, bundle_pt
bundle, const char* serviceName, long serviceId, const void* serviceObject, properties_pt
dictionary) {
+service_registration_pt serviceRegistration_create(registry_callback_t callback, bundle_pt
bundle, const char* serviceName, unsigned long serviceId, const void* serviceObject, properties_pt
dictionary) {
 	mock_c()->actualCall("serviceRegistration_create")
 		->withParameterOfType("registry_callback_t", "callback", &callback)
 		->withPointerParameters("bundle", bundle)
 		->withStringParameters("serviceName", serviceName)
-		->withIntParameters("serviceId", serviceId)
+		->withUnsignedLongIntParameters("serviceId", serviceId)
 		->withPointerParameters("serviceObject", (void*)serviceObject)
 		->withPointerParameters("dictionary", dictionary);
 	return mock_c()->returnValue().value.pointerValue;
 }
 
-service_registration_pt serviceRegistration_createServiceFactory(registry_callback_t callback,
bundle_pt bundle, const char* serviceName, long serviceId, const void* serviceObject, properties_pt
dictionary) {
+service_registration_pt serviceRegistration_createServiceFactory(registry_callback_t callback,
bundle_pt bundle, const char* serviceName, unsigned long serviceId, const void* serviceObject,
properties_pt dictionary) {
 	mock_c()->actualCall("serviceRegistration_createServiceFactory")
 		->withParameterOfType("registry_callback_t", "callback", &callback)
 		->withPointerParameters("bundle", bundle)
 		->withStringParameters("serviceName", serviceName)
-		->withIntParameters("serviceId", serviceId)
+		->withUnsignedLongIntParameters("serviceId", serviceId)
 		->withPointerParameters("serviceObject", (void*) serviceObject)
 		->withPointerParameters("dictionary", dictionary);
 	return mock_c()->returnValue().value.pointerValue;

http://git-wip-us.apache.org/repos/asf/celix/blob/652741c9/framework/private/src/service_registration.c
----------------------------------------------------------------------
diff --git a/framework/private/src/service_registration.c b/framework/private/src/service_registration.c
index f805860..e2932f9 100644
--- a/framework/private/src/service_registration.c
+++ b/framework/private/src/service_registration.c
@@ -32,23 +32,23 @@
 #include "constants.h"
 
 static celix_status_t serviceRegistration_initializeProperties(service_registration_pt registration,
properties_pt properties);
-static celix_status_t serviceRegistration_createInternal(registry_callback_t callback, bundle_pt
bundle, const char* serviceName, long serviceId,
+static celix_status_t serviceRegistration_createInternal(registry_callback_t callback, bundle_pt
bundle, const char* serviceName, unsigned long serviceId,
         const void * serviceObject, properties_pt dictionary, bool isFactory, service_registration_pt
*registration);
 static celix_status_t serviceRegistration_destroy(service_registration_pt registration);
 
-service_registration_pt serviceRegistration_create(registry_callback_t callback, bundle_pt
bundle, const char* serviceName, long serviceId, const void * serviceObject, properties_pt
dictionary) {
+service_registration_pt serviceRegistration_create(registry_callback_t callback, bundle_pt
bundle, const char* serviceName, unsigned long serviceId, const void * serviceObject, properties_pt
dictionary) {
     service_registration_pt registration = NULL;
 	serviceRegistration_createInternal(callback, bundle, serviceName, serviceId, serviceObject,
dictionary, false, &registration);
 	return registration;
 }
 
-service_registration_pt serviceRegistration_createServiceFactory(registry_callback_t callback,
bundle_pt bundle, const char* serviceName, long serviceId, const void * serviceObject, properties_pt
dictionary) {
+service_registration_pt serviceRegistration_createServiceFactory(registry_callback_t callback,
bundle_pt bundle, const char* serviceName, unsigned long serviceId, const void * serviceObject,
properties_pt dictionary) {
     service_registration_pt registration = NULL;
     serviceRegistration_createInternal(callback, bundle, serviceName, serviceId, serviceObject,
dictionary, true, &registration);
     return registration;
 }
 
-static celix_status_t serviceRegistration_createInternal(registry_callback_t callback, bundle_pt
bundle, const char* serviceName, long serviceId,
+static celix_status_t serviceRegistration_createInternal(registry_callback_t callback, bundle_pt
bundle, const char* serviceName, unsigned long serviceId,
         const void * serviceObject, properties_pt dictionary, bool isFactory, service_registration_pt
*out) {
     celix_status_t status = CELIX_SUCCESS;
 
@@ -128,7 +128,7 @@ static celix_status_t serviceRegistration_initializeProperties(service_registrat
 	}
 
 
-	snprintf(sId, 32, "%ld", registration->serviceId);
+	snprintf(sId, 32, "%lu", registration->serviceId);
 	properties_set(dictionary, (char *) OSGI_FRAMEWORK_SERVICE_ID, sId);
 
 	if (properties_get(dictionary, (char *) OSGI_FRAMEWORK_OBJECTCLASS) == NULL) {

http://git-wip-us.apache.org/repos/asf/celix/blob/652741c9/framework/private/src/service_registry.c
----------------------------------------------------------------------
diff --git a/framework/private/src/service_registry.c b/framework/private/src/service_registry.c
index 49f0638..139ee70 100644
--- a/framework/private/src/service_registry.c
+++ b/framework/private/src/service_registry.c
@@ -71,7 +71,7 @@ celix_status_t serviceRegistry_create(framework_pt framework, serviceChanged_fun
         reg->serviceChanged = serviceChanged;
 		reg->serviceRegistrations = hashMap_create(NULL, NULL, NULL, NULL);
 		reg->framework = framework;
-		reg->currentServiceId = 1l;
+		reg->currentServiceId = 1UL;
 		reg->serviceReferences = hashMap_create(NULL, NULL, NULL, NULL);
 
         reg->checkDeletedReferences = CHECK_DELETED_REFERENCES;
@@ -218,7 +218,7 @@ celix_status_t serviceRegistry_unregisterService(service_registry_pt registry,
b
     while (hashMapIterator_hasNext(iter)) {
         hash_map_pt refsMap = hashMapIterator_nextValue(iter);
         service_reference_pt ref = refsMap != NULL ?
-                                   hashMap_get(refsMap, registration) : NULL;
+                                   hashMap_get(refsMap, (void*)registration->serviceId)
: NULL;
         if (ref != NULL) {
             serviceReference_invalidate(ref);
         }
@@ -302,7 +302,7 @@ static celix_status_t serviceRegistry_getServiceReference_internal(service_regis
         hashMap_put(registry->serviceReferences, owner, references);
 	}
 
-    ref = hashMap_get(references, registration);
+    ref = hashMap_get(references, (void*)registration->serviceId);
 
     if (ref == NULL) {
         status = serviceRegistration_getBundle(registration, &bundle);
@@ -310,7 +310,7 @@ static celix_status_t serviceRegistry_getServiceReference_internal(service_regis
             status = serviceReference_create(registry->callback, owner, registration,
&ref);
         }
         if (status == CELIX_SUCCESS) {
-            hashMap_put(references, registration, ref);
+            hashMap_put(references, (void*)registration->serviceId, ref);
             hashMap_put(registry->deletedServiceReferences, ref, (void *)false);
         }
     } else {
@@ -453,25 +453,25 @@ celix_status_t serviceRegistry_ungetServiceReference(service_registry_pt
registr
 
             hash_map_pt refsMap = hashMap_get(registry->serviceReferences, bundle);
 
-            service_registration_pt reg = NULL;
+            unsigned long reg = 0UL;
             service_reference_pt ref = NULL;
             hash_map_iterator_pt iter = hashMapIterator_create(refsMap);
             while (hashMapIterator_hasNext(iter)) {
                 hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
-                reg = hashMapEntry_getKey(entry); //note could be invalid e.g. freed
+                reg = (unsigned long)hashMapEntry_getKey(entry); //note could be invalid
e.g. freed
                 ref = hashMapEntry_getValue(entry);
 
                 if (ref == reference) {
                     break;
                 } else {
                     ref = NULL;
-                    reg = NULL;
+                    reg = 0UL;
                 }
             }
             hashMapIterator_destroy(iter);
 
             if (ref != NULL) {
-                hashMap_remove(refsMap, reg);
+                hashMap_remove(refsMap, (void*)reg);
                 int size = hashMap_size(refsMap);
                 if (size == 0) {
                     hashMap_destroy(refsMap, false, false);
@@ -771,7 +771,7 @@ static celix_status_t serviceRegistry_getUsingBundles(service_registry_pt
regist
             hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
             bundle_pt registrationUser = hashMapEntry_getKey(entry);
             hash_map_pt regMap = hashMapEntry_getValue(entry);
-            if (hashMap_containsKey(regMap, registration)) {
+            if (hashMap_containsKey(regMap, (void*)registration->serviceId)) {
                 arrayList_add(bundles, registrationUser);
             }
         }

http://git-wip-us.apache.org/repos/asf/celix/blob/652741c9/framework/private/src/utils.c
----------------------------------------------------------------------
diff --git a/framework/private/src/utils.c b/framework/private/src/utils.c
index 1386046..9fc5335 100644
--- a/framework/private/src/utils.c
+++ b/framework/private/src/utils.c
@@ -127,7 +127,7 @@ celix_status_t utils_isNumeric(const char *number, bool *ret) {
 }
 
 
-FRAMEWORK_EXPORT int utils_compareServiceIdsAndRanking(long servId, long servRank, long otherServId,
long otherServRank) {
+FRAMEWORK_EXPORT int utils_compareServiceIdsAndRanking(unsigned long servId, long servRank,
unsigned long otherServId, long otherServRank) {
 	int result;
 
 	if (servId == otherServId) {

http://git-wip-us.apache.org/repos/asf/celix/blob/652741c9/framework/private/test/service_registration_test.cpp
----------------------------------------------------------------------
diff --git a/framework/private/test/service_registration_test.cpp b/framework/private/test/service_registration_test.cpp
index 9e670de..4f37c2f 100644
--- a/framework/private/test/service_registration_test.cpp
+++ b/framework/private/test/service_registration_test.cpp
@@ -100,7 +100,7 @@ TEST(service_registration, create) {
 	callback.handle = registry;
 	char * name = my_strdup("sevice_name");
 	bundle_pt bundle = (bundle_pt) 0x20;
-	long serviceId = 1l;
+	unsigned long serviceId = 1UL;
 	void *service = (void *) 0x30;
 
 	service_registration_pt registration = serviceRegistration_create(callback, bundle, name,
serviceId, service, NULL);
@@ -108,7 +108,8 @@ TEST(service_registration, create) {
 	STRCMP_EQUAL(name, registration->className);
 	POINTERS_EQUAL(bundle, registration->bundle);
 	POINTERS_EQUAL(service, registration->svcObj);
-	LONGS_EQUAL(serviceId, registration->serviceId);
+	UNSIGNED_LONGS_EQUAL(serviceId, registration->serviceId);
+
 	LONGS_EQUAL(0, registration->isUnregistering);
 	LONGS_EQUAL(0, registration->isServiceFactory);
 	POINTERS_EQUAL(NULL, registration->serviceFactory);
@@ -132,7 +133,7 @@ TEST(service_registration, createServiceFactory) {
 	callback.handle = registry;
 	char * name = my_strdup("sevice_name");
 	bundle_pt bundle = (bundle_pt) 0x20;
-	long serviceId = 1l;
+	unsigned long serviceId = 1UL;
 	void *service = (void *) 0x30;
 
 	service_registration_pt registration = serviceRegistration_createServiceFactory(callback,
bundle, name, serviceId, service, NULL);
@@ -140,7 +141,7 @@ TEST(service_registration, createServiceFactory) {
 	STRCMP_EQUAL(name, registration->className);
 	POINTERS_EQUAL(bundle, registration->bundle);
 	POINTERS_EQUAL(service, registration->svcObj);
-	LONGS_EQUAL(serviceId, registration->serviceId);
+	UNSIGNED_LONGS_EQUAL(serviceId, registration->serviceId);
 	LONGS_EQUAL(0, registration->isUnregistering);
 	LONGS_EQUAL(1, registration->isServiceFactory);
 	POINTERS_EQUAL(service, registration->serviceFactory);

http://git-wip-us.apache.org/repos/asf/celix/blob/652741c9/framework/private/test/service_registry_test.cpp
----------------------------------------------------------------------
diff --git a/framework/private/test/service_registry_test.cpp b/framework/private/test/service_registry_test.cpp
index 8bf8b0a..05229a9 100644
--- a/framework/private/test/service_registry_test.cpp
+++ b/framework/private/test/service_registry_test.cpp
@@ -38,6 +38,7 @@ extern "C" {
 #include "listener_hook_service.h"
 #include "service_registry.h"
 #include "service_registry_private.h"
+#include "service_registration_private.h"
 #include "celix_log.h"
 
 framework_logger_pt logger = (framework_logger_pt) 0x42;
@@ -112,7 +113,7 @@ TEST(service_registry, create) {
 
 	POINTERS_EQUAL(framework, registry->framework);
 	POINTERS_EQUAL(serviceRegistryTest_serviceChanged, registry->serviceChanged);
-	LONGS_EQUAL(1l, registry->currentServiceId);
+	UNSIGNED_LONGS_EQUAL(1UL, registry->currentServiceId);
 	CHECK(registry->listenerHooks != NULL);
 	CHECK(registry->serviceReferences != NULL);
 	CHECK(registry->serviceRegistrations != NULL);
@@ -126,14 +127,15 @@ TEST(service_registry, getRegisteredServices) {
 	serviceRegistry_create(framework,serviceRegistryTest_serviceChanged, &registry);
 	array_list_pt registrations = NULL;
 	arrayList_create(&registrations);
-	service_registration_pt reg = (service_registration_pt) 0x10;
+	service_registration_pt reg = (service_registration_pt) calloc(1,sizeof(struct serviceRegistration));
+	reg->serviceId = 10UL;
 	arrayList_add(registrations, reg);
 	bundle_pt bundle = (bundle_pt) 0x20;
 	hashMap_put(registry->serviceRegistrations, bundle, registrations);
 
 	hash_map_pt usages = hashMap_create(NULL, NULL, NULL, NULL);
 	service_reference_pt ref = (service_reference_pt) 0x30;
-	hashMap_put(usages, reg, ref);
+	hashMap_put(usages, (void*)reg->serviceId, ref);
 	hashMap_put(registry->serviceReferences, bundle, usages);
 
 	mock()
@@ -153,6 +155,7 @@ TEST(service_registry, getRegisteredServices) {
 	arrayList_destroy(registrations);
 	hashMap_remove(registry->serviceRegistrations, bundle);
 	serviceRegistry_destroy(registry);
+	free(reg);
 	hashMap_destroy(usages, false, false);
 }
 
@@ -297,7 +300,8 @@ TEST(service_registry, unregisterService) {
 	framework_pt framework = (framework_pt) 0x01;
 	serviceRegistry_create(framework,serviceRegistryTest_serviceChanged, &registry);
 	bundle_pt bundle = (bundle_pt) 0x10;
-	service_registration_pt registration = (service_registration_pt) 0x20;
+	service_registration_pt registration = (service_registration_pt) calloc(1,sizeof(struct
serviceRegistration));
+	registration->serviceId = 20UL;
 
 	array_list_pt registrations = NULL;
 	arrayList_create(&registrations);
@@ -306,7 +310,7 @@ TEST(service_registry, unregisterService) {
 	service_reference_pt reference = (service_reference_pt) 0x30;
 	hash_map_pt references = hashMap_create(NULL, NULL, NULL, NULL);
 
-	hashMap_put(references, registration, reference);
+	hashMap_put(references, (void*)registration->serviceId, reference);
 	hashMap_put(registry->serviceReferences, bundle, references);
 	properties_pt properties = (properties_pt) 0x40;
 
@@ -343,6 +347,7 @@ TEST(service_registry, unregisterService) {
 
 	serviceRegistry_unregisterService(registry, bundle, registration);
 	hashMap_destroy(references, false,false);
+	free(registration);
 	serviceRegistry_destroy(registry);
 }
 
@@ -408,11 +413,12 @@ TEST(service_registry, getServiceReference){
 	serviceRegistry_create(framework,serviceRegistryTest_serviceChanged, &registry);
 
 	bundle_pt bundle = (bundle_pt) 0x10;
-	service_registration_pt registration = (service_registration_pt) 0x20;
+	service_registration_pt registration = (service_registration_pt) calloc(1,sizeof(struct
serviceRegistration));
+	registration->serviceId = 20UL;
 	service_reference_pt reference = (service_reference_pt) 0x50;
 
 	hash_map_pt references = hashMap_create(NULL, NULL, NULL, NULL);
-	hashMap_put(references, registration, reference);
+	hashMap_put(references, (void*)registration->serviceId, reference);
 	hashMap_put(registry->serviceReferences, bundle, references);
 
 	mock().expectOneCall("serviceReference_retain")
@@ -424,6 +430,7 @@ TEST(service_registry, getServiceReference){
 	POINTERS_EQUAL(reference, get_reference);
 
 	hashMap_destroy(references, false, false);
+	free(registration);
 	serviceRegistry_destroy(registry);
 }
 
@@ -433,7 +440,8 @@ TEST(service_registry, getServiceReference_unknownRef){
 	serviceRegistry_create(framework,serviceRegistryTest_serviceChanged, &registry);
 
 	bundle_pt bundle = (bundle_pt) 0x10;
-	service_registration_pt registration = (service_registration_pt) 0x20;
+	service_registration_pt registration = (service_registration_pt) calloc(1,sizeof(struct
serviceRegistration));
+	registration->serviceId = 20UL;
 	service_reference_pt reference = (service_reference_pt) 0x50;
 
 	//test getting ref from bundle without refs
@@ -456,6 +464,7 @@ TEST(service_registry, getServiceReference_unknownRef){
 	//cleanup
 	hash_map_pt del = (hash_map_pt) hashMap_remove(registry->serviceReferences, bundle);
 	hashMap_destroy(del, false, false);
+	free(registration);
 	serviceRegistry_destroy(registry);
 }
 
@@ -465,7 +474,9 @@ TEST(service_registry, getServiceReferences) {
 	serviceRegistry_create(framework,serviceRegistryTest_serviceChanged, &registry);
 
 	bundle_pt bundle = (bundle_pt) 0x10;
-	service_registration_pt registration = (service_registration_pt) 0x20;
+	service_registration_pt registration = (service_registration_pt) calloc(1,sizeof(struct
serviceRegistration));
+	registration->serviceId = 20UL;
+
 	array_list_pt registrations = NULL;
 	arrayList_create(&registrations);
 	arrayList_add(registrations, registration);
@@ -476,7 +487,7 @@ TEST(service_registry, getServiceReferences) {
 
 	hash_map_pt references = hashMap_create(NULL, NULL, NULL, NULL);
 	service_reference_pt reference = (service_reference_pt) 0x50;
-	hashMap_put(references, registration, reference);
+	hashMap_put(references, (void*)registration->serviceId, reference);
 	hashMap_put(registry->serviceReferences, bundle, references);
 
 	mock()
@@ -522,6 +533,7 @@ TEST(service_registry, getServiceReferences) {
 	arrayList_destroy(actual);
 	arrayList_destroy(registrations);
 	hashMap_remove(registry->serviceRegistrations, bundle);
+	free(registration);
 	serviceRegistry_destroy(registry);
 }
 
@@ -531,7 +543,9 @@ TEST(service_registry, getServiceReferences_noFilterOrName) {
 	serviceRegistry_create(framework,serviceRegistryTest_serviceChanged, &registry);
 
 	bundle_pt bundle = (bundle_pt) 0x10;
-	service_registration_pt registration = (service_registration_pt) 0x20;
+	service_registration_pt registration = (service_registration_pt) calloc(1,sizeof(struct
serviceRegistration));
+	registration->serviceId = 20UL;
+
 	array_list_pt registrations = NULL;
 	arrayList_create(&registrations);
 	arrayList_add(registrations, registration);
@@ -541,7 +555,7 @@ TEST(service_registry, getServiceReferences_noFilterOrName) {
 
 	hash_map_pt references = hashMap_create(NULL, NULL, NULL, NULL);
 	service_reference_pt reference = (service_reference_pt) 0x50;
-	hashMap_put(references, registration, reference);
+	hashMap_put(references, (void*)registration->serviceId, reference);
 	hashMap_put(registry->serviceReferences, bundle, references);
 
 	mock()
@@ -576,6 +590,7 @@ TEST(service_registry, getServiceReferences_noFilterOrName) {
 	arrayList_destroy(actual);
 	arrayList_destroy(registrations);
 	hashMap_remove(registry->serviceRegistrations, bundle);
+	free(registration);
 	serviceRegistry_destroy(registry);
 }
 
@@ -937,12 +952,13 @@ TEST(service_registry, getListenerHooks) {
 	framework_pt framework = (framework_pt) 0x01;
 	serviceRegistry_create(framework,serviceRegistryTest_serviceChanged, &registry);
 	bundle_pt bundle = (bundle_pt) 0x10;
-	service_registration_pt registration = (service_registration_pt) 0x20;
+	service_registration_pt registration = (service_registration_pt) calloc(1,sizeof(struct
serviceRegistration));
+	registration->serviceId = 20UL;
 	arrayList_add(registry->listenerHooks, registration);
 
 	hash_map_pt usages = hashMap_create(NULL, NULL, NULL, NULL);
 	service_reference_pt reference = (service_reference_pt) 0x30;
-	hashMap_put(usages, registration, reference);
+	hashMap_put(usages, (void*)registration->serviceId, reference);
 	hashMap_put(registry->serviceReferences, bundle, usages);
 
 	mock()
@@ -963,6 +979,7 @@ TEST(service_registry, getListenerHooks) {
 	hashMap_destroy(usages, false, false);
 	arrayList_destroy(hooks);
 	arrayList_remove(registry->listenerHooks, 0);
+	free(registration);
 	serviceRegistry_destroy(registry);
 }
 
@@ -989,10 +1006,16 @@ TEST(service_registry, getUsingBundles) {
 	framework_pt framework = (framework_pt) 0x01;
 	serviceRegistry_create(framework,serviceRegistryTest_serviceChanged, &registry);
 
-	service_registration_pt registration = (service_registration_pt) 0x10;
-	service_registration_pt registration2 = (service_registration_pt) 0x20;
-	service_registration_pt registration3 = (service_registration_pt) 0x30;
-	service_registration_pt registration4 = (service_registration_pt) 0x40;
+	service_registration_pt registration  = (service_registration_pt) calloc(1,sizeof(struct
serviceRegistration));
+	service_registration_pt registration2 = (service_registration_pt) calloc(1,sizeof(struct
serviceRegistration));
+	service_registration_pt registration3 = (service_registration_pt) calloc(1,sizeof(struct
serviceRegistration));
+	service_registration_pt registration4 = (service_registration_pt) calloc(1,sizeof(struct
serviceRegistration));
+
+	registration->serviceId  = 10UL;
+	registration2->serviceId = 20UL;
+	registration3->serviceId = 30UL;
+	registration4->serviceId = 40UL;
+
 	service_reference_pt reference = (service_reference_pt) 0x50;
 	service_reference_pt reference2 = (service_reference_pt) 0x60;
 	service_reference_pt reference3 = (service_reference_pt) 0x70;
@@ -1005,19 +1028,19 @@ TEST(service_registry, getUsingBundles) {
 
 	//only contains registration1
 	hash_map_pt references = hashMap_create(NULL, NULL, NULL, NULL);
-	hashMap_put(references, registration, reference);
+	hashMap_put(references, (void*)registration->serviceId, reference);
 	hashMap_put(registry->serviceReferences, bundle, references);
 
 	//contains registration1 and one other
 	hash_map_pt references2 = hashMap_create(NULL, NULL, NULL, NULL);
-	hashMap_put(references2, registration, reference2);
-	hashMap_put(references2, registration2, reference3);
+	hashMap_put(references2, (void*)registration->serviceId, reference2);
+	hashMap_put(references2, (void*)registration2->serviceId, reference3);
 	hashMap_put(registry->serviceReferences, bundle2, references2);
 
 	//contains 2 registrations, but not registration1
 	hash_map_pt references3 = hashMap_create(NULL, NULL, NULL, NULL);
-	hashMap_put(references3, registration3, reference4);
-	hashMap_put(references3, registration4, reference5);
+	hashMap_put(references3, (void*)registration3->serviceId, reference4);
+	hashMap_put(references3, (void*)registration4->serviceId, reference5);
 	hashMap_put(registry->serviceReferences, bundle3, references3);
 
 	//call to getUsingBundles
@@ -1043,4 +1066,10 @@ TEST(service_registry, getUsingBundles) {
 	hashMap_destroy(references2, false, false);
 	hashMap_destroy(references3, false, false);
 	serviceRegistry_destroy(registry);
+
+   free(registration);
+   free(registration2);
+   free(registration3);
+   free(registration4);
+
 }

http://git-wip-us.apache.org/repos/asf/celix/blob/652741c9/framework/public/include/utils.h
----------------------------------------------------------------------
diff --git a/framework/public/include/utils.h b/framework/public/include/utils.h
index bd04067..108bbdd 100644
--- a/framework/public/include/utils.h
+++ b/framework/public/include/utils.h
@@ -40,7 +40,7 @@ FRAMEWORK_EXPORT char * string_ndup(const char *s, size_t n);
 FRAMEWORK_EXPORT char * utils_stringTrim(char * string);
 FRAMEWORK_EXPORT bool utils_isStringEmptyOrNull(const char * const str);
 
-FRAMEWORK_EXPORT int utils_compareServiceIdsAndRanking(long servId, long servRank, long otherServId,
long otherServRank);
+FRAMEWORK_EXPORT int utils_compareServiceIdsAndRanking(unsigned long servId, long servRank,
unsigned long otherServId, long otherServRank);
 
 FRAMEWORK_EXPORT celix_status_t thread_equalsSelf(celix_thread_t thread, bool *equals);
 

http://git-wip-us.apache.org/repos/asf/celix/blob/652741c9/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 cd13dc0..d8139bc 100644
--- a/remote_services/discovery/private/src/endpoint_descriptor_reader.c
+++ b/remote_services/discovery/private/src/endpoint_descriptor_reader.c
@@ -358,7 +358,7 @@ int main() {
 		printf("\nEndpoint description #%d:\n", (i+1));
 		endpoint_description_pt edp = arrayList_get(list, i);
 		printf("Id: %s\n", edp->id);
-		printf("Service Id: %ld\n", edp->serviceId);
+		printf("Service Id: %lu\n", edp->serviceId);
 		printf("Framework UUID: %s\n", edp->frameworkUUID);
 		printf("Service: %s\n", edp->service);
 

http://git-wip-us.apache.org/repos/asf/celix/blob/652741c9/remote_services/remote_service_admin/private/src/endpoint_description.c
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin/private/src/endpoint_description.c b/remote_services/remote_service_admin/private/src/endpoint_description.c
index c11eb0d..0d8b684 100644
--- a/remote_services/remote_service_admin/private/src/endpoint_description.c
+++ b/remote_services/remote_service_admin/private/src/endpoint_description.c
@@ -33,12 +33,12 @@
 #include "remote_constants.h"
 #include "constants.h"
 
-static celix_status_t endpointDescription_verifyLongProperty(properties_pt properties, char
*propertyName, long *longProperty);
+static celix_status_t endpointDescription_verifyLongProperty(properties_pt properties, char
*propertyName, unsigned long *longProperty);
 
 celix_status_t endpointDescription_create(properties_pt properties, endpoint_description_pt
*endpointDescription) {
 	celix_status_t status = CELIX_SUCCESS;
 
-	long serviceId = 0L;
+	unsigned long serviceId = 0UL;
 	status = endpointDescription_verifyLongProperty(properties, (char *) OSGI_RSA_ENDPOINT_SERVICE_ID,
&serviceId);
 	if (status != CELIX_SUCCESS) {
 		return status;
@@ -75,14 +75,14 @@ celix_status_t endpointDescription_destroy(endpoint_description_pt description)
     return CELIX_SUCCESS;
 }
 
-static celix_status_t endpointDescription_verifyLongProperty(properties_pt properties, char
*propertyName, long *longProperty) {
+static celix_status_t endpointDescription_verifyLongProperty(properties_pt properties, char
*propertyName, unsigned long *longProperty) {
     celix_status_t status = CELIX_SUCCESS;
 
     const char *value = properties_get(properties, propertyName);
     if (value == NULL) {
-        *longProperty = 0l;
+        *longProperty = 0UL;
     } else {
-        *longProperty = atol(value);
+        *longProperty = strtoul(value,NULL,10);
     }
 
     return status;

http://git-wip-us.apache.org/repos/asf/celix/blob/652741c9/remote_services/remote_service_admin/public/include/endpoint_description.h
----------------------------------------------------------------------
diff --git a/remote_services/remote_service_admin/public/include/endpoint_description.h b/remote_services/remote_service_admin/public/include/endpoint_description.h
index a028776..de27d2e 100644
--- a/remote_services/remote_service_admin/public/include/endpoint_description.h
+++ b/remote_services/remote_service_admin/public/include/endpoint_description.h
@@ -37,7 +37,7 @@ struct endpoint_description {
     char *service;
     // HASH_MAP packageVersions;
     properties_pt properties;
-    long serviceId;
+    unsigned long serviceId;
 };
 
 typedef struct endpoint_description endpoint_description_t;

http://git-wip-us.apache.org/repos/asf/celix/blob/652741c9/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 745aa2e..9feab9f 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
@@ -313,7 +313,7 @@ static int remoteServiceAdmin_callback(struct mg_connection *conn) {
             char service[pos+1];
             strncpy(service, rest, pos);
             service[pos] = '\0';
-            long serviceId = atol(service);
+            unsigned long serviceId = strtoul(service,NULL,10);
 
             celixThreadMutex_lock(&rsa->exportedServicesLock);
 
@@ -366,7 +366,7 @@ static int remoteServiceAdmin_callback(struct mg_connection *conn) {
                 free(data);
             } else {
                 result = 0;
-                RSA_LOG_WARNING(rsa, "NO export registration found for service id %i", serviceId);
+                RSA_LOG_WARNING(rsa, "NO export registration found for service id %lu", serviceId);
             }
 
             celixThreadMutex_unlock(&rsa->exportedServicesLock);

http://git-wip-us.apache.org/repos/asf/celix/blob/652741c9/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 f73d094..0b05c1f 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
@@ -321,7 +321,7 @@ static int remoteServiceAdmin_callback(struct mg_connection *conn) {
 				int expIt = 0;
 				for (expIt = 0; expIt < arrayList_size(exports); expIt++) {
 					export_registration_pt export = arrayList_get(exports, expIt);
-					long serviceId = atol(service);
+					unsigned long serviceId = strtoul(service,NULL,10);
 					if (serviceId == export->endpointDescription->serviceId && export->endpoint
!= NULL) {
 						uint64_t datalength = request_info->content_length;
 						char* data = malloc(datalength + 1);


Mime
View raw message