From 0c9e3aa9ba3948e88a0241861b75a002085eeccd Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Wed, 30 Sep 2015 11:14:46 +0200 Subject: [PATCH] =?utf8?q?Read-only=20store=20types:=20const=20char=20**?= =?utf8?q?=20=E2=86=92=20const=20char=20*=20const=20*.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This makes it truely read-only. --- src/core/plugin.c | 38 +++++++++++++++++++------------------- src/core/store.c | 4 ++-- src/include/core/store.h | 8 ++++---- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/core/plugin.c b/src/core/plugin.c index 83ef6ea..8977699 100644 --- a/src/core/plugin.c +++ b/src/core/plugin.c @@ -662,7 +662,7 @@ plugin_add_callback(sdb_llist_t **list, const char *type, } /* plugin_add_callback */ static void -get_backend(const char **backends, size_t *backends_num) +get_backend(char **backends, size_t *backends_num) { const sdb_plugin_info_t *info; @@ -1485,7 +1485,7 @@ int sdb_plugin_store_host(const char *name, sdb_time_t last_update) { sdb_store_host_t host = { 0 }; - const char *backends[1]; + char *backends[1]; char *cname; sdb_llist_iter_t *iter; @@ -1508,8 +1508,8 @@ sdb_plugin_store_host(const char *name, sdb_time_t last_update) host.name = cname; host.last_update = last_update; - host.backends = backends; - get_backend(host.backends, &host.backends_num); + host.backends = (const char * const *)backends; + get_backend(backends, &host.backends_num); iter = sdb_llist_get_iter(writer_list); while (sdb_llist_iter_has_next(iter)) { @@ -1530,7 +1530,7 @@ sdb_plugin_store_service(const char *hostname, const char *name, sdb_time_t last_update) { sdb_store_service_t service = { 0 }; - const char *backends[1]; + char *backends[1]; char *cname; sdb_llist_iter_t *iter; @@ -1556,8 +1556,8 @@ sdb_plugin_store_service(const char *hostname, const char *name, service.hostname = cname; service.name = name; service.last_update = last_update; - service.backends = backends; - get_backend(service.backends, &service.backends_num); + service.backends = (const char * const *)backends; + get_backend(backends, &service.backends_num); iter = sdb_llist_get_iter(writer_list); while (sdb_llist_iter_has_next(iter)) { @@ -1588,7 +1588,7 @@ sdb_plugin_store_metric(const char *hostname, const char *name, sdb_metric_store_t *store, sdb_time_t last_update) { sdb_store_metric_t metric = { 0 }; - const char *backends[1]; + char *backends[1]; char *cname; sdb_llist_iter_t *iter; @@ -1621,8 +1621,8 @@ sdb_plugin_store_metric(const char *hostname, const char *name, metric.store.id = store->id; } metric.last_update = last_update; - metric.backends = backends; - get_backend(metric.backends, &metric.backends_num); + metric.backends = (const char * const *)backends; + get_backend(backends, &metric.backends_num); iter = sdb_llist_get_iter(writer_list); while (sdb_llist_iter_has_next(iter)) { @@ -1653,7 +1653,7 @@ sdb_plugin_store_attribute(const char *hostname, const char *key, const sdb_data_t *value, sdb_time_t last_update) { sdb_store_attribute_t attr = { 0 }; - const char *backends[1]; + char *backends[1]; char *cname; sdb_llist_iter_t *iter; @@ -1679,8 +1679,8 @@ sdb_plugin_store_attribute(const char *hostname, const char *key, attr.key = key; attr.value = *value; attr.last_update = last_update; - attr.backends = backends; - get_backend(attr.backends, &attr.backends_num); + attr.backends = (const char * const *)backends; + get_backend(backends, &attr.backends_num); iter = sdb_llist_get_iter(writer_list); while (sdb_llist_iter_has_next(iter)) { @@ -1701,7 +1701,7 @@ sdb_plugin_store_service_attribute(const char *hostname, const char *service, const char *key, const sdb_data_t *value, sdb_time_t last_update) { sdb_store_attribute_t attr = { 0 }; - const char *backends[1]; + char *backends[1]; char *cname; sdb_llist_iter_t *iter; @@ -1728,8 +1728,8 @@ sdb_plugin_store_service_attribute(const char *hostname, const char *service, attr.key = key; attr.value = *value; attr.last_update = last_update; - attr.backends = backends; - get_backend(attr.backends, &attr.backends_num); + attr.backends = (const char * const *)backends; + get_backend(backends, &attr.backends_num); iter = sdb_llist_get_iter(writer_list); while (sdb_llist_iter_has_next(iter)) { @@ -1750,7 +1750,7 @@ sdb_plugin_store_metric_attribute(const char *hostname, const char *metric, const char *key, const sdb_data_t *value, sdb_time_t last_update) { sdb_store_attribute_t attr = { 0 }; - const char *backends[1]; + char *backends[1]; char *cname; sdb_llist_iter_t *iter; @@ -1777,8 +1777,8 @@ sdb_plugin_store_metric_attribute(const char *hostname, const char *metric, attr.key = key; attr.value = *value; attr.last_update = last_update; - attr.backends = backends; - get_backend(attr.backends, &attr.backends_num); + attr.backends = (const char * const *)backends; + get_backend(backends, &attr.backends_num); iter = sdb_llist_get_iter(writer_list); while (sdb_llist_iter_has_next(iter)) { diff --git a/src/core/store.c b/src/core/store.c index c6e22df..0a23513 100644 --- a/src/core/store.c +++ b/src/core/store.c @@ -66,7 +66,7 @@ typedef struct { int type; const char *name; sdb_time_t last_update; - const char **backends; + const char * const *backends; size_t backends_num; } store_obj_t; #define STORE_OBJ_INIT { NULL, NULL, 0, NULL, 0, NULL, 0 } @@ -307,7 +307,7 @@ static sdb_type_t attribute_type = { static int record_backends(sdb_store_obj_t *obj, - const char **backends, size_t backends_num) + const char * const *backends, size_t backends_num) { char **tmp; size_t i; diff --git a/src/include/core/store.h b/src/include/core/store.h index bccb792..ea0cd97 100644 --- a/src/include/core/store.h +++ b/src/include/core/store.h @@ -118,7 +118,7 @@ typedef struct { sdb_time_t last_update; sdb_time_t interval; - const char **backends; + const char * const *backends; size_t backends_num; } sdb_store_host_t; @@ -131,7 +131,7 @@ typedef struct { sdb_time_t last_update; sdb_time_t interval; - const char **backends; + const char * const *backends; size_t backends_num; } sdb_store_service_t; @@ -156,7 +156,7 @@ typedef struct { sdb_time_t last_update; sdb_time_t interval; - const char **backends; + const char * const *backends; size_t backends_num; } sdb_store_metric_t; @@ -172,7 +172,7 @@ typedef struct { sdb_time_t last_update; sdb_time_t interval; - const char **backends; + const char * const *backends; size_t backends_num; } sdb_store_attribute_t; -- 2.30.2