Repository: celix Updated Branches: refs/heads/develop 13af678fe -> 2cd57a789
CELIX-249: Refactors usage of char** output for properties to const char**. This is a backwards incompatible change, resulting in a lot a small changes. Project: http://git-wip-us.apache.org/repos/asf/celix/repo Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/2cd57a78 Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/2cd57a78 Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/2cd57a78 Branch: refs/heads/develop Commit: 2cd57a7891d7f0b2eaaee711a3fbd0c1b1462dd9 Parents: 13af678 Author: Pepijn Noltes <[email protected]> Authored: Tue Jul 5 21:36:46 2016 +0200 Committer: Pepijn Noltes <[email protected]> Committed: Tue Jul 5 21:36:46 2016 +0200 ---------------------------------------------------------------------- .../private/src/managed_service_tracker.c | 12 ++--- dependency_manager/private/src/dm_event.c | 8 ++-- .../private/src/dm_service_dependency.c | 2 +- deployment_admin/private/src/deployment_admin.c | 8 ++-- .../device_access/private/src/device_manager.c | 10 ++-- .../private/src/driver_attributes.c | 8 ++-- .../device_access/private/src/driver_matcher.c | 14 +++--- .../driver_locator/private/src/activator.c | 2 +- .../private/src/consuming_driver.c | 2 +- .../private/src/refining_driver.c | 2 +- framework/private/include/framework_private.h | 2 +- framework/private/mock/bundle_context_mock.c | 2 +- framework/private/mock/framework_mock.c | 2 +- framework/private/mock/service_reference_mock.c | 2 +- framework/private/src/bundle_context.c | 2 +- framework/private/src/framework.c | 4 +- framework/private/src/service_reference.c | 12 +++-- framework/private/src/utils.c | 16 +++++-- framework/private/test/bundle_context_test.cpp | 2 +- .../private/test/service_reference_test.cpp | 2 +- framework/public/include/bundle_context.h | 2 +- framework/public/include/service_reference.h | 2 +- log_service/private/src/log_service_activator.c | 4 +- log_service/public/src/log_helper.c | 2 +- .../discovery/private/src/discovery.c | 14 +++--- .../discovery/private/src/discovery_activator.c | 2 +- .../private/src/endpoint_discovery_poller.c | 12 ++--- .../private/src/endpoint_discovery_server.c | 19 ++++---- .../discovery_etcd/private/src/discovery_impl.c | 5 +- .../discovery_etcd/private/src/etcd_watcher.c | 16 +++---- .../private/src/discovery_shmWatcher.c | 2 +- .../private/src/export_registration_impl.c | 2 +- .../private/src/import_registration_impl.c | 2 +- .../rsa/private/src/dfi_utils.c | 2 +- .../rsa/private/src/export_registration_dfi.c | 4 +- .../rsa/private/src/remote_service_admin_dfi.c | 26 +++++----- .../rsa_tst/rsa_tests.cpp | 4 +- .../private/src/remote_service_admin_impl.c | 38 ++++++++------- .../private/src/remote_service_admin_impl.c | 27 ++++++----- .../topology_manager/private/src/activator.c | 10 ++-- .../topology_manager/private/src/scope.c | 2 +- .../private/src/topology_manager.c | 50 ++++++++++---------- .../tms_tst/disc_mock/disc_mock_activator.c | 4 +- remote_shell/private/src/activator.c | 4 +- shell/private/src/inspect_command.c | 4 +- shell/private/src/shell.c | 14 +++--- 46 files changed, 204 insertions(+), 183 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/celix/blob/2cd57a78/config_admin/service/private/src/managed_service_tracker.c ---------------------------------------------------------------------- diff --git a/config_admin/service/private/src/managed_service_tracker.c b/config_admin/service/private/src/managed_service_tracker.c index 1ce5ac1..79f573d 100644 --- a/config_admin/service/private/src/managed_service_tracker.c +++ b/config_admin/service/private/src/managed_service_tracker.c @@ -202,7 +202,7 @@ celix_status_t managedServiceTracker_addingService(void * handle, service_refere celix_status_t status; - char *pid = NULL; + const char* pid = NULL; bundle_context_pt context = NULL; @@ -211,7 +211,7 @@ celix_status_t managedServiceTracker_addingService(void * handle, service_refere // (1) reference.getPid - status = serviceReference_getProperty(reference, (char *) OSGI_FRAMEWORK_SERVICE_PID, &pid); + status = serviceReference_getProperty(reference, OSGI_FRAMEWORK_SERVICE_PID, &pid); if (status != CELIX_SUCCESS || pid == NULL) { *service = NULL; printf(" [ ERROR ]: Tracker - PID is NULL \n"); @@ -255,7 +255,7 @@ celix_status_t managedServiceTracker_addingService(void * handle, service_refere // (3) trackerInstance.AddManagedServiceToLocalList configurationStore_lock(managedServiceTracker_i->configurationStore); - status = managedServiceTracker_add(managedServiceTracker_i, reference, pid, managedService_s); + status = managedServiceTracker_add(managedServiceTracker_i, reference, (char*)pid, managedService_s); if (status != CELIX_SUCCESS) { bundleContext_ungetService(context, reference, NULL); } @@ -281,19 +281,19 @@ celix_status_t managedServiceTracker_modifiedService(void * handle, service_refe celix_status_t managedServiceTracker_removedService(void * handle, service_reference_pt reference, void * service) { celix_status_t status = CELIX_SUCCESS; - char *pid; + const char* pid; managed_service_tracker_pt managedServiceTracker_i = handle; //instance bundle_context_pt context; - status = serviceReference_getProperty(reference, (char *)OSGI_FRAMEWORK_SERVICE_PID, &pid); + status = serviceReference_getProperty(reference, OSGI_FRAMEWORK_SERVICE_PID, &pid); if (status != CELIX_SUCCESS || pid == NULL){ return CELIX_ILLEGAL_ARGUMENT; } if ( managedServiceTracker_getBundleContext(managedServiceTracker_i, &context) != CELIX_SUCCESS ){ return CELIX_ILLEGAL_ARGUMENT; } - status = managedServiceTracker_remove(managedServiceTracker_i, reference, pid); + status = managedServiceTracker_remove(managedServiceTracker_i, reference, (char*)pid); return status; http://git-wip-us.apache.org/repos/asf/celix/blob/2cd57a78/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 491c69f..017bcf5 100644 --- a/dependency_manager/private/src/dm_event.c +++ b/dependency_manager/private/src/dm_event.c @@ -39,13 +39,13 @@ celix_status_t event_create(dm_event_type_e event_type, bundle_pt bundle, bundle status = CELIX_ENOMEM; } - char *serviceIdStr = NULL; - serviceReference_getProperty(reference, (char *)OSGI_FRAMEWORK_SERVICE_ID, &serviceIdStr); + const char* serviceIdStr = NULL; + serviceReference_getProperty(reference, OSGI_FRAMEWORK_SERVICE_ID, &serviceIdStr); long servId = atol(serviceIdStr); //FIXME service ranking can dynamicly change, but service reference can be removed at any time. - char *rankingStr = NULL; - serviceReference_getProperty(reference, (char *)OSGI_FRAMEWORK_SERVICE_RANKING, &rankingStr); + const char* rankingStr = NULL; + serviceReference_getProperty(reference, OSGI_FRAMEWORK_SERVICE_RANKING, &rankingStr); long ranking = rankingStr == NULL ? 0 : atol(rankingStr); if (status == CELIX_SUCCESS) { http://git-wip-us.apache.org/repos/asf/celix/blob/2cd57a78/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 4f63c6d..ca9e8ae 100644 --- a/dependency_manager/private/src/dm_service_dependency.c +++ b/dependency_manager/private/src/dm_service_dependency.c @@ -435,7 +435,7 @@ celix_status_t serviceDependency_invokeSet(dm_service_dependency_pt dependency, /* Find the service with the higest ranking */ for (i = 0; i < arrayList_size(serviceReferences); i++) { service_reference_pt serviceReference = arrayList_get(serviceReferences, i); - char *ranking_value; + const char* ranking_value; int ranking = 0; status = serviceReference_getProperty(serviceReference, ((char *) OSGI_FRAMEWORK_SERVICE_RANKING), &ranking_value); http://git-wip-us.apache.org/repos/asf/celix/blob/2cd57a78/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 4a7245b..1eb58f3 100644 --- a/deployment_admin/private/src/deployment_admin.c +++ b/deployment_admin/private/src/deployment_admin.c @@ -97,7 +97,7 @@ celix_status_t deploymentAdmin_create(bundle_context_pt context, deployment_admi (*admin)->pollUrl = NULL; (*admin)->auditlogUrl = NULL; - bundleContext_getProperty(context, IDENTIFICATION_ID, &(*admin)->targetIdentification); + bundleContext_getProperty(context, IDENTIFICATION_ID, (const char**) &(*admin)->targetIdentification); struct timeval tv; gettimeofday(&tv,NULL); @@ -108,7 +108,7 @@ celix_status_t deploymentAdmin_create(bundle_context_pt context, deployment_admi fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Target name must be set using \"deployment_admin_identification\""); status = CELIX_ILLEGAL_ARGUMENT; } else { - char *url = NULL; + const char *url = NULL; bundleContext_getProperty(context, DISCOVERY_URL, &url); if (url == NULL) { fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "URL must be set using \"deployment_admin_url\"\n"); @@ -211,7 +211,7 @@ static celix_status_t deploymentAdmin_performRequest(deployment_admin_pt admin, static celix_status_t deploymentAdmin_auditEventTargetPropertiesSet(deployment_admin_pt admin) { celix_status_t status = CELIX_SUCCESS; - char *tags = NULL; + const char *tags = NULL; bundleContext_getProperty(admin->context, DEPLOYMENT_TAGS, &tags); @@ -433,7 +433,7 @@ celix_status_t deploymentAdmin_download(deployment_admin_pt admin, char * url, c CURLcode res = 0; curl = curl_easy_init(); if (curl) { - char *dir = NULL; + const char *dir = NULL; bundleContext_getProperty(admin->context, DEPLOYMENT_CACHE_DIR, &dir); if (dir != NULL) { *inputFile = calloc(1024, sizeof (char)); http://git-wip-us.apache.org/repos/asf/celix/blob/2cd57a78/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 dea4513..bba6be6 100644 --- a/device_access/device_access/private/src/device_manager.c +++ b/device_access/device_access/private/src/device_manager.c @@ -169,8 +169,8 @@ static celix_status_t deviceManager_attachAlgorithm(device_manager_pt manager, s serviceReference_getPropertyKeys(ref, &keys, &size); for (int i = 0; i < size; i++) { - char *key = keys[i]; - char *value = NULL; + char* key = keys[i]; + const char* value = NULL; serviceReference_getProperty(ref, key, &value); properties_set(properties, key, value); } @@ -307,7 +307,7 @@ celix_status_t deviceManager_matchAttachDriver(device_manager_pt manager, driver celix_status_t deviceManager_noDriverFound(device_manager_pt manager, void *service, service_reference_pt reference) { celix_status_t status = CELIX_SUCCESS; - char *objectClass = NULL; + const char* objectClass = NULL; serviceReference_getProperty(reference, (char *) OSGI_FRAMEWORK_OBJECTCLASS, &objectClass); if (strcmp(objectClass, OSGI_DEVICEACCESS_DRIVER_SERVICE_NAME) == 0) { device_service_pt device = service; @@ -541,8 +541,8 @@ celix_status_t deviceManager_isDriverBundle(device_manager_pt manager, bundle_pt int i; for (i = 0; i < arrayList_size(refs); i++) { service_reference_pt ref = arrayList_get(refs, i); - char *object = NULL; - serviceReference_getProperty(ref, (char *) OSGI_FRAMEWORK_OBJECTCLASS, &object); + const char* object = NULL; + serviceReference_getProperty(ref, OSGI_FRAMEWORK_OBJECTCLASS, &object); if (strcmp(object, "driver") == 0) { *isDriver = true; break; http://git-wip-us.apache.org/repos/asf/celix/blob/2cd57a78/device_access/device_access/private/src/driver_attributes.c ---------------------------------------------------------------------- diff --git a/device_access/device_access/private/src/driver_attributes.c b/device_access/device_access/private/src/driver_attributes.c index 5da996d..db28e03 100644 --- a/device_access/device_access/private/src/driver_attributes.c +++ b/device_access/device_access/private/src/driver_attributes.c @@ -88,7 +88,7 @@ celix_status_t driverAttributes_getReference(driver_attributes_pt driverAttribut celix_status_t driverAttributes_getDriverId(driver_attributes_pt driverAttributes, char **driverId) { celix_status_t status = CELIX_SUCCESS; - char *id_prop = NULL; + const char* id_prop = NULL; status = serviceReference_getProperty(driverAttributes->reference, "DRIVER_ID", &id_prop); if (status == CELIX_SUCCESS) { if (!id_prop) { @@ -125,11 +125,11 @@ celix_status_t driverAttributes_isInUse(driver_attributes_pt driverAttributes, b int i; for (i = 0; i < arrayList_size(references); i++) { service_reference_pt ref = arrayList_get(references, i); - char *object = NULL; - status = serviceReference_getProperty(ref, (char *) OSGI_FRAMEWORK_OBJECTCLASS, &object); + const char *object = NULL; + status = serviceReference_getProperty(ref, OSGI_FRAMEWORK_OBJECTCLASS, &object); if (status == CELIX_SUCCESS) { - char *category = NULL; + const char* category = NULL; status = serviceReference_getProperty(ref, "DEVICE_CATEGORY", &category); if (status == CELIX_SUCCESS) { http://git-wip-us.apache.org/repos/asf/celix/blob/2cd57a78/device_access/device_access/private/src/driver_matcher.c ---------------------------------------------------------------------- diff --git a/device_access/device_access/private/src/driver_matcher.c b/device_access/device_access/private/src/driver_matcher.c index 98ad69b..f36cd4a 100644 --- a/device_access/device_access/private/src/driver_matcher.c +++ b/device_access/device_access/private/src/driver_matcher.c @@ -215,7 +215,8 @@ celix_status_t driverMatcher_getBestMatchInternal(driver_matcher_pt matcher, mat celix_status_t substatus = driverAttributes_getReference(attributes, &reference); if (substatus == CELIX_SUCCESS) { if (best != NULL) { - char *rank1Str, *rank2Str; + const char* rank1Str; + const char* rank2Str; int rank1, rank2; rank1Str = "0"; @@ -223,8 +224,8 @@ celix_status_t driverMatcher_getBestMatchInternal(driver_matcher_pt matcher, mat logHelper_log(matcher->loghelper, OSGI_LOGSERVICE_DEBUG, "DRIVER_MATCHER: Compare ranking"); - serviceReference_getProperty(reference, (char *) OSGI_FRAMEWORK_SERVICE_RANKING, &rank1Str); - serviceReference_getProperty(reference, (char *) OSGI_FRAMEWORK_SERVICE_RANKING, &rank2Str); + serviceReference_getProperty(reference, OSGI_FRAMEWORK_SERVICE_RANKING, &rank1Str); + serviceReference_getProperty(reference, OSGI_FRAMEWORK_SERVICE_RANKING, &rank2Str); rank1 = atoi(rank1Str); rank2 = atoi(rank2Str); @@ -234,7 +235,8 @@ celix_status_t driverMatcher_getBestMatchInternal(driver_matcher_pt matcher, mat best = reference; } } else { - char *id1Str, *id2Str; + const char* id1Str; + const char* id2Str; long id1, id2; id1Str = NULL; @@ -242,8 +244,8 @@ celix_status_t driverMatcher_getBestMatchInternal(driver_matcher_pt matcher, mat logHelper_log(matcher->loghelper, OSGI_LOGSERVICE_DEBUG, "DRIVER_MATCHER: Compare id's"); - serviceReference_getProperty(reference, (char *) OSGI_FRAMEWORK_SERVICE_ID, &id1Str); - serviceReference_getProperty(reference, (char *) OSGI_FRAMEWORK_SERVICE_ID, &id2Str); + serviceReference_getProperty(reference, OSGI_FRAMEWORK_SERVICE_ID, &id1Str); + serviceReference_getProperty(reference, OSGI_FRAMEWORK_SERVICE_ID, &id2Str); id1 = atol(id1Str); id2 = atol(id2Str); http://git-wip-us.apache.org/repos/asf/celix/blob/2cd57a78/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 6c13e10..abc60c5 100644 --- a/device_access/driver_locator/private/src/activator.c +++ b/device_access/driver_locator/private/src/activator.c @@ -61,7 +61,7 @@ celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) bi->service->locator = bi->locator; bi->locator->drivers = NULL; arrayList_create(&bi->locator->drivers); - bundleContext_getProperty(context, "DRIVER_LOCATOR_PATH", &bi->locator->path); + bundleContext_getProperty(context, "DRIVER_LOCATOR_PATH", (const char**)&bi->locator->path); if (bi->locator->path == NULL ) { bi->locator->path = (char *)DEFAULT_LOCATOR_PATH; } http://git-wip-us.apache.org/repos/asf/celix/blob/2cd57a78/device_access/example/consuming_driver/private/src/consuming_driver.c ---------------------------------------------------------------------- diff --git a/device_access/example/consuming_driver/private/src/consuming_driver.c b/device_access/example/consuming_driver/private/src/consuming_driver.c index b44ac32..9106dbd 100644 --- a/device_access/example/consuming_driver/private/src/consuming_driver.c +++ b/device_access/example/consuming_driver/private/src/consuming_driver.c @@ -111,7 +111,7 @@ celix_status_t consumingDriver_match(void *driverHandler, service_reference_pt r int match=0; celix_status_t status = CELIX_SUCCESS; - char *category = NULL; + const char* category = NULL; status = serviceReference_getProperty(reference, OSGI_DEVICEACCESS_DEVICE_CATEGORY, &category); if (status == CELIX_SUCCESS) { if (strcmp(category, REFINING_DRIVER_DEVICE_CATEGORY) == 0) { http://git-wip-us.apache.org/repos/asf/celix/blob/2cd57a78/device_access/example/refining_driver/private/src/refining_driver.c ---------------------------------------------------------------------- diff --git a/device_access/example/refining_driver/private/src/refining_driver.c b/device_access/example/refining_driver/private/src/refining_driver.c index b624e7d..404bc42 100644 --- a/device_access/example/refining_driver/private/src/refining_driver.c +++ b/device_access/example/refining_driver/private/src/refining_driver.c @@ -210,7 +210,7 @@ celix_status_t refiningDriver_match(void *driverHandler, service_reference_pt re int match = 0; celix_status_t status = CELIX_SUCCESS; - char *category = NULL; + const char* category = NULL; status = serviceReference_getProperty(reference, OSGI_DEVICEACCESS_DEVICE_CATEGORY, &category); if (status == CELIX_SUCCESS) { if (strcmp(category, BASE_DRIVER_DEVICE_CATEGORY) == 0) { http://git-wip-us.apache.org/repos/asf/celix/blob/2cd57a78/framework/private/include/framework_private.h ---------------------------------------------------------------------- diff --git a/framework/private/include/framework_private.h b/framework/private/include/framework_private.h index 28c504d..6ed3dec 100644 --- a/framework/private/include/framework_private.h +++ b/framework/private/include/framework_private.h @@ -93,7 +93,7 @@ struct framework { celix_status_t framework_start(framework_pt framework); void framework_stop(framework_pt framework); -FRAMEWORK_EXPORT celix_status_t fw_getProperty(framework_pt framework, const char *name, char **value); +FRAMEWORK_EXPORT celix_status_t fw_getProperty(framework_pt framework, const char *name, const char** value); FRAMEWORK_EXPORT celix_status_t fw_installBundle(framework_pt framework, bundle_pt * bundle, char * location, char *inputFile); FRAMEWORK_EXPORT celix_status_t fw_uninstallBundle(framework_pt framework, bundle_pt bundle); http://git-wip-us.apache.org/repos/asf/celix/blob/2cd57a78/framework/private/mock/bundle_context_mock.c ---------------------------------------------------------------------- diff --git a/framework/private/mock/bundle_context_mock.c b/framework/private/mock/bundle_context_mock.c index 3ec6287..f00bade 100644 --- a/framework/private/mock/bundle_context_mock.c +++ b/framework/private/mock/bundle_context_mock.c @@ -185,7 +185,7 @@ celix_status_t bundleContext_removeBundleListener(bundle_context_pt context, bun } -celix_status_t bundleContext_getProperty(bundle_context_pt context, const char *name, char **value) { +celix_status_t bundleContext_getProperty(bundle_context_pt context, const char *name, const char** value) { mock_c()->actualCall("bundleContext_getProperty") ->withPointerParameters("context", context) ->withStringParameters("name", name) http://git-wip-us.apache.org/repos/asf/celix/blob/2cd57a78/framework/private/mock/framework_mock.c ---------------------------------------------------------------------- diff --git a/framework/private/mock/framework_mock.c b/framework/private/mock/framework_mock.c index acd90ad..ab01218 100644 --- a/framework/private/mock/framework_mock.c +++ b/framework/private/mock/framework_mock.c @@ -51,7 +51,7 @@ void framework_stop(framework_pt framework) { mock_c()->actualCall("framework_stop"); } -celix_status_t fw_getProperty(framework_pt framework, const char *name, char **value) { +celix_status_t fw_getProperty(framework_pt framework, const char *name, const char** value) { mock_c()->actualCall("fw_getProperty") ->withPointerParameters("framework", framework) ->withStringParameters("name", name) http://git-wip-us.apache.org/repos/asf/celix/blob/2cd57a78/framework/private/mock/service_reference_mock.c ---------------------------------------------------------------------- diff --git a/framework/private/mock/service_reference_mock.c b/framework/private/mock/service_reference_mock.c index 7bb643f..9d8d4db 100644 --- a/framework/private/mock/service_reference_mock.c +++ b/framework/private/mock/service_reference_mock.c @@ -112,7 +112,7 @@ celix_status_t serviceReference_getServiceRegistration(service_reference_pt refe return mock_c()->returnValue().value.intValue; } -celix_status_t serviceReference_getProperty(service_reference_pt reference, char *key, char **value){ +celix_status_t serviceReference_getProperty(service_reference_pt reference, const char *key, const char** value){ mock_c()->actualCall("serviceReference_getProperty") ->withPointerParameters("reference", reference) ->withStringParameters("key", key) http://git-wip-us.apache.org/repos/asf/celix/blob/2cd57a78/framework/private/src/bundle_context.c ---------------------------------------------------------------------- diff --git a/framework/private/src/bundle_context.c b/framework/private/src/bundle_context.c index f12dbfa..5eb903a 100644 --- a/framework/private/src/bundle_context.c +++ b/framework/private/src/bundle_context.c @@ -362,7 +362,7 @@ celix_status_t bundleContext_removeFrameworkListener(bundle_context_pt context, return status; } -celix_status_t bundleContext_getProperty(bundle_context_pt context, const char *name, char **value) { +celix_status_t bundleContext_getProperty(bundle_context_pt context, const char *name, const char** value) { celix_status_t status = CELIX_SUCCESS; if (context == NULL || name == NULL || *value != NULL) { http://git-wip-us.apache.org/repos/asf/celix/blob/2cd57a78/framework/private/src/framework.c ---------------------------------------------------------------------- diff --git a/framework/private/src/framework.c b/framework/private/src/framework.c index 16dcf3f..93db610 100644 --- a/framework/private/src/framework.c +++ b/framework/private/src/framework.c @@ -518,14 +518,14 @@ void framework_stop(framework_pt framework) { fw_stopBundle(framework, framework->bundle, true); } -celix_status_t fw_getProperty(framework_pt framework, const char *name, char **value) { +celix_status_t fw_getProperty(framework_pt framework, const char *name, const char** value) { celix_status_t status = CELIX_SUCCESS; if (framework == NULL || name == NULL || *value != NULL) { status = CELIX_ILLEGAL_ARGUMENT; } else { if (framework->configurationMap != NULL) { - *value = (char*) properties_get(framework->configurationMap, name); + *value = properties_get(framework->configurationMap, name); } if (*value == NULL) { *value = getenv(name); http://git-wip-us.apache.org/repos/asf/celix/blob/2cd57a78/framework/private/src/service_reference.c ---------------------------------------------------------------------- diff --git a/framework/private/src/service_reference.c b/framework/private/src/service_reference.c index 0a5573c..2f75973 100644 --- a/framework/private/src/service_reference.c +++ b/framework/private/src/service_reference.c @@ -196,7 +196,7 @@ celix_status_t serviceReference_getServiceRegistration(service_reference_pt ref, return CELIX_SUCCESS; } -celix_status_t serviceReference_getProperty(service_reference_pt ref, char *key, char **value) { +celix_status_t serviceReference_getProperty(service_reference_pt ref, const char* key, const char** value) { celix_status_t status = CELIX_SUCCESS; properties_pt props = NULL; celixThreadRwlock_readLock(&ref->lock); @@ -289,7 +289,8 @@ celix_status_t serviceReference_compareTo(service_reference_pt reference, servic celix_status_t status = CELIX_SUCCESS; long id, other_id; - char *id_str, *other_id_str; + const char* id_str; + const char* other_id_str; serviceReference_getProperty(reference, (char *) OSGI_FRAMEWORK_SERVICE_ID, &id_str); serviceReference_getProperty(compareTo, (char *) OSGI_FRAMEWORK_SERVICE_ID, &other_id_str); @@ -298,9 +299,10 @@ celix_status_t serviceReference_compareTo(service_reference_pt reference, servic long rank, other_rank; - char *rank_str, *other_rank_str; - serviceReference_getProperty(reference, (char *) OSGI_FRAMEWORK_SERVICE_RANKING, &rank_str); - serviceReference_getProperty(compareTo, (char *) OSGI_FRAMEWORK_SERVICE_RANKING, &other_rank_str); + const char *rank_str; + const char* other_rank_str; + serviceReference_getProperty(reference, OSGI_FRAMEWORK_SERVICE_RANKING, &rank_str); + serviceReference_getProperty(compareTo, OSGI_FRAMEWORK_SERVICE_RANKING, &other_rank_str); rank = rank_str == NULL ? 0 : atol(rank_str); other_rank = other_rank_str == NULL ? 0 : atol(other_rank_str); http://git-wip-us.apache.org/repos/asf/celix/blob/2cd57a78/framework/private/src/utils.c ---------------------------------------------------------------------- diff --git a/framework/private/src/utils.c b/framework/private/src/utils.c index fdb0f62..5998531 100644 --- a/framework/private/src/utils.c +++ b/framework/private/src/utils.c @@ -59,7 +59,7 @@ char * string_ndup(const char *s, size_t n) { } char * utils_stringTrim(char * string) { - char * copy = string; + char* copy = string; char *end; // Trim leading space @@ -70,13 +70,21 @@ char * utils_stringTrim(char * string) { // Trim trailing space end = copy + strlen(copy) - 1; while(end > copy && isspace(*end)) { - *(end) = 0; + *(end) = '\0'; end--; } + if (copy != string) { + //beginning whitespaces -> move char in copy to to begin string + //This to ensure free still works on the same pointer. + char* nstring = string; + while(*copy != '\0') { + *(nstring++) = *(copy++); + } + (*nstring) = '\0'; + } - - return copy; + return string; } bool utils_isStringEmptyOrNull(const char * const str) { http://git-wip-us.apache.org/repos/asf/celix/blob/2cd57a78/framework/private/test/bundle_context_test.cpp ---------------------------------------------------------------------- diff --git a/framework/private/test/bundle_context_test.cpp b/framework/private/test/bundle_context_test.cpp index a83bdfb..96d9192 100644 --- a/framework/private/test/bundle_context_test.cpp +++ b/framework/private/test/bundle_context_test.cpp @@ -609,7 +609,7 @@ TEST(bundle_context, getProperty) { .withOutputParameterReturning("value", &value, sizeof(value)) .andReturnValue(CELIX_SUCCESS); - char *actualValue = NULL; + const char *actualValue = NULL; celix_status_t status = bundleContext_getProperty(context, name, &actualValue); LONGS_EQUAL(CELIX_SUCCESS, status); STRCMP_EQUAL(value, actualValue); http://git-wip-us.apache.org/repos/asf/celix/blob/2cd57a78/framework/private/test/service_reference_test.cpp ---------------------------------------------------------------------- diff --git a/framework/private/test/service_reference_test.cpp b/framework/private/test/service_reference_test.cpp index 8cb8491..0d49f18 100644 --- a/framework/private/test/service_reference_test.cpp +++ b/framework/private/test/service_reference_test.cpp @@ -326,7 +326,7 @@ TEST(service_reference, getProperty){ properties_pt props = (properties_pt) 0x20; char * key = my_strdup("key"); char * value = my_strdup("value"); - char * get_value = (char*) NULL; + const char * get_value = (char*) NULL; //test getting a property mock().expectOneCall("serviceRegistration_getProperties") http://git-wip-us.apache.org/repos/asf/celix/blob/2cd57a78/framework/public/include/bundle_context.h ---------------------------------------------------------------------- diff --git a/framework/public/include/bundle_context.h b/framework/public/include/bundle_context.h index cf8ac4a..fc29db5 100644 --- a/framework/public/include/bundle_context.h +++ b/framework/public/include/bundle_context.h @@ -113,6 +113,6 @@ FRAMEWORK_EXPORT celix_status_t bundleContext_removeBundleListener(bundle_contex FRAMEWORK_EXPORT celix_status_t bundleContext_addFrameworkListener(bundle_context_pt context, framework_listener_pt listener); FRAMEWORK_EXPORT celix_status_t bundleContext_removeFrameworkListener(bundle_context_pt context, framework_listener_pt listener); -FRAMEWORK_EXPORT celix_status_t bundleContext_getProperty(bundle_context_pt context, const char* name, char** value); +FRAMEWORK_EXPORT celix_status_t bundleContext_getProperty(bundle_context_pt context, const char* name, const char** value); #endif /* BUNDLE_CONTEXT_H_ */ http://git-wip-us.apache.org/repos/asf/celix/blob/2cd57a78/framework/public/include/service_reference.h ---------------------------------------------------------------------- diff --git a/framework/public/include/service_reference.h b/framework/public/include/service_reference.h index a8af38d..6e1605a 100644 --- a/framework/public/include/service_reference.h +++ b/framework/public/include/service_reference.h @@ -39,7 +39,7 @@ FRAMEWORK_EXPORT celix_status_t serviceReference_getBundle(service_reference_pt FRAMEWORK_EXPORT bool serviceReference_isAssignableTo(service_reference_pt reference, bundle_pt requester, const char* serviceName); -FRAMEWORK_EXPORT celix_status_t serviceReference_getProperty(service_reference_pt reference, char *key, char **value); +FRAMEWORK_EXPORT celix_status_t serviceReference_getProperty(service_reference_pt reference, const char* key, const char** value); FRAMEWORK_EXPORT celix_status_t serviceReference_getPropertyKeys(service_reference_pt reference, char **keys[], unsigned int *size); FRAMEWORK_EXPORT celix_status_t serviceReference_getServiceRegistration(service_reference_pt reference, service_registration_pt *registration); http://git-wip-us.apache.org/repos/asf/celix/blob/2cd57a78/log_service/private/src/log_service_activator.c ---------------------------------------------------------------------- diff --git a/log_service/private/src/log_service_activator.c b/log_service/private/src/log_service_activator.c index ce3cbb7..4f45153 100644 --- a/log_service/private/src/log_service_activator.c +++ b/log_service/private/src/log_service_activator.c @@ -158,7 +158,7 @@ celix_status_t bundleActivator_destroy(void * userData, bundle_context_pt contex static celix_status_t bundleActivator_getMaxSize(struct logActivator *activator, int *max_size) { celix_status_t status = CELIX_SUCCESS; - char *max_size_str = NULL; + const char *max_size_str = NULL; *max_size = DEFAULT_MAX_SIZE; @@ -173,7 +173,7 @@ static celix_status_t bundleActivator_getMaxSize(struct logActivator *activator, static celix_status_t bundleActivator_getStoreDebug(struct logActivator *activator, bool *store_debug) { celix_status_t status = CELIX_SUCCESS; - char *store_debug_str = NULL; + const char *store_debug_str = NULL; *store_debug = DEFAULT_STORE_DEBUG; http://git-wip-us.apache.org/repos/asf/celix/blob/2cd57a78/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 12ebe0b..7fcb172 100644 --- a/log_service/public/src/log_helper.c +++ b/log_service/public/src/log_helper.c @@ -64,7 +64,7 @@ celix_status_t logHelper_create(bundle_context_pt context, log_helper_pt* loghel } else { - char* stdOutFallbackStr = NULL; + const char* stdOutFallbackStr = NULL; (*loghelper)->bundleContext = context; (*loghelper)->logServiceTracker = NULL; (*loghelper)->stdOutFallback = false; http://git-wip-us.apache.org/repos/asf/celix/blob/2cd57a78/remote_services/discovery/private/src/discovery.c ---------------------------------------------------------------------- diff --git a/remote_services/discovery/private/src/discovery.c b/remote_services/discovery/private/src/discovery.c index e2415b4..e40a887 100644 --- a/remote_services/discovery/private/src/discovery.c +++ b/remote_services/discovery/private/src/discovery.c @@ -70,10 +70,10 @@ celix_status_t discovery_endpointListenerAdded(void* handle, service_reference_p celix_status_t status = CELIX_SUCCESS; discovery_pt discovery = handle; - char *discoveryListener = NULL; + const char *discoveryListener = NULL; serviceReference_getProperty(reference, "DISCOVERY", &discoveryListener); - char *scope = NULL; - serviceReference_getProperty(reference, (char *) OSGI_ENDPOINT_LISTENER_SCOPE, &scope); + const char *scope = NULL; + serviceReference_getProperty(reference, OSGI_ENDPOINT_LISTENER_SCOPE, &scope); filter_pt filter = filter_create(scope); @@ -157,8 +157,8 @@ celix_status_t discovery_informEndpointListeners(discovery_pt discovery, endpoin service_reference_pt reference = hashMapEntry_getKey(entry); endpoint_listener_pt listener = NULL; - char *scope = NULL; - serviceReference_getProperty(reference, (char *) OSGI_ENDPOINT_LISTENER_SCOPE, &scope); + const char* scope = NULL; + serviceReference_getProperty(reference, OSGI_ENDPOINT_LISTENER_SCOPE, &scope); filter_pt filter = filter_create(scope); bool matchResult = false; @@ -170,11 +170,11 @@ celix_status_t discovery_informEndpointListeners(discovery_pt discovery, endpoin if (endpointAdded) { logHelper_log(discovery->loghelper, OSGI_LOGSERVICE_INFO, "Adding service (%s)", endpoint->service); - listener->endpointAdded(listener->handle, endpoint, scope); + listener->endpointAdded(listener->handle, endpoint, (char*)scope); } else { logHelper_log(discovery->loghelper, OSGI_LOGSERVICE_INFO, "Removing service (%s)", endpoint->service); - listener->endpointRemoved(listener->handle, endpoint, scope); + listener->endpointRemoved(listener->handle, endpoint, (char*)scope); } } http://git-wip-us.apache.org/repos/asf/celix/blob/2cd57a78/remote_services/discovery/private/src/discovery_activator.c ---------------------------------------------------------------------- diff --git a/remote_services/discovery/private/src/discovery_activator.c b/remote_services/discovery/private/src/discovery_activator.c index e98de1a..3267d25 100644 --- a/remote_services/discovery/private/src/discovery_activator.c +++ b/remote_services/discovery/private/src/discovery_activator.c @@ -94,7 +94,7 @@ 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; struct activator *activator = userData; - char *uuid = NULL; + const char *uuid = NULL; logHelper_start(activator->loghelper); http://git-wip-us.apache.org/repos/asf/celix/blob/2cd57a78/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 202f061..7005ed7 100644 --- a/remote_services/discovery/private/src/endpoint_discovery_poller.c +++ b/remote_services/discovery/private/src/endpoint_discovery_poller.c @@ -67,19 +67,19 @@ celix_status_t endpointDiscoveryPoller_create(discovery_pt discovery, bundle_con return status; } - char* interval = NULL; + const char* interval = NULL; status = bundleContext_getProperty(context, DISCOVERY_POLL_INTERVAL, &interval); if (!interval) { interval = DEFAULT_POLL_INTERVAL; } - char* endpoints = NULL; - status = bundleContext_getProperty(context, DISCOVERY_POLL_ENDPOINTS, &endpoints); - if (!endpoints) { - endpoints = DEFAULT_POLL_ENDPOINTS; + const char* endpointsProp = NULL; + status = bundleContext_getProperty(context, DISCOVERY_POLL_ENDPOINTS, &endpointsProp); + if (!endpointsProp) { + endpointsProp = DEFAULT_POLL_ENDPOINTS; } // we're going to mutate the string with strtok, so create a copy... - endpoints = strdup(endpoints); + char* endpoints = strdup(endpointsProp); (*poller)->poll_interval = atoi(interval); (*poller)->discovery = discovery; http://git-wip-us.apache.org/repos/asf/celix/blob/2cd57a78/remote_services/discovery/private/src/endpoint_discovery_server.c ---------------------------------------------------------------------- diff --git a/remote_services/discovery/private/src/endpoint_discovery_server.c b/remote_services/discovery/private/src/endpoint_discovery_server.c index 02cc923..6273e6f 100644 --- a/remote_services/discovery/private/src/endpoint_discovery_server.c +++ b/remote_services/discovery/private/src/endpoint_discovery_server.c @@ -66,7 +66,7 @@ struct endpoint_discovery_server { // Forward declarations... static int endpointDiscoveryServer_callback(struct mg_connection *conn); -static char* format_path(char* path); +static char* format_path(const char* path); #ifndef ANDROID static celix_status_t endpointDiscoveryServer_getIpAdress(char* interface, char** ip); @@ -75,10 +75,10 @@ static celix_status_t endpointDiscoveryServer_getIpAdress(char* interface, char* celix_status_t endpointDiscoveryServer_create(discovery_pt discovery, bundle_context_pt context, endpoint_discovery_server_pt *server) { celix_status_t status; - char *port = NULL; - char *ip = NULL; + const char *port = NULL; + const char *ip = NULL; char *detectedIp = NULL; - char *path = NULL; + const char *path = NULL; *server = malloc(sizeof(struct endpoint_discovery_server)); if (!*server) { @@ -99,10 +99,10 @@ celix_status_t endpointDiscoveryServer_create(discovery_pt discovery, bundle_con bundleContext_getProperty(context, DISCOVERY_SERVER_IP, &ip); #ifndef ANDROID if (ip == NULL) { - char *interface = NULL; + const char *interface = NULL; bundleContext_getProperty(context, DISCOVERY_SERVER_INTERFACE, &interface); - if ((interface != NULL) && (endpointDiscoveryServer_getIpAdress(interface, &detectedIp) != CELIX_SUCCESS)) { + if ((interface != NULL) && (endpointDiscoveryServer_getIpAdress((char*)interface, &detectedIp) != CELIX_SUCCESS)) { logHelper_log(*(*server)->loghelper, OSGI_LOGSERVICE_WARNING, "Could not retrieve IP adress for interface %s", interface); } @@ -161,7 +161,7 @@ celix_status_t endpointDiscoveryServer_create(discovery_pt discovery, bundle_con } else { errno = 0; - char* endptr = port; + char* endptr = (char*)port; long currentPort = strtol(port, &endptr, 10); if (*endptr || errno != 0) { @@ -273,8 +273,9 @@ celix_status_t endpointDiscoveryServer_removeEndpoint(endpoint_discovery_server_ return status; } -static char* format_path(char* path) { - char* result = strdup(utils_stringTrim(path)); +static char* format_path(const char* path) { + char* result = strdup(path); + result = utils_stringTrim(result); // check whether the path starts with a leading slash... if (result[0] != '/') { size_t len = strlen(result); http://git-wip-us.apache.org/repos/asf/celix/blob/2cd57a78/remote_services/discovery_etcd/private/src/discovery_impl.c ---------------------------------------------------------------------- diff --git a/remote_services/discovery_etcd/private/src/discovery_impl.c b/remote_services/discovery_etcd/private/src/discovery_impl.c index 00ab9a6..8087d95 100644 --- a/remote_services/discovery_etcd/private/src/discovery_impl.c +++ b/remote_services/discovery_etcd/private/src/discovery_impl.c @@ -109,8 +109,8 @@ celix_status_t discovery_destroy(discovery_pt discovery) { celix_status_t discovery_start(discovery_pt discovery) { celix_status_t status = CELIX_SUCCESS; - char *port = NULL; - char *path = NULL; + const char *port = NULL; + const char *path = NULL; logHelper_start(discovery->loghelper); @@ -138,7 +138,6 @@ celix_status_t discovery_start(discovery_pt discovery) { if (status != CELIX_SUCCESS) { return CELIX_BUNDLE_EXCEPTION; } - return status; } http://git-wip-us.apache.org/repos/asf/celix/blob/2cd57a78/remote_services/discovery_etcd/private/src/etcd_watcher.c ---------------------------------------------------------------------- diff --git a/remote_services/discovery_etcd/private/src/etcd_watcher.c b/remote_services/discovery_etcd/private/src/etcd_watcher.c index 0675bc2..a7bcc2e 100644 --- a/remote_services/discovery_etcd/private/src/etcd_watcher.c +++ b/remote_services/discovery_etcd/private/src/etcd_watcher.c @@ -68,7 +68,7 @@ struct etcd_watcher { // note that the rootNode shouldn't have a leading slash static celix_status_t etcdWatcher_getRootPath(bundle_context_pt context, char* rootNode) { celix_status_t status = CELIX_SUCCESS; - char* rootPath = NULL; + const char* rootPath = NULL; if (((bundleContext_getProperty(context, CFG_ETCD_ROOT_PATH, &rootPath)) != CELIX_SUCCESS) || (!rootPath)) { strcpy(rootNode, DEFAULT_ETCD_ROOTPATH); @@ -84,7 +84,7 @@ static celix_status_t etcdWatcher_getRootPath(bundle_context_pt context, char* r static celix_status_t etcdWatcher_getLocalNodePath(bundle_context_pt context, char* localNodePath) { celix_status_t status = CELIX_SUCCESS; char rootPath[MAX_ROOTNODE_LENGTH]; - char* uuid = NULL; + const char* uuid = NULL; if ((etcdWatcher_getRootPath(context, &rootPath[0]) != CELIX_SUCCESS)) { status = CELIX_ILLEGAL_STATE; @@ -159,7 +159,7 @@ static celix_status_t etcdWatcher_addOwnFramework(etcd_watcher_pt watcher) char url[MAX_VALUE_LENGTH]; int modIndex; char* endpoints = NULL; - char* ttlStr = NULL; + const char* ttlStr = NULL; int ttl; bundle_context_pt context = watcher->discovery->context; @@ -181,7 +181,7 @@ static celix_status_t etcdWatcher_addOwnFramework(etcd_watcher_pt watcher) } else { - char* endptr = ttlStr; + char* endptr = (char*)ttlStr; errno = 0; ttl = strtol(ttlStr, &endptr, 10); if (*endptr || errno != 0) { @@ -325,8 +325,8 @@ celix_status_t etcdWatcher_create(discovery_pt discovery, bundle_context_pt cont { celix_status_t status = CELIX_SUCCESS; - char* etcd_server = NULL; - char* etcd_port_string = NULL; + const char* etcd_server = NULL; + const char* etcd_port_string = NULL; int etcd_port = 0; if (discovery == NULL) { @@ -353,7 +353,7 @@ celix_status_t etcdWatcher_create(discovery_pt discovery, bundle_context_pt cont } else { - char* endptr = etcd_port_string; + char* endptr = (char*)etcd_port_string; errno = 0; etcd_port = strtol(etcd_port_string, &endptr, 10); if (*endptr || errno != 0) { @@ -361,7 +361,7 @@ celix_status_t etcdWatcher_create(discovery_pt discovery, bundle_context_pt cont } } - status = etcd_init(etcd_server, etcd_port); + status = etcd_init((char*)etcd_server, etcd_port); printf(" ININT\n"); if (status == CELIX_SUCCESS) { http://git-wip-us.apache.org/repos/asf/celix/blob/2cd57a78/remote_services/discovery_shm/private/src/discovery_shmWatcher.c ---------------------------------------------------------------------- diff --git a/remote_services/discovery_shm/private/src/discovery_shmWatcher.c b/remote_services/discovery_shm/private/src/discovery_shmWatcher.c index ea49c4d..6460de8 100644 --- a/remote_services/discovery_shm/private/src/discovery_shmWatcher.c +++ b/remote_services/discovery_shm/private/src/discovery_shmWatcher.c @@ -60,7 +60,7 @@ static celix_status_t discoveryShmWatcher_getRootPath(char* rootNode) { static celix_status_t discoveryShmWatcher_getLocalNodePath(bundle_context_pt context, char* localNodePath) { celix_status_t status; char rootPath[MAX_ROOTNODE_LENGTH]; - char* uuid = NULL; + const char* uuid = NULL; status = discoveryShmWatcher_getRootPath(&rootPath[0]); http://git-wip-us.apache.org/repos/asf/celix/blob/2cd57a78/remote_services/remote_service_admin/private/src/export_registration_impl.c ---------------------------------------------------------------------- diff --git a/remote_services/remote_service_admin/private/src/export_registration_impl.c b/remote_services/remote_service_admin/private/src/export_registration_impl.c index 20be900..1c684e7 100644 --- a/remote_services/remote_service_admin/private/src/export_registration_impl.c +++ b/remote_services/remote_service_admin/private/src/export_registration_impl.c @@ -179,7 +179,7 @@ celix_status_t exportRegistration_endpointRemoved(void * handle, service_referen celix_status_t exportRegistration_open(export_registration_pt registration) { celix_status_t status = CELIX_SUCCESS; - char *bundleStore = NULL; + const char *bundleStore = NULL; bundleContext_getProperty(registration->context, BUNDLE_STORE_PROPERTY_NAME, &bundleStore); http://git-wip-us.apache.org/repos/asf/celix/blob/2cd57a78/remote_services/remote_service_admin/private/src/import_registration_impl.c ---------------------------------------------------------------------- diff --git a/remote_services/remote_service_admin/private/src/import_registration_impl.c b/remote_services/remote_service_admin/private/src/import_registration_impl.c index f7419a2..9a84327 100644 --- a/remote_services/remote_service_admin/private/src/import_registration_impl.c +++ b/remote_services/remote_service_admin/private/src/import_registration_impl.c @@ -116,7 +116,7 @@ celix_status_t importRegistrationFactory_open(import_registration_factory_pt reg { celix_status_t status; - char *bundleStore = NULL; + const char *bundleStore = NULL; bundleContext_getProperty(registration_factory->context, BUNDLE_STORE_PROPERTY_NAME, &bundleStore); if (bundleStore == NULL) { http://git-wip-us.apache.org/repos/asf/celix/blob/2cd57a78/remote_services/remote_service_admin_dfi/rsa/private/src/dfi_utils.c ---------------------------------------------------------------------- diff --git a/remote_services/remote_service_admin_dfi/rsa/private/src/dfi_utils.c b/remote_services/remote_service_admin_dfi/rsa/private/src/dfi_utils.c index ba66e52..c77e7f4 100644 --- a/remote_services/remote_service_admin_dfi/rsa/private/src/dfi_utils.c +++ b/remote_services/remote_service_admin_dfi/rsa/private/src/dfi_utils.c @@ -26,7 +26,7 @@ static celix_status_t dfi_findFileForFramework(bundle_context_pt context, const char pwd[1024]; char path[1024]; - char *extPath = NULL; + const char *extPath = NULL; status = bundleContext_getProperty(context, "CELIX_FRAMEWORK_EXTENDER_PATH", &extPath); if (status != CELIX_SUCCESS || extPath == NULL) { http://git-wip-us.apache.org/repos/asf/celix/blob/2cd57a78/remote_services/remote_service_admin_dfi/rsa/private/src/export_registration_dfi.c ---------------------------------------------------------------------- diff --git a/remote_services/remote_service_admin_dfi/rsa/private/src/export_registration_dfi.c b/remote_services/remote_service_admin_dfi/rsa/private/src/export_registration_dfi.c index 66c849d..b83b5a8 100644 --- a/remote_services/remote_service_admin_dfi/rsa/private/src/export_registration_dfi.c +++ b/remote_services/remote_service_admin_dfi/rsa/private/src/export_registration_dfi.c @@ -54,7 +54,7 @@ static void exportRegistration_removeServ(export_registration_pt reg, service_re celix_status_t exportRegistration_create(log_helper_pt helper, service_reference_pt reference, endpoint_description_pt endpoint, bundle_context_pt context, export_registration_pt *out) { celix_status_t status = CELIX_SUCCESS; - char *servId = NULL; + const char *servId = NULL; status = serviceReference_getProperty(reference, "service.id", &servId); if (status != CELIX_SUCCESS) { logHelper_log(helper, OSGI_LOGSERVICE_WARNING, "Cannot find service.id for ref"); @@ -78,7 +78,7 @@ celix_status_t exportRegistration_create(log_helper_pt helper, service_reference celixThreadMutex_create(®->mutex, NULL); } - char *exports = NULL; + const char *exports = NULL; CELIX_DO_IF(status, serviceReference_getProperty(reference, (char *) OSGI_RSA_SERVICE_EXPORTED_INTERFACES, &exports)); bundle_pt bundle = NULL; http://git-wip-us.apache.org/repos/asf/celix/blob/2cd57a78/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 4320a54..16134fe 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 @@ -127,8 +127,8 @@ celix_status_t remoteServiceAdmin_create(bundle_context_pt context, remote_servi status = CELIX_ENOMEM; } else { unsigned int port_counter = 0; - char *port = NULL; - char *ip = NULL; + const char *port = NULL; + const char *ip = NULL; char *detectedIp = NULL; (*admin)->context = context; (*admin)->exportedServices = hashMap_create(NULL, NULL, NULL, NULL); @@ -154,10 +154,10 @@ celix_status_t remoteServiceAdmin_create(bundle_context_pt context, remote_servi bundleContext_getProperty(context, "RSA_IP", &ip); if (ip == NULL) { - char *interface = NULL; + const char *interface = NULL; bundleContext_getProperty(context, "RSA_INTERFACE", &interface); - if ((interface != NULL) && (remoteServiceAdmin_getIpAdress(interface, &detectedIp) != CELIX_SUCCESS)) { + if ((interface != NULL) && (remoteServiceAdmin_getIpAdress((char*)interface, &detectedIp) != CELIX_SUCCESS)) { logHelper_log((*admin)->loghelper, OSGI_LOGSERVICE_WARNING, "RSA: Could not retrieve IP adress for interface %s", interface); } @@ -201,7 +201,7 @@ celix_status_t remoteServiceAdmin_create(bundle_context_pt context, remote_servi } else { errno = 0; - char* endptr = port; + char* endptr = (char*)port; int currentPort = strtol(port, &endptr, 10); if (*endptr || errno != 0) { @@ -407,8 +407,8 @@ celix_status_t remoteServiceAdmin_exportService(remote_service_admin_pt admin, c status = CELIX_ILLEGAL_STATE; } - char *exports = NULL; - char *provided = NULL; + const char *exports = NULL; + const char *provided = NULL; if (status == CELIX_SUCCESS) { serviceReference_getProperty(reference, (char *) OSGI_RSA_SERVICE_EXPORTED_INTERFACES, &exports); serviceReference_getProperty(reference, (char *) OSGI_FRAMEWORK_OBJECTCLASS, &provided); @@ -422,11 +422,11 @@ celix_status_t remoteServiceAdmin_exportService(remote_service_admin_pt admin, c } if (status == CELIX_SUCCESS) { - char *interface = provided; + const char *interface = provided; endpoint_description_pt endpoint = NULL; export_registration_pt registration = NULL; - remoteServiceAdmin_createEndpointDescription(admin, reference, properties, interface, &endpoint); + remoteServiceAdmin_createEndpointDescription(admin, reference, properties, (char*)interface, &endpoint); //TOOD precheck if descriptor exists status = exportRegistration_create(admin->loghelper, reference, endpoint, admin->context, ®istration); if (status == CELIX_SUCCESS) { @@ -495,7 +495,7 @@ static celix_status_t remoteServiceAdmin_createEndpointDescription(remote_servic serviceReference_getPropertyKeys(reference, &keys, &size); for (int i = 0; i < size; i++) { char *key = keys[i]; - char *value = NULL; + const char *value = NULL; if (serviceReference_getProperty(reference, key, &value) == CELIX_SUCCESS && strcmp(key, (char*) OSGI_RSA_SERVICE_EXPORTED_INTERFACES) != 0 @@ -508,7 +508,7 @@ static celix_status_t remoteServiceAdmin_createEndpointDescription(remote_servic char* key = hashMapEntry_getKey(entry); char *serviceId = (char *) hashMap_remove(endpointProperties, (void *) OSGI_FRAMEWORK_SERVICE_ID); - char *uuid = NULL; + const char *uuid = NULL; char buf[512]; snprintf(buf, 512, "/service/%s/%s", serviceId, interface); @@ -544,7 +544,7 @@ static celix_status_t remoteServiceAdmin_createEndpointDescription(remote_servic status = CELIX_ENOMEM; } else { (*endpoint)->id = (char*)properties_get(endpointProperties, (char*) OSGI_RSA_ENDPOINT_ID); - char *serviceId = NULL; + const char *serviceId = NULL; serviceReference_getProperty(reference, (char*) OSGI_FRAMEWORK_SERVICE_ID, &serviceId); (*endpoint)->serviceId = strtoull(serviceId, NULL, 0); (*endpoint)->frameworkUUID = (char*) properties_get(endpointProperties, (char*) OSGI_RSA_ENDPOINT_FRAMEWORK_UUID); @@ -685,7 +685,7 @@ static celix_status_t remoteServiceAdmin_send(void *handle, endpoint_description // assume the default timeout int timeout = DEFAULT_TIMEOUT; - char *timeoutStr = NULL; + const char *timeoutStr = NULL; // Check if the endpoint has a timeout, if so, use it. timeoutStr = (char*) properties_get(endpointDescription->properties, (char*) OSGI_RSA_REMOTE_PROXY_TIMEOUT); if (timeoutStr == NULL) { http://git-wip-us.apache.org/repos/asf/celix/blob/2cd57a78/remote_services/remote_service_admin_dfi/rsa_tst/rsa_tests.cpp ---------------------------------------------------------------------- diff --git a/remote_services/remote_service_admin_dfi/rsa_tst/rsa_tests.cpp b/remote_services/remote_service_admin_dfi/rsa_tst/rsa_tests.cpp index d6db569..8b7988d 100644 --- a/remote_services/remote_service_admin_dfi/rsa_tst/rsa_tests.cpp +++ b/remote_services/remote_service_admin_dfi/rsa_tst/rsa_tests.cpp @@ -126,13 +126,13 @@ extern "C" { static void testExportService(void) { int rc = 0; - char *calcId = NULL; + const char *calcId = NULL; array_list_pt regs = NULL; rc = serviceReference_getProperty(calcRef, (char *)"service.id", &calcId); CHECK_EQUAL(CELIX_SUCCESS, rc); - rc = rsa->exportService(rsa->admin, calcId, NULL, ®s); + rc = rsa->exportService(rsa->admin, (char*)calcId, NULL, ®s); CHECK_EQUAL(CELIX_SUCCESS, rc); CHECK_EQUAL(1, arrayList_size(regs)); http://git-wip-us.apache.org/repos/asf/celix/blob/2cd57a78/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 80eb364..75ec5d0 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 @@ -106,8 +106,8 @@ celix_status_t remoteServiceAdmin_create(bundle_context_pt context, remote_servi status = CELIX_ENOMEM; } else { unsigned int port_counter = 0; - char *port = NULL; - char *ip = NULL; + const char *port = NULL; + const char *ip = NULL; char *detectedIp = NULL; (*admin)->context = context; (*admin)->exportedServices = hashMap_create(NULL, NULL, NULL, NULL); @@ -129,10 +129,10 @@ celix_status_t remoteServiceAdmin_create(bundle_context_pt context, remote_servi #ifndef ANDROID if (ip == NULL) { - char *interface = NULL; + const char *interface = NULL; bundleContext_getProperty(context, "RSA_INTERFACE", &interface); - if ((interface != NULL) && (remoteServiceAdmin_getIpAdress(interface, &detectedIp) != CELIX_SUCCESS)) { + if ((interface != NULL) && (remoteServiceAdmin_getIpAdress((char*)interface, &detectedIp) != CELIX_SUCCESS)) { logHelper_log((*admin)->loghelper, OSGI_LOGSERVICE_WARNING, "RSA: Could not retrieve IP adress for interface %s", interface); } @@ -174,7 +174,7 @@ celix_status_t remoteServiceAdmin_create(bundle_context_pt context, remote_servi (*admin)->port = strdup(port); } else { - char* endptr = port; + char* endptr = (char*)port; int currentPort = strtol(port, &endptr, 10); errno = 0; @@ -399,10 +399,10 @@ celix_status_t remoteServiceAdmin_exportService(remote_service_admin_pt admin, c return CELIX_ILLEGAL_STATE; } - char *exports = NULL; - char *provided = NULL; - serviceReference_getProperty(reference, (char *) OSGI_RSA_SERVICE_EXPORTED_INTERFACES, &exports); - serviceReference_getProperty(reference, (char *) OSGI_FRAMEWORK_OBJECTCLASS, &provided); + const char *exports = NULL; + const char *provided = NULL; + serviceReference_getProperty(reference, OSGI_RSA_SERVICE_EXPORTED_INTERFACES, &exports); + serviceReference_getProperty(reference, OSGI_FRAMEWORK_OBJECTCLASS, &provided); if (exports == NULL || provided == NULL) { logHelper_log(admin->loghelper, OSGI_LOGSERVICE_WARNING, "RSA: No Services to export."); @@ -410,19 +410,21 @@ celix_status_t remoteServiceAdmin_exportService(remote_service_admin_pt admin, c logHelper_log(admin->loghelper, OSGI_LOGSERVICE_INFO, "RSA: Export services (%s)", exports); array_list_pt interfaces = NULL; arrayList_create(&interfaces); - if (strcmp(utils_stringTrim(exports), "*") == 0) { + char *cmpExports = strndup(exports, 1024*10); + char *providedCopy = strndup(provided, 1024*10); + if (strcmp(utils_stringTrim(cmpExports), "*") == 0) { char *save_ptr = NULL; - char *interface = strtok_r(provided, ",", &save_ptr); + char *interface = strtok_r(providedCopy, ",", &save_ptr); while (interface != NULL) { arrayList_add(interfaces, utils_stringTrim(interface)); interface = strtok_r(NULL, ",", &save_ptr); } } else { char *provided_save_ptr = NULL; - char *pinterface = strtok_r(provided, ",", &provided_save_ptr); + char *pinterface = strtok_r(providedCopy, ",", &provided_save_ptr); while (pinterface != NULL) { char *exports_save_ptr = NULL; - char *einterface = strtok_r(exports, ",", &exports_save_ptr); + char *einterface = strtok_r(cmpExports, ",", &exports_save_ptr); while (einterface != NULL) { if (strcmp(einterface, pinterface) == 0) { arrayList_add(interfaces, einterface); @@ -432,6 +434,8 @@ celix_status_t remoteServiceAdmin_exportService(remote_service_admin_pt admin, c pinterface = strtok_r(NULL, ",", &provided_save_ptr); } } + free(cmpExports); + free(providedCopy); if (arrayList_size(interfaces) != 0) { int iter = 0; @@ -501,7 +505,7 @@ celix_status_t remoteServiceAdmin_installEndpoint(remote_service_admin_pt admin, serviceReference_getPropertyKeys(reference, &keys, &size); for (int i = 0; i < size; i++) { char *key = keys[i]; - char *value = NULL; + const char *value = NULL; if (serviceReference_getProperty(reference, key, &value) == CELIX_SUCCESS && strcmp(key, (char*) OSGI_RSA_SERVICE_EXPORTED_INTERFACES) != 0 @@ -514,7 +518,7 @@ celix_status_t remoteServiceAdmin_installEndpoint(remote_service_admin_pt admin, char* key = hashMapEntry_getKey(entry); char *serviceId = (char *) hashMap_remove(endpointProperties, (void *) OSGI_FRAMEWORK_SERVICE_ID); - char *uuid = NULL; + const char *uuid = NULL; char buf[512]; snprintf(buf, 512, "/service/%s/%s", serviceId, interface); @@ -590,7 +594,7 @@ celix_status_t remoteServiceAdmin_createEndpointDescription(remote_service_admin status = CELIX_ENOMEM; } else { (*description)->id = (char*)properties_get(endpointProperties, (char*) OSGI_RSA_ENDPOINT_ID); - char *serviceId = NULL; + const char *serviceId = NULL; serviceReference_getProperty(reference, (char*)OSGI_FRAMEWORK_SERVICE_ID, &serviceId); (*description)->serviceId = strtoull(serviceId, NULL, 0); (*description)->frameworkUUID = (char*)properties_get(endpointProperties, OSGI_RSA_ENDPOINT_FRAMEWORK_UUID); @@ -738,7 +742,7 @@ celix_status_t remoteServiceAdmin_send(remote_service_admin_pt rsa, endpoint_des int timeout = DEFAULT_TIMEOUT; if (status == CELIX_SUCCESS) { - char *timeoutStr = NULL; + const char *timeoutStr = NULL; // Check if the endpoint has a timeout, if so, use it. timeoutStr = (char*)properties_get(endpointDescription->properties, OSGI_RSA_REMOTE_PROXY_TIMEOUT); http://git-wip-us.apache.org/repos/asf/celix/blob/2cd57a78/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 8060a52..c760590 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 @@ -407,7 +407,7 @@ celix_status_t remoteServiceAdmin_removeSharedIdentityFile(remote_service_admin_ celix_status_t remoteServiceAdmin_removeSharedIdentityFiles(remote_service_admin_pt admin) { char tmpDir[RSA_FILEPATH_LENGTH]; - char* fwUuid = NULL; + const char* fwUuid = NULL; bundleContext_getProperty(admin->context, OSGI_FRAMEWORK_FRAMEWORK_UUID, &fwUuid); snprintf(tmpDir, RSA_FILEPATH_LENGTH, "%s/%s", P_tmpdir, fwUuid); @@ -463,8 +463,8 @@ celix_status_t remoteServiceAdmin_exportService(remote_service_admin_pt admin, c array_list_pt references = NULL; service_reference_pt reference = NULL; char filter[256]; - char *exports = NULL; - char *provided = NULL; + const char *exportsProp = NULL; + const char *providedProp = NULL; snprintf(filter, 256, "(%s=%s)", (char *) OSGI_FRAMEWORK_SERVICE_ID, serviceId); @@ -476,9 +476,11 @@ celix_status_t remoteServiceAdmin_exportService(remote_service_admin_pt admin, c arrayList_destroy(references); - serviceReference_getProperty(reference, (char *) OSGI_RSA_SERVICE_EXPORTED_INTERFACES, &exports); - serviceReference_getProperty(reference, (char *) OSGI_FRAMEWORK_OBJECTCLASS, &provided); + serviceReference_getProperty(reference, (char *) OSGI_RSA_SERVICE_EXPORTED_INTERFACES, &exportsProp); + serviceReference_getProperty(reference, (char *) OSGI_FRAMEWORK_OBJECTCLASS, &providedProp); + char* exports = strndup(exportsProp, 1024*10); + char* provided = strndup(providedProp, 1024*10); if (reference == NULL) { logHelper_log(admin->loghelper, OSGI_LOGSERVICE_ERROR, "expected a reference for service id %s.", serviceId); @@ -557,6 +559,9 @@ celix_status_t remoteServiceAdmin_exportService(remote_service_admin_pt admin, c arrayList_destroy(interfaces); } + free(exports); + free(provided); + return status; } @@ -729,7 +734,7 @@ celix_status_t remoteServiceAdmin_installEndpoint(remote_service_admin_pt admin, serviceReference_getPropertyKeys(reference, &keys, &size); for (int i = 0; i < size; i++) { char *key = keys[i]; - char *value = NULL; + const char *value = NULL; if (serviceReference_getProperty(reference, key, &value) == CELIX_SUCCESS && strcmp(key, (char*) OSGI_RSA_SERVICE_EXPORTED_INTERFACES) != 0 && strcmp(key, (char*) OSGI_FRAMEWORK_OBJECTCLASS) != 0) { properties_set(endpointProperties, key, value); @@ -740,7 +745,7 @@ celix_status_t remoteServiceAdmin_installEndpoint(remote_service_admin_pt admin, char* key = hashMapEntry_getKey(entry); char *serviceId = (char *) hashMap_remove(endpointProperties, (void *) OSGI_FRAMEWORK_SERVICE_ID); - char *uuid = NULL; + const char *uuid = NULL; uuid_t endpoint_uid; uuid_generate(endpoint_uid); @@ -758,8 +763,8 @@ celix_status_t remoteServiceAdmin_installEndpoint(remote_service_admin_pt admin, if (properties_get(endpointProperties, (char *) RSA_SHM_PATH_PROPERTYNAME) == NULL) { char sharedIdentifierFile[RSA_FILEPATH_LENGTH]; - if (remoteServiceAdmin_getSharedIdentifierFile(admin, uuid, interface, sharedIdentifierFile) == CELIX_SUCCESS) { - properties_set(endpointProperties, (char *) RSA_SHM_PATH_PROPERTYNAME, sharedIdentifierFile); + if (remoteServiceAdmin_getSharedIdentifierFile(admin, (char*)uuid, interface, sharedIdentifierFile) == CELIX_SUCCESS) { + properties_set(endpointProperties, RSA_SHM_PATH_PROPERTYNAME, sharedIdentifierFile); } else { properties_set(endpointProperties, (char *) RSA_SHM_PATH_PROPERTYNAME, (char *) RSA_SHM_DEFAULTPATH); } @@ -770,7 +775,7 @@ celix_status_t remoteServiceAdmin_installEndpoint(remote_service_admin_pt admin, if (properties_get(endpointProperties, (char *) RSA_SEM_PATH_PROPERTYNAME) == NULL) { char sharedIdentifierFile[RSA_FILEPATH_LENGTH]; - if (remoteServiceAdmin_getSharedIdentifierFile(admin, uuid, interface, sharedIdentifierFile) == CELIX_SUCCESS) { + if (remoteServiceAdmin_getSharedIdentifierFile(admin, (char*)uuid, interface, sharedIdentifierFile) == CELIX_SUCCESS) { properties_set(endpointProperties, (char *) RSA_SEM_PATH_PROPERTYNAME, sharedIdentifierFile); } else { properties_set(endpointProperties, (char *) RSA_SEM_PATH_PROPERTYNAME, (char *) RSA_SEM_DEFAULTPATH); @@ -801,7 +806,7 @@ celix_status_t remoteServiceAdmin_createEndpointDescription(remote_service_admin if (status == CELIX_SUCCESS) { (*description)->properties = endpointProperties; (*description)->frameworkUUID = (char*)properties_get(endpointProperties, (char*) OSGI_RSA_ENDPOINT_FRAMEWORK_UUID); - char *serviceId = NULL; + const char *serviceId = NULL; serviceReference_getProperty(reference, (char*)OSGI_FRAMEWORK_SERVICE_ID, &serviceId); (*description)->serviceId = strtoull(serviceId, NULL, 0); (*description)->id = (char*)properties_get(endpointProperties, (char*) OSGI_RSA_ENDPOINT_ID); http://git-wip-us.apache.org/repos/asf/celix/blob/2cd57a78/remote_services/topology_manager/private/src/activator.c ---------------------------------------------------------------------- diff --git a/remote_services/topology_manager/private/src/activator.c b/remote_services/topology_manager/private/src/activator.c index 1ec4fed..7f39a25 100644 --- a/remote_services/topology_manager/private/src/activator.c +++ b/remote_services/topology_manager/private/src/activator.c @@ -179,8 +179,8 @@ celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) endpointListener->endpointRemoved = topologyManager_removeImportedService; activator->endpointListener = endpointListener; - char *uuid = NULL; - status = bundleContext_getProperty(activator->context, (char *) OSGI_FRAMEWORK_FRAMEWORK_UUID, &uuid); + const char *uuid = NULL; + status = bundleContext_getProperty(activator->context, OSGI_FRAMEWORK_FRAMEWORK_UUID, &uuid); if (!uuid) { logHelper_log(activator->loghelper, OSGI_LOGSERVICE_ERROR, "TOPOLOGY_MANAGER: no framework UUID defined?!"); return CELIX_ILLEGAL_STATE; @@ -228,10 +228,10 @@ celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) int i; for (i = 0; i < arrayList_size(references); i++) { service_reference_pt reference = arrayList_get(references, i); - char *serviceId = NULL; - status = CELIX_DO_IF(status, serviceReference_getProperty(reference, (char *)OSGI_FRAMEWORK_SERVICE_ID, &serviceId)); + const char* serviceId = NULL; + status = CELIX_DO_IF(status, serviceReference_getProperty(reference, OSGI_FRAMEWORK_SERVICE_ID, &serviceId)); - CELIX_DO_IF(status, topologyManager_addExportedService(activator->manager, reference, serviceId)); + CELIX_DO_IF(status, topologyManager_addExportedService(activator->manager, reference, (char*)serviceId)); } arrayList_destroy(references); http://git-wip-us.apache.org/repos/asf/celix/blob/2cd57a78/remote_services/topology_manager/private/src/scope.c ---------------------------------------------------------------------- diff --git a/remote_services/topology_manager/private/src/scope.c b/remote_services/topology_manager/private/src/scope.c index 59e030c..b600040 100644 --- a/remote_services/topology_manager/private/src/scope.c +++ b/remote_services/topology_manager/private/src/scope.c @@ -286,7 +286,7 @@ celix_status_t scope_getExportProperties(scope_pt scope, service_reference_pt re serviceReference_getPropertyKeys(reference, &keys, &size); for (int i = 0; i < size; i++) { char *key = keys[i]; - char *value = NULL; + const char* value = NULL; if (serviceReference_getProperty(reference, key, &value) == CELIX_SUCCESS) { // && strcmp(key, (char*) OSGI_RSA_SERVICE_EXPORTED_INTERFACES) != 0 http://git-wip-us.apache.org/repos/asf/celix/blob/2cd57a78/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 f4d27a8..09f069d 100644 --- a/remote_services/topology_manager/private/src/topology_manager.c +++ b/remote_services/topology_manager/private/src/topology_manager.c @@ -246,14 +246,14 @@ celix_status_t topologyManager_rsaAdded(void * handle, service_reference_pt refe while (hashMapIterator_hasNext(exportedServicesIterator)) { hash_map_entry_pt entry = hashMapIterator_nextEntry(exportedServicesIterator); service_reference_pt reference = hashMapEntry_getKey(entry); - char *serviceId = NULL; + const char* serviceId = NULL; - serviceReference_getProperty(reference, (char *) OSGI_FRAMEWORK_SERVICE_ID, &serviceId); + serviceReference_getProperty(reference, OSGI_FRAMEWORK_SERVICE_ID, &serviceId); scope_getExportProperties(manager->scope, reference, &serviceProperties); array_list_pt endpoints = NULL; - status = rsa->exportService(rsa->admin, serviceId, serviceProperties, &endpoints); + status = rsa->exportService(rsa->admin, (char*)serviceId, serviceProperties, &endpoints); if (status == CELIX_SUCCESS) { hash_map_pt exports = hashMapEntry_getValue(entry); @@ -370,10 +370,10 @@ celix_status_t topologyManager_serviceChanged(void *listener, service_event_pt e service_listener_pt listen = listener; topology_manager_pt manager = listen->handle; - char *export = NULL; - char *serviceId = NULL; - serviceReference_getProperty(event->reference, (char *) OSGI_RSA_SERVICE_EXPORTED_INTERFACES, &export); - serviceReference_getProperty(event->reference, (char *) OSGI_FRAMEWORK_SERVICE_ID, &serviceId); + const char* export = NULL; + const char* serviceId = NULL; + serviceReference_getProperty(event->reference, OSGI_RSA_SERVICE_EXPORTED_INTERFACES, &export); + serviceReference_getProperty(event->reference, OSGI_FRAMEWORK_SERVICE_ID, &serviceId); if (!export) { // Nothing needs to be done: we're not interested... @@ -382,17 +382,17 @@ celix_status_t topologyManager_serviceChanged(void *listener, service_event_pt e switch (event->type) { case OSGI_FRAMEWORK_SERVICE_EVENT_REGISTERED: - status = topologyManager_addExportedService(manager, event->reference, serviceId); + status = topologyManager_addExportedService(manager, event->reference, (char*)serviceId); break; case OSGI_FRAMEWORK_SERVICE_EVENT_MODIFIED: - status = topologyManager_removeExportedService(manager, event->reference, serviceId); + status = topologyManager_removeExportedService(manager, event->reference, (char*)serviceId); if (status == CELIX_SUCCESS) { - status = topologyManager_addExportedService(manager, event->reference, serviceId); + status = topologyManager_addExportedService(manager, event->reference, (char*)serviceId); } break; case OSGI_FRAMEWORK_SERVICE_EVENT_UNREGISTERING: - status = topologyManager_removeExportedService(manager, event->reference, serviceId); + status = topologyManager_removeExportedService(manager, event->reference, (char*)serviceId); break; case OSGI_FRAMEWORK_SERVICE_EVENT_MODIFIED_ENDMATCH: break; @@ -405,7 +405,7 @@ celix_status_t topologyManager_exportScopeChanged(void *handle, char *filterStr) celix_status_t status = CELIX_SUCCESS; topology_manager_pt manager = (topology_manager_pt) handle; service_registration_pt reg = NULL; - char *serviceId = NULL; + const char* serviceId = NULL; bool found; properties_pt props; filter_pt filter = filter_create(filterStr); @@ -436,8 +436,8 @@ celix_status_t topologyManager_exportScopeChanged(void *handle, char *filterStr) status = filter_match(filter, props, &found); if (found) { srvRefs[nrFound] = reference; - serviceReference_getProperty(reference, (char *) OSGI_FRAMEWORK_SERVICE_ID, &serviceId); - srvIds[nrFound++] = serviceId; + serviceReference_getProperty(reference, OSGI_FRAMEWORK_SERVICE_ID, &serviceId); + srvIds[nrFound++] = (char*)serviceId; } } } @@ -448,7 +448,7 @@ celix_status_t topologyManager_exportScopeChanged(void *handle, char *filterStr) if (nrFound > 0) { for (int i = 0; i < nrFound; i++) { // Question: can srvRefs become invalid meanwhile?? - char *export = NULL; + const char* export = NULL; serviceReference_getProperty(srvRefs[i], (char *) OSGI_RSA_SERVICE_EXPORTED_INTERFACES, &export); if (export) { @@ -698,7 +698,7 @@ celix_status_t topologyManager_endpointListenerAdding(void* handle, service_refe celix_status_t topologyManager_endpointListenerAdded(void* handle, service_reference_pt reference, void* service) { celix_status_t status = CELIX_SUCCESS; topology_manager_pt manager = handle; - char *scope = NULL; + const char* scope = NULL; logHelper_log(manager->loghelper, OSGI_LOGSERVICE_INFO, "TOPOLOGY_MANAGER: Added ENDPOINT_LISTENER"); @@ -706,7 +706,7 @@ celix_status_t topologyManager_endpointListenerAdded(void* handle, service_refer hashMap_put(manager->listenerList, reference, NULL); celixThreadMutex_unlock(&manager->listenerListLock); - serviceReference_getProperty(reference, (char *) OSGI_ENDPOINT_LISTENER_SCOPE, &scope); + serviceReference_getProperty(reference, OSGI_ENDPOINT_LISTENER_SCOPE, &scope); filter_pt filter = filter_create(scope); hash_map_iterator_pt refIter = hashMapIterator_create(manager->exportedServices); @@ -733,7 +733,7 @@ celix_status_t topologyManager_endpointListenerAdded(void* handle, service_refer filter_match(filter, endpoint->properties, &matchResult); if (matchResult) { endpoint_listener_pt listener = (endpoint_listener_pt) service; - status = listener->endpointAdded(listener->handle, endpoint, scope); + status = listener->endpointAdded(listener->handle, endpoint, (char*)scope); } } } @@ -783,11 +783,11 @@ celix_status_t topologyManager_notifyListenersEndpointAdded(topology_manager_pt hash_map_iterator_pt iter = hashMapIterator_create(manager->listenerList); while (hashMapIterator_hasNext(iter)) { - char *scope = NULL; + const char* scope = NULL; endpoint_listener_pt epl = NULL; service_reference_pt reference = hashMapIterator_nextKey(iter); - serviceReference_getProperty(reference, (char *) OSGI_ENDPOINT_LISTENER_SCOPE, &scope); + serviceReference_getProperty(reference, OSGI_ENDPOINT_LISTENER_SCOPE, &scope); status = bundleContext_getService(manager->context, reference, (void **) &epl); if (status == CELIX_SUCCESS) { @@ -802,7 +802,7 @@ celix_status_t topologyManager_notifyListenersEndpointAdded(topology_manager_pt bool matchResult = false; filter_match(filter, endpoint->properties, &matchResult); if (matchResult) { - status = epl->endpointAdded(epl->handle, endpoint, scope); + status = epl->endpointAdded(epl->handle, endpoint, (char*)scope); } } else { status = substatus; @@ -827,10 +827,10 @@ celix_status_t topologyManager_notifyListenersEndpointRemoved(topology_manager_p endpoint_description_pt endpoint = NULL; endpoint_listener_pt epl = NULL; celix_status_t substatus; - char *scope = NULL; + const char* scope = NULL; service_reference_pt reference = hashMapIterator_nextKey(iter); - serviceReference_getProperty(reference, (char *) OSGI_ENDPOINT_LISTENER_SCOPE, &scope); + serviceReference_getProperty(reference, OSGI_ENDPOINT_LISTENER_SCOPE, &scope); substatus = bundleContext_getService(manager->context, reference, (void **) &epl); @@ -858,9 +858,9 @@ celix_status_t topologyManager_notifyListenersEndpointRemoved(topology_manager_p celix_status_t topologyManager_extendFilter(topology_manager_pt manager, char *filter, char **updatedFilter) { celix_status_t status; bundle_context_pt context = manager->context; - char* uuid = NULL; + const char* uuid = NULL; - status = bundleContext_getProperty(context, (char *) OSGI_FRAMEWORK_FRAMEWORK_UUID, &uuid); + status = bundleContext_getProperty(context, OSGI_FRAMEWORK_FRAMEWORK_UUID, &uuid); if (!uuid) { logHelper_log(manager->loghelper, OSGI_LOGSERVICE_ERROR, "TOPOLOGY_MANAGER: no framework UUID defined?!"); http://git-wip-us.apache.org/repos/asf/celix/blob/2cd57a78/remote_services/topology_manager/tms_tst/disc_mock/disc_mock_activator.c ---------------------------------------------------------------------- diff --git a/remote_services/topology_manager/tms_tst/disc_mock/disc_mock_activator.c b/remote_services/topology_manager/tms_tst/disc_mock/disc_mock_activator.c index 15f128f..53fccd7 100644 --- a/remote_services/topology_manager/tms_tst/disc_mock/disc_mock_activator.c +++ b/remote_services/topology_manager/tms_tst/disc_mock/disc_mock_activator.c @@ -61,10 +61,10 @@ celix_status_t bundleActivator_create(bundle_context_pt context, void **out) { celix_status_t bundleActivator_start(void * userData, bundle_context_pt context) { celix_status_t status; struct disc_mock_activator * act = userData; - char *uuid = NULL; + const char *uuid = NULL; act->reg = NULL; - status = bundleContext_registerService(context, (char *) DISC_MOCK_SERVICE_NAME, act->serv, NULL, &act->reg); + status = bundleContext_registerService(context, DISC_MOCK_SERVICE_NAME, act->serv, NULL, &act->reg); bundleContext_getProperty(context, OSGI_FRAMEWORK_FRAMEWORK_UUID, &uuid); http://git-wip-us.apache.org/repos/asf/celix/blob/2cd57a78/remote_shell/private/src/activator.c ---------------------------------------------------------------------- diff --git a/remote_shell/private/src/activator.c b/remote_shell/private/src/activator.c index 4344258..541eda6 100644 --- a/remote_shell/private/src/activator.c +++ b/remote_shell/private/src/activator.c @@ -131,12 +131,12 @@ static int bundleActivator_getMaximumConnections(bundle_instance_pt bi, bundle_c } static int bundleActivator_getProperty(bundle_instance_pt bi, bundle_context_pt context, char* propertyName, int defaultValue) { - char *strValue = NULL; + const char *strValue = NULL; int value; bundleContext_getProperty(context, propertyName, &strValue); if (strValue != NULL) { - char* endptr = strValue; + char* endptr = (char*)strValue; errno = 0; value = strtol(strValue, &endptr, 10); http://git-wip-us.apache.org/repos/asf/celix/blob/2cd57a78/shell/private/src/inspect_command.c ---------------------------------------------------------------------- diff --git a/shell/private/src/inspect_command.c b/shell/private/src/inspect_command.c index 24a343b..206319b 100644 --- a/shell/private/src/inspect_command.c +++ b/shell/private/src/inspect_command.c @@ -143,7 +143,7 @@ celix_status_t inspectCommand_printExportedServices(bundle_context_pt context, a serviceReference_getPropertyKeys(ref, &keys, &size); for (int k = 0; k < size; k++) { char *key = keys[k]; - char *value = NULL; + const char *value = NULL; serviceReference_getProperty(ref, key, &value); fprintf(outStream, "%s = %s\n", key, value); @@ -239,7 +239,7 @@ celix_status_t inspectCommand_printImportedServices(bundle_context_pt context, a serviceReference_getPropertyKeys(ref, &keys, &size); for (int k = 0; k < size; k++) { char *key = keys[k]; - char *value = NULL; + const char *value = NULL; serviceReference_getProperty(ref, key, &value); fprintf(outStream, "%s = %s\n", key, value); http://git-wip-us.apache.org/repos/asf/celix/blob/2cd57a78/shell/private/src/shell.c ---------------------------------------------------------------------- diff --git a/shell/private/src/shell.c b/shell/private/src/shell.c index 9956ce2..e4fef47 100644 --- a/shell/private/src/shell.c +++ b/shell/private/src/shell.c @@ -110,7 +110,7 @@ celix_status_t shell_destroy(shell_service_pt *shell_service_ptr) { celix_status_t shell_addCommand(shell_pt shell_ptr, service_reference_pt reference_ptr, void *svc) { celix_status_t status = CELIX_SUCCESS; command_service_pt command_ptr = NULL; - char *name_str = NULL; + const char *name_str = NULL; if (!shell_ptr || !reference_ptr) { return CELIX_ILLEGAL_ARGUMENT; @@ -129,7 +129,7 @@ celix_status_t shell_addCommand(shell_pt shell_ptr, service_reference_pt referen } if (status == CELIX_SUCCESS) { - hashMap_put(shell_ptr->command_name_map_ptr, name_str, command_ptr); + hashMap_put(shell_ptr->command_name_map_ptr, (char *)name_str, command_ptr); hashMap_put(shell_ptr->command_reference_map_ptr, reference_ptr, command_ptr); } @@ -147,7 +147,7 @@ celix_status_t shell_removeCommand(shell_pt shell_ptr, service_reference_pt refe celix_status_t status = CELIX_SUCCESS; command_service_pt command_ptr = NULL; - char *name_str = NULL; + const char *name_str = NULL; if (!shell_ptr || !reference_ptr) { status = CELIX_ILLEGAL_ARGUMENT; @@ -168,7 +168,7 @@ celix_status_t shell_removeCommand(shell_pt shell_ptr, service_reference_pt refe } if (status == CELIX_SUCCESS) { - hashMap_remove(shell_ptr->command_name_map_ptr, name_str); + hashMap_remove(shell_ptr->command_name_map_ptr, (char *)name_str); } return status; @@ -220,7 +220,7 @@ celix_status_t shell_getCommandUsage(shell_pt shell_ptr, char *command_name_str, } if (status == CELIX_SUCCESS) { - status = serviceReference_getProperty(reference, "command.usage", usage_pstr); + status = serviceReference_getProperty(reference, "command.usage", (const char**)usage_pstr); } return status; @@ -243,7 +243,7 @@ celix_status_t shell_getCommandDescription(shell_pt shell_ptr, char *command_nam } if (status == CELIX_SUCCESS) { - serviceReference_getProperty(reference, "command.description", command_description_pstr); + serviceReference_getProperty(reference, "command.description", (const char**)command_description_pstr); } return status; @@ -262,7 +262,7 @@ celix_status_t shell_getCommandReference(shell_pt shell_ptr, char *command_name_ while (hashMapIterator_hasNext(iter)) { hash_map_entry_pt entry = hashMapIterator_nextEntry(iter); service_reference_pt reference = hashMapEntry_getKey(entry); - char *name_str = NULL; + const char *name_str = NULL; serviceReference_getProperty(reference, "command.name", &name_str); if (strcmp(name_str, command_name_str) == 0) { *command_reference_ptr = (service_reference_pt) hashMapEntry_getKey(entry);
