From cc9d98f8f18466fa98496c21ef05433385e7442e Mon Sep 17 00:00:00 2001 From: Alexander Bushnev Date: Thu, 12 Sep 2024 15:00:15 +0200 Subject: [PATCH 1/4] Remove const from closure params --- include/zenoh-pico/api/handlers.h | 2 +- include/zenoh-pico/api/macros.h | 20 ++++++++++---------- include/zenoh-pico/api/types.h | 24 ++++++++++++------------ include/zenoh-pico/session/session.h | 6 +++--- src/api/api.c | 10 +++++----- 5 files changed, 31 insertions(+), 31 deletions(-) diff --git a/include/zenoh-pico/api/handlers.h b/include/zenoh-pico/api/handlers.h index 25b4444df..60c59423d 100644 --- a/include/zenoh-pico/api/handlers.h +++ b/include/zenoh-pico/api/handlers.h @@ -53,7 +53,7 @@ extern "C" { _Z_ERROR("%s failed: %i", #collection_push_f, ret); \ } \ } \ - static inline void _z_##handler_name##_send(const elem_loaned_type *elem, void *context) { \ + static inline void _z_##handler_name##_send(elem_loaned_type *elem, void *context) { \ elem_owned_type *internal_elem = (elem_owned_type *)z_malloc(sizeof(elem_owned_type)); \ if (internal_elem == NULL) { \ _Z_ERROR("Out of memory"); \ diff --git a/include/zenoh-pico/api/macros.h b/include/zenoh-pico/api/macros.h index acbfb89f5..65f886eb3 100644 --- a/include/zenoh-pico/api/macros.h +++ b/include/zenoh-pico/api/macros.h @@ -503,20 +503,20 @@ inline bool z_internal_check(const z_owned_ring_handler_reply_t& v) { return z_i inline bool z_internal_check(const z_owned_ring_handler_sample_t& v) { return z_internal_ring_handler_sample_check(&v); }; // z_call definition -inline void z_call(const z_loaned_closure_sample_t &closure, const z_loaned_sample_t *sample) +inline void z_call(const z_loaned_closure_sample_t &closure, z_loaned_sample_t *sample) { z_closure_sample_call(&closure, sample); } -inline void z_call(const z_loaned_closure_query_t &closure, const z_loaned_query_t *query) +inline void z_call(const z_loaned_closure_query_t &closure, z_loaned_query_t *query) { z_closure_query_call(&closure, query); } -inline void z_call(const z_loaned_closure_reply_t &closure, const z_loaned_reply_t *reply) +inline void z_call(const z_loaned_closure_reply_t &closure, z_loaned_reply_t *reply) { z_closure_reply_call(&closure, reply); } -inline void z_call(const z_loaned_closure_hello_t &closure, const z_loaned_hello_t *hello) +inline void z_call(const z_loaned_closure_hello_t &closure, z_loaned_hello_t *hello) { z_closure_hello_call(&closure, hello); } -inline void z_call(const z_loaned_closure_zid_t &closure, const z_id_t *zid) +inline void z_call(const z_loaned_closure_zid_t &closure, z_id_t *zid) { z_closure_zid_call(&closure, zid); } inline void z_closure( z_owned_closure_hello_t* closure, - void (*call)(const z_loaned_hello_t*, void*), + void (*call)(z_loaned_hello_t*, void*), void (*drop)(void*) = NULL, void *context = NULL) { closure->_val.context = context; @@ -525,7 +525,7 @@ inline void z_closure( }; inline void z_closure( z_owned_closure_query_t* closure, - void (*call)(const z_loaned_query_t*, void*), + void (*call)(z_loaned_query_t*, void*), void (*drop)(void*) = NULL, void *context = NULL) { closure->_val.context = context; @@ -534,7 +534,7 @@ inline void z_closure( }; inline void z_closure( z_owned_closure_reply_t* closure, - void (*call)(const z_loaned_reply_t*, void*), + void (*call)(z_loaned_reply_t*, void*), void (*drop)(void*) = NULL, void *context = NULL) { closure->_val.context = context; @@ -543,7 +543,7 @@ inline void z_closure( }; inline void z_closure( z_owned_closure_sample_t* closure, - void (*call)(const z_loaned_sample_t*, void*), + void (*call)(z_loaned_sample_t*, void*), void (*drop)(void*) = NULL, void *context = NULL) { closure->_val.context = context; @@ -552,7 +552,7 @@ inline void z_closure( }; inline void z_closure( z_owned_closure_zid_t* closure, - void (*call)(const z_id_t*, void*), + void (*call)(z_id_t*, void*), void (*drop)(void*) = NULL, void *context = NULL) { closure->_val.context = context; diff --git a/include/zenoh-pico/api/types.h b/include/zenoh-pico/api/types.h index 9b7e702d3..252c52152 100644 --- a/include/zenoh-pico/api/types.h +++ b/include/zenoh-pico/api/types.h @@ -503,12 +503,12 @@ typedef struct { * * Members: * void *context: a pointer to an arbitrary state. - * z_data_handler_t call: `void *call(const struct z_sample_t*, const void *context)` is the callback function. + * z_data_handler_t call: `void *call(z_loaned_sample_t*, const void *context)` is the callback function. * z_dropper_handler_t drop: `void *drop(void*)` allows the callback's state to be freed. */ _Z_OWNED_TYPE_VALUE(_z_closure_sample_t, closure_sample) -void z_closure_sample_call(const z_loaned_closure_sample_t *closure, const z_loaned_sample_t *sample); +void z_closure_sample_call(const z_loaned_closure_sample_t *closure, z_loaned_sample_t *sample); typedef _z_queryable_handler_t z_queryable_handler_t; @@ -524,14 +524,14 @@ typedef struct { * * Members: * void *context: a pointer to an arbitrary state. - * _z_queryable_handler_t call: `void (*_z_queryable_handler_t)(z_query_t *query, void *arg)` is the + * _z_queryable_handler_t call: `void (*_z_queryable_handler_t)(z_loaned_query_t *query, void *arg)` is the * callback function. * z_dropper_handler_t drop: `void *drop(void*)` allows the callback's state to be freed. * void *context: a pointer to an arbitrary state. */ _Z_OWNED_TYPE_VALUE(_z_closure_query_t, closure_query) -void z_closure_query_call(const z_loaned_closure_query_t *closure, const z_loaned_query_t *query); +void z_closure_query_call(const z_loaned_closure_query_t *closure, z_loaned_query_t *query); typedef _z_reply_handler_t z_reply_handler_t; @@ -547,16 +547,16 @@ typedef struct { * * Members: * void *context: a pointer to an arbitrary state. - * z_reply_handler_t call: `void (*_z_reply_handler_t)(_z_reply_t *reply, void *arg)` is the + * z_reply_handler_t call: `void (*_z_reply_handler_t)(z_loaned_reply_t *reply, void *arg)` is the * callback function. * z_dropper_handler_t drop: `void *drop(void*)` allows the callback's state to be freed. * void *context: a pointer to an arbitrary state. */ _Z_OWNED_TYPE_VALUE(_z_closure_reply_t, closure_reply) -void z_closure_reply_call(const z_loaned_closure_reply_t *closure, const z_loaned_reply_t *reply); +void z_closure_reply_call(const z_loaned_closure_reply_t *closure, z_loaned_reply_t *reply); -typedef void (*z_loaned_hello_handler_t)(const z_loaned_hello_t *hello, void *arg); +typedef void (*z_loaned_hello_handler_t)(z_loaned_hello_t *hello, void *arg); typedef struct { void *context; @@ -570,16 +570,16 @@ typedef struct { * * Members: * void *context: a pointer to an arbitrary state. - * z_loaned_hello_handler_t call: `void (*z_loaned_hello_handler_t)(const z_loaned_hello_t *hello, void *arg)` is the + * z_loaned_hello_handler_t call: `void (*z_loaned_hello_handler_t)(z_loaned_hello_t *hello, void *arg)` is the * callback function. * z_dropper_handler_t drop: `void *drop(void*)` allows the callback's state to be freed. * void *context: a pointer to an arbitrary state. */ _Z_OWNED_TYPE_VALUE(_z_closure_hello_t, closure_hello) -void z_closure_hello_call(const z_loaned_closure_hello_t *closure, const z_loaned_hello_t *hello); +void z_closure_hello_call(const z_loaned_closure_hello_t *closure, z_loaned_hello_t *hello); -typedef void (*z_id_handler_t)(const z_id_t *id, void *arg); +typedef void (*z_id_handler_t)(z_id_t *id, void *arg); typedef struct { void *context; @@ -593,13 +593,13 @@ typedef struct { * * Members: * void *context: a pointer to an arbitrary state. - * z_id_handler_t call: `void (*z_id_handler_t)(const z_id_t *id, void *arg)` is the callback function. + * z_id_handler_t call: `void (*z_id_handler_t)(z_id_t *id, void *arg)` is the callback function. * z_dropper_handler_t drop: `void *drop(void*)` allows the callback's state to be freed. * void *context: a pointer to an arbitrary state. */ _Z_OWNED_TYPE_VALUE(_z_closure_zid_t, closure_zid) -void z_closure_zid_call(const z_loaned_closure_zid_t *closure, const z_id_t *id); +void z_closure_zid_call(const z_loaned_closure_zid_t *closure, z_id_t *id); #ifdef __cplusplus } diff --git a/include/zenoh-pico/session/session.h b/include/zenoh-pico/session/session.h index c91b4d979..592a483ae 100644 --- a/include/zenoh-pico/session/session.h +++ b/include/zenoh-pico/session/session.h @@ -54,7 +54,7 @@ typedef struct _z_sample_t _z_sample_t; /** * The callback signature of the functions handling data messages. */ -typedef void (*_z_data_handler_t)(const _z_sample_t *sample, void *arg); +typedef void (*_z_data_handler_t)(_z_sample_t *sample, void *arg); typedef struct { _z_keyexpr_t _key; @@ -85,7 +85,7 @@ typedef struct _z_query_rc_t _z_query_rc_t; /** * The callback signature of the functions handling query messages. */ -typedef void (*_z_queryable_handler_t)(const _z_query_rc_t *query, void *arg); +typedef void (*_z_queryable_handler_t)(_z_query_rc_t *query, void *arg); typedef struct { _z_keyexpr_t _key; @@ -114,7 +114,7 @@ typedef struct _z_reply_t _z_reply_t; /** * The callback signature of the functions handling query replies. */ -typedef void (*_z_reply_handler_t)(const _z_reply_t *reply, void *arg); +typedef void (*_z_reply_handler_t)(_z_reply_t *reply, void *arg); typedef struct { _z_keyexpr_t _key; diff --git a/src/api/api.c b/src/api/api.c index 2bd60f512..6faab5736 100644 --- a/src/api/api.c +++ b/src/api/api.c @@ -712,31 +712,31 @@ const z_loaned_encoding_t *z_query_encoding(const z_loaned_query_t *query) { return &_Z_RC_IN_VAL(query)->_value.encoding; } -void z_closure_sample_call(const z_loaned_closure_sample_t *closure, const z_loaned_sample_t *sample) { +void z_closure_sample_call(const z_loaned_closure_sample_t *closure, z_loaned_sample_t *sample) { if (closure->call != NULL) { (closure->call)(sample, closure->context); } } -void z_closure_query_call(const z_loaned_closure_query_t *closure, const z_loaned_query_t *query) { +void z_closure_query_call(const z_loaned_closure_query_t *closure, z_loaned_query_t *query) { if (closure->call != NULL) { (closure->call)(query, closure->context); } } -void z_closure_reply_call(const z_loaned_closure_reply_t *closure, const z_loaned_reply_t *reply) { +void z_closure_reply_call(const z_loaned_closure_reply_t *closure, z_loaned_reply_t *reply) { if (closure->call != NULL) { (closure->call)(reply, closure->context); } } -void z_closure_hello_call(const z_loaned_closure_hello_t *closure, const z_loaned_hello_t *hello) { +void z_closure_hello_call(const z_loaned_closure_hello_t *closure, z_loaned_hello_t *hello) { if (closure->call != NULL) { (closure->call)(hello, closure->context); } } -void z_closure_zid_call(const z_loaned_closure_zid_t *closure, const z_id_t *id) { +void z_closure_zid_call(const z_loaned_closure_zid_t *closure, z_id_t *id) { if (closure->call != NULL) { (closure->call)(id, closure->context); } From 413071ef4b5d82f80bc073f8ca5585949f2b4bf1 Mon Sep 17 00:00:00 2001 From: Alexander Bushnev Date: Thu, 12 Sep 2024 15:00:27 +0200 Subject: [PATCH 2/4] Update tests for remove const from closure params --- tests/z_api_alignment_test.c | 10 +++++----- tests/z_client_test.c | 6 +++--- tests/z_peer_multicast_test.c | 2 +- tests/z_perf_rx.c | 2 +- tests/z_test_fragment_rx.c | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/z_api_alignment_test.c b/tests/z_api_alignment_test.c index cd4279fce..a53be3b3a 100644 --- a/tests/z_api_alignment_test.c +++ b/tests/z_api_alignment_test.c @@ -44,7 +44,7 @@ const char *value = "Test value"; volatile unsigned int zids = 0; -void zid_handler(const z_id_t *id, void *arg) { +void zid_handler(z_id_t *id, void *arg) { (void)(arg); (void)(id); printf("%s\n", __func__); @@ -52,7 +52,7 @@ void zid_handler(const z_id_t *id, void *arg) { } volatile unsigned int hellos = 0; -void hello_handler(const z_loaned_hello_t *hello, void *arg) { +void hello_handler(z_loaned_hello_t *hello, void *arg) { (void)hello; (void)(arg); printf("%s\n", __func__); @@ -60,7 +60,7 @@ void hello_handler(const z_loaned_hello_t *hello, void *arg) { } volatile unsigned int queries = 0; -void query_handler(const z_loaned_query_t *query, void *arg) { +void query_handler(z_loaned_query_t *query, void *arg) { printf("%s\n", __func__); queries++; @@ -86,7 +86,7 @@ void query_handler(const z_loaned_query_t *query, void *arg) { } volatile unsigned int replies = 0; -void reply_handler(const z_loaned_reply_t *reply, void *arg) { +void reply_handler(z_loaned_reply_t *reply, void *arg) { printf("%s\n", __func__); replies++; (void)arg; @@ -105,7 +105,7 @@ void reply_handler(const z_loaned_reply_t *reply, void *arg) { } volatile unsigned int datas = 0; -void data_handler(const z_loaned_sample_t *sample, void *arg) { +void data_handler(z_loaned_sample_t *sample, void *arg) { printf("%s\n", __func__); datas++; diff --git a/tests/z_client_test.c b/tests/z_client_test.c index 0f6c1e4d1..fa75dda86 100644 --- a/tests/z_client_test.c +++ b/tests/z_client_test.c @@ -48,7 +48,7 @@ z_owned_keyexpr_t rids2[SET]; volatile unsigned int total = 0; volatile unsigned int queries = 0; -void query_handler(const z_loaned_query_t *query, void *arg) { +void query_handler(z_loaned_query_t *query, void *arg) { char *res = (char *)malloc(64); snprintf(res, 64, "%s%u", uri, *(unsigned int *)arg); printf(">> Received query: %s\t(%u/%u)\n", res, queries, total); @@ -72,7 +72,7 @@ void query_handler(const z_loaned_query_t *query, void *arg) { } volatile unsigned int replies = 0; -void reply_handler(const z_loaned_reply_t *reply, void *arg) { +void reply_handler(z_loaned_reply_t *reply, void *arg) { char *res = (char *)malloc(64); snprintf(res, 64, "%s%u", uri, *(unsigned int *)arg); if (z_reply_is_ok(reply)) { @@ -97,7 +97,7 @@ void reply_handler(const z_loaned_reply_t *reply, void *arg) { } volatile unsigned int datas = 0; -void data_handler(const z_loaned_sample_t *sample, void *arg) { +void data_handler(z_loaned_sample_t *sample, void *arg) { char *res = (char *)malloc(64); snprintf(res, 64, "%s%u", uri, *(unsigned int *)arg); printf(">> Received data: %s\t(%u/%u)\n", res, datas, total); diff --git a/tests/z_peer_multicast_test.c b/tests/z_peer_multicast_test.c index 1bd5ff9fb..23e477ec4 100644 --- a/tests/z_peer_multicast_test.c +++ b/tests/z_peer_multicast_test.c @@ -41,7 +41,7 @@ _z_list_t *subs2 = NULL; volatile unsigned int total = 0; volatile unsigned int datas = 0; -void data_handler(const z_loaned_sample_t *sample, void *arg) { +void data_handler(z_loaned_sample_t *sample, void *arg) { char *res = (char *)malloc(64); snprintf(res, 64, "%s%u", uri, *(unsigned int *)arg); printf(">> Received data: %s\t(%u/%u)\n", res, datas, total); diff --git a/tests/z_perf_rx.c b/tests/z_perf_rx.c index 52c309f56..442c5ac5c 100644 --- a/tests/z_perf_rx.c +++ b/tests/z_perf_rx.c @@ -39,7 +39,7 @@ void z_stats_stop(z_stats_t *stats) { stats->count = 0; } -void on_sample(const z_loaned_sample_t *sample, void *context) { +void on_sample(z_loaned_sample_t *sample, void *context) { z_stats_t *stats = (z_stats_t *)context; z_owned_slice_t value; z_bytes_deserialize_into_slice(z_sample_payload(sample), &value); diff --git a/tests/z_test_fragment_rx.c b/tests/z_test_fragment_rx.c index 76eff0767..f550343bd 100644 --- a/tests/z_test_fragment_rx.c +++ b/tests/z_test_fragment_rx.c @@ -18,7 +18,7 @@ #include #if Z_FEATURE_SUBSCRIPTION == 1 -void data_handler(const z_loaned_sample_t *sample, void *ctx) { +void data_handler(z_loaned_sample_t *sample, void *ctx) { (void)(ctx); z_view_string_t keystr; z_keyexpr_as_view_string(z_sample_keyexpr(sample), &keystr); From 0733d7cf45b77fd3157641a66a793d9f0a58af58 Mon Sep 17 00:00:00 2001 From: Alexander Bushnev Date: Thu, 12 Sep 2024 15:00:52 +0200 Subject: [PATCH 3/4] Update examples for remove const from closure params --- examples/arduino/z_get.ino | 2 +- examples/arduino/z_queryable.ino | 2 +- examples/arduino/z_scout.ino | 2 +- examples/arduino/z_sub.ino | 2 +- examples/espidf/z_get.c | 2 +- examples/espidf/z_queryable.c | 2 +- examples/espidf/z_scout.c | 2 +- examples/espidf/z_sub.c | 2 +- examples/freertos_plus_tcp/z_get.c | 2 +- examples/freertos_plus_tcp/z_queryable.c | 2 +- examples/freertos_plus_tcp/z_scout.c | 2 +- examples/freertos_plus_tcp/z_sub.c | 2 +- examples/freertos_plus_tcp/z_sub_st.c | 2 +- examples/mbed/z_get.cpp | 2 +- examples/mbed/z_queryable.cpp | 2 +- examples/mbed/z_scout.cpp | 2 +- examples/mbed/z_sub.cpp | 2 +- examples/unix/c11/z_get.c | 2 +- examples/unix/c11/z_get_attachment.c | 2 +- examples/unix/c11/z_info.c | 2 +- examples/unix/c11/z_ping.c | 2 +- examples/unix/c11/z_pong.c | 2 +- examples/unix/c11/z_queryable.c | 2 +- examples/unix/c11/z_queryable_attachment.c | 2 +- examples/unix/c11/z_scout.c | 2 +- examples/unix/c11/z_sub.c | 2 +- examples/unix/c11/z_sub_attachment.c | 2 +- examples/unix/c11/z_sub_st.c | 2 +- examples/unix/c11/z_sub_thr.c | 2 +- examples/unix/c99/z_get.c | 2 +- examples/unix/c99/z_info.c | 2 +- examples/unix/c99/z_ping.c | 2 +- examples/unix/c99/z_pong.c | 2 +- examples/unix/c99/z_queryable.c | 2 +- examples/unix/c99/z_scout.c | 2 +- examples/unix/c99/z_sub.c | 2 +- examples/unix/c99/z_sub_st.c | 2 +- examples/windows/z_get.c | 2 +- examples/windows/z_info.c | 2 +- examples/windows/z_ping.c | 2 +- examples/windows/z_pong.c | 2 +- examples/windows/z_queryable.c | 2 +- examples/windows/z_scout.c | 2 +- examples/windows/z_sub.c | 2 +- examples/windows/z_sub_st.c | 2 +- examples/zephyr/z_get.c | 2 +- examples/zephyr/z_queryable.c | 2 +- examples/zephyr/z_scout.c | 2 +- examples/zephyr/z_sub.c | 2 +- 49 files changed, 49 insertions(+), 49 deletions(-) diff --git a/examples/arduino/z_get.ino b/examples/arduino/z_get.ino index 18030d77e..bb4658a31 100644 --- a/examples/arduino/z_get.ino +++ b/examples/arduino/z_get.ino @@ -38,7 +38,7 @@ void reply_dropper(void *ctx) { Serial.println(" >> Received query final notification"); } -void reply_handler(const z_loaned_reply_t *oreply, void *ctx) { +void reply_handler(z_loaned_reply_t *oreply, void *ctx) { (void)(ctx); if (z_reply_is_ok(oreply)) { const z_loaned_sample_t *sample = z_reply_ok(oreply); diff --git a/examples/arduino/z_queryable.ino b/examples/arduino/z_queryable.ino index 591cf1598..8f37c68ab 100644 --- a/examples/arduino/z_queryable.ino +++ b/examples/arduino/z_queryable.ino @@ -34,7 +34,7 @@ z_owned_session_t s; z_owned_queryable_t qable; -void query_handler(const z_loaned_query_t *query, void *arg) { +void query_handler(z_loaned_query_t *query, void *arg) { z_view_string_t keystr; z_keyexpr_as_view_string(z_query_keyexpr(query), &keystr); Serial.print(" >> [Queryable handler] Received Query '"); diff --git a/examples/arduino/z_scout.ino b/examples/arduino/z_scout.ino index 7af5da089..17d033100 100644 --- a/examples/arduino/z_scout.ino +++ b/examples/arduino/z_scout.ino @@ -75,7 +75,7 @@ void fprinthello(const z_loaned_hello_t *hello) { Serial.println(" }"); } -void callback(const z_loaned_hello_t *hello, void *context) { +void callback(z_loaned_hello_t *hello, void *context) { fprinthello(hello); Serial.println(""); (*(int *)context)++; diff --git a/examples/arduino/z_sub.ino b/examples/arduino/z_sub.ino index 8b12c333c..fa612fbf5 100644 --- a/examples/arduino/z_sub.ino +++ b/examples/arduino/z_sub.ino @@ -33,7 +33,7 @@ z_owned_session_t s; z_owned_subscriber_t sub; -void data_handler(const z_loaned_sample_t *sample, void *arg) { +void data_handler(z_loaned_sample_t *sample, void *arg) { z_view_string_t keystr; z_keyexpr_as_view_string(z_sample_keyexpr(sample), &keystr); z_owned_string_t value; diff --git a/examples/espidf/z_get.c b/examples/espidf/z_get.c index fdc04e30d..090284579 100644 --- a/examples/espidf/z_get.c +++ b/examples/espidf/z_get.c @@ -103,7 +103,7 @@ void wifi_init_sta(void) { void reply_dropper(void *ctx) { printf(" >> Received query final notification\n"); } -void reply_handler(const z_loaned_reply_t *oreply, void *ctx) { +void reply_handler(z_loaned_reply_t *oreply, void *ctx) { if (z_reply_is_ok(oreply)) { const z_loaned_sample_t *sample = z_reply_ok(oreply); z_view_string_t keystr; diff --git a/examples/espidf/z_queryable.c b/examples/espidf/z_queryable.c index b7a11e26a..3aeed6cb6 100644 --- a/examples/espidf/z_queryable.c +++ b/examples/espidf/z_queryable.c @@ -101,7 +101,7 @@ void wifi_init_sta(void) { vEventGroupDelete(s_event_group_handler); } -void query_handler(const z_loaned_query_t *query, void *ctx) { +void query_handler(z_loaned_query_t *query, void *ctx) { (void)(ctx); z_view_string_t keystr; z_keyexpr_as_view_string(z_query_keyexpr(query), &keystr); diff --git a/examples/espidf/z_scout.c b/examples/espidf/z_scout.c index 9866a2806..a8adc731d 100644 --- a/examples/espidf/z_scout.c +++ b/examples/espidf/z_scout.c @@ -129,7 +129,7 @@ void fprinthello(FILE *stream, const z_loaned_hello_t *hello) { fprintf(stream, " }"); } -void callback(const z_loaned_hello_t *hello, void *context) { +void callback(z_loaned_hello_t *hello, void *context) { fprinthello(stdout, hello); fprintf(stdout, "\n"); (*(int *)context)++; diff --git a/examples/espidf/z_sub.c b/examples/espidf/z_sub.c index 735096158..3d4653f9b 100644 --- a/examples/espidf/z_sub.c +++ b/examples/espidf/z_sub.c @@ -100,7 +100,7 @@ void wifi_init_sta(void) { vEventGroupDelete(s_event_group_handler); } -void data_handler(const z_loaned_sample_t* sample, void* arg) { +void data_handler(z_loaned_sample_t* sample, void* arg) { z_view_string_t keystr; z_keyexpr_as_view_string(z_sample_keyexpr(sample), &keystr); z_owned_string_t value; diff --git a/examples/freertos_plus_tcp/z_get.c b/examples/freertos_plus_tcp/z_get.c index dc1056046..c71c5b48a 100644 --- a/examples/freertos_plus_tcp/z_get.c +++ b/examples/freertos_plus_tcp/z_get.c @@ -36,7 +36,7 @@ void reply_dropper(void *ctx) { printf(">> Received query final notification\n"); } -void reply_handler(const z_loaned_reply_t *reply, void *ctx) { +void reply_handler(z_loaned_reply_t *reply, void *ctx) { (void)(ctx); if (z_reply_is_ok(reply)) { const z_loaned_sample_t *sample = z_reply_ok(reply); diff --git a/examples/freertos_plus_tcp/z_queryable.c b/examples/freertos_plus_tcp/z_queryable.c index 5cb3bb420..4504e46e1 100644 --- a/examples/freertos_plus_tcp/z_queryable.c +++ b/examples/freertos_plus_tcp/z_queryable.c @@ -29,7 +29,7 @@ #define KEYEXPR "demo/example/zenoh-pico-queryable" #define VALUE "[FreeRTOS-Plus-TCP] Queryable from Zenoh-Pico!" -void query_handler(const z_loaned_query_t *query, void *ctx) { +void query_handler(z_loaned_query_t *query, void *ctx) { (void)(ctx); z_view_string_t keystr; z_keyexpr_as_view_string(z_query_keyexpr(query), &keystr); diff --git a/examples/freertos_plus_tcp/z_scout.c b/examples/freertos_plus_tcp/z_scout.c index 0f59f2416..5a5e45c65 100644 --- a/examples/freertos_plus_tcp/z_scout.c +++ b/examples/freertos_plus_tcp/z_scout.c @@ -63,7 +63,7 @@ void fprinthello(FILE *stream, const z_loaned_hello_t *hello) { fprintf(stream, " }"); } -void callback(const z_loaned_hello_t *hello, void *context) { +void callback(z_loaned_hello_t *hello, void *context) { fprinthello(stdout, hello); fprintf(stdout, "\n"); (*(int *)context)++; diff --git a/examples/freertos_plus_tcp/z_sub.c b/examples/freertos_plus_tcp/z_sub.c index af24f128a..9f8f1610a 100644 --- a/examples/freertos_plus_tcp/z_sub.c +++ b/examples/freertos_plus_tcp/z_sub.c @@ -28,7 +28,7 @@ #define KEYEXPR "demo/example/**" -void data_handler(const z_loaned_sample_t *sample, void *ctx) { +void data_handler(z_loaned_sample_t *sample, void *ctx) { (void)(ctx); z_view_string_t keystr; z_keyexpr_as_view_string(z_sample_keyexpr(sample), &keystr); diff --git a/examples/freertos_plus_tcp/z_sub_st.c b/examples/freertos_plus_tcp/z_sub_st.c index d2ec34047..7d3468216 100644 --- a/examples/freertos_plus_tcp/z_sub_st.c +++ b/examples/freertos_plus_tcp/z_sub_st.c @@ -31,7 +31,7 @@ int msg_nb = 0; -void data_handler(const z_loaned_sample_t *sample, void *ctx) { +void data_handler(z_loaned_sample_t *sample, void *ctx) { (void)(ctx); z_view_string_t keystr; z_keyexpr_as_view_string(z_sample_keyexpr(sample), &keystr); diff --git a/examples/mbed/z_get.cpp b/examples/mbed/z_get.cpp index 1e4c89580..7939e1bce 100644 --- a/examples/mbed/z_get.cpp +++ b/examples/mbed/z_get.cpp @@ -33,7 +33,7 @@ void reply_dropper(void *ctx) { printf(" >> Received query final notification\n"); } -void reply_handler(const z_loaned_reply_t *oreply, void *ctx) { +void reply_handler(z_loaned_reply_t *oreply, void *ctx) { if (z_reply_is_ok(oreply)) { const z_loaned_sample_t *sample = z_reply_ok(oreply); z_view_string_t keystr; diff --git a/examples/mbed/z_queryable.cpp b/examples/mbed/z_queryable.cpp index fc5427443..0732c5033 100644 --- a/examples/mbed/z_queryable.cpp +++ b/examples/mbed/z_queryable.cpp @@ -31,7 +31,7 @@ #define KEYEXPR "demo/example/zenoh-pico-queryable" #define VALUE "[MBedOS]{nucleo-F767ZI} Queryable from Zenoh-Pico!" -void query_handler(const z_loaned_query_t *query, void *ctx) { +void query_handler(z_loaned_query_t *query, void *ctx) { (void)(ctx); z_view_string_t keystr; z_keyexpr_as_view_string(z_query_keyexpr(query), &keystr); diff --git a/examples/mbed/z_scout.cpp b/examples/mbed/z_scout.cpp index c227acabc..2d9f71b69 100644 --- a/examples/mbed/z_scout.cpp +++ b/examples/mbed/z_scout.cpp @@ -71,7 +71,7 @@ void fprinthello(FILE *stream, const z_loaned_hello_t *hello) { fprintf(stream, " }"); } -void callback(const z_loaned_hello_t *hello, void *context) { +void callback(z_loaned_hello_t *hello, void *context) { fprinthello(stdout, hello); fprintf(stdout, "\n"); (*(int *)context)++; diff --git a/examples/mbed/z_sub.cpp b/examples/mbed/z_sub.cpp index fe58c2d12..6f8576cf4 100644 --- a/examples/mbed/z_sub.cpp +++ b/examples/mbed/z_sub.cpp @@ -30,7 +30,7 @@ #define KEYEXPR "demo/example/**" -void data_handler(const z_loaned_sample_t *sample, void *arg) { +void data_handler(z_loaned_sample_t *sample, void *arg) { z_view_string_t keystr; z_keyexpr_as_view_string(z_sample_keyexpr(sample), &keystr); z_owned_string_t value; diff --git a/examples/unix/c11/z_get.c b/examples/unix/c11/z_get.c index f06217a6b..db0bf816a 100644 --- a/examples/unix/c11/z_get.c +++ b/examples/unix/c11/z_get.c @@ -31,7 +31,7 @@ void reply_dropper(void *ctx) { z_drop(z_move(cond)); } -void reply_handler(const z_loaned_reply_t *reply, void *ctx) { +void reply_handler(z_loaned_reply_t *reply, void *ctx) { (void)(ctx); if (z_reply_is_ok(reply)) { const z_loaned_sample_t *sample = z_reply_ok(reply); diff --git a/examples/unix/c11/z_get_attachment.c b/examples/unix/c11/z_get_attachment.c index b3a5f0e51..a24ee6f13 100644 --- a/examples/unix/c11/z_get_attachment.c +++ b/examples/unix/c11/z_get_attachment.c @@ -99,7 +99,7 @@ void reply_dropper(void *ctx) { z_drop(z_move(cond)); } -void reply_handler(const z_loaned_reply_t *reply, void *ctx) { +void reply_handler(z_loaned_reply_t *reply, void *ctx) { (void)(ctx); if (z_reply_is_ok(reply)) { const z_loaned_sample_t *sample = z_reply_ok(reply); diff --git a/examples/unix/c11/z_info.c b/examples/unix/c11/z_info.c index 303a134ef..701789bdb 100644 --- a/examples/unix/c11/z_info.c +++ b/examples/unix/c11/z_info.c @@ -18,7 +18,7 @@ #include #include -void print_zid(const z_id_t *id, void *ctx) { +void print_zid(z_id_t *id, void *ctx) { (void)(ctx); printf(" "); for (int i = 15; i >= 0; i--) { diff --git a/examples/unix/c11/z_ping.c b/examples/unix/c11/z_ping.c index 071133278..42cd17c6d 100644 --- a/examples/unix/c11/z_ping.c +++ b/examples/unix/c11/z_ping.c @@ -30,7 +30,7 @@ static z_owned_condvar_t cond; static z_owned_mutex_t mutex; -void callback(const z_loaned_sample_t* sample, void* context) { +void callback(z_loaned_sample_t* sample, void* context) { (void)sample; (void)context; z_condvar_signal(z_loan_mut(cond)); diff --git a/examples/unix/c11/z_pong.c b/examples/unix/c11/z_pong.c index 9da0d51fe..f0ecd2c25 100644 --- a/examples/unix/c11/z_pong.c +++ b/examples/unix/c11/z_pong.c @@ -16,7 +16,7 @@ #include "zenoh-pico.h" #if Z_FEATURE_SUBSCRIPTION == 1 && Z_FEATURE_PUBLICATION == 1 -void callback(const z_loaned_sample_t* sample, void* context) { +void callback(z_loaned_sample_t* sample, void* context) { const z_loaned_publisher_t* pub = z_loan(*(z_owned_publisher_t*)context); z_owned_bytes_t payload; z_bytes_clone(&payload, z_sample_payload(sample)); diff --git a/examples/unix/c11/z_queryable.c b/examples/unix/c11/z_queryable.c index 7c1eb3c39..09e12d1f0 100644 --- a/examples/unix/c11/z_queryable.c +++ b/examples/unix/c11/z_queryable.c @@ -26,7 +26,7 @@ static int msg_nb = 0; static enum { REPLY_DATA, REPLY_DELETE, REPLY_ERR } reply_kind = REPLY_DATA; bool reply_err = false; -void query_handler(const z_loaned_query_t *query, void *ctx) { +void query_handler(z_loaned_query_t *query, void *ctx) { (void)(ctx); z_view_string_t keystr; z_keyexpr_as_view_string(z_query_keyexpr(query), &keystr); diff --git a/examples/unix/c11/z_queryable_attachment.c b/examples/unix/c11/z_queryable_attachment.c index 4601aa68c..78dff9b16 100644 --- a/examples/unix/c11/z_queryable_attachment.c +++ b/examples/unix/c11/z_queryable_attachment.c @@ -104,7 +104,7 @@ void drop_attachment(kv_pairs_rx_t *kvp) { z_free(kvp->data); } -void query_handler(const z_loaned_query_t *query, void *ctx) { +void query_handler(z_loaned_query_t *query, void *ctx) { (void)(ctx); z_view_string_t keystr; z_keyexpr_as_view_string(z_query_keyexpr(query), &keystr); diff --git a/examples/unix/c11/z_scout.c b/examples/unix/c11/z_scout.c index 9c190017f..4324a966a 100644 --- a/examples/unix/c11/z_scout.c +++ b/examples/unix/c11/z_scout.c @@ -61,7 +61,7 @@ void fprinthello(FILE *stream, const z_loaned_hello_t *hello) { fprintf(stream, " }"); } -void callback(const z_loaned_hello_t *hello, void *context) { +void callback(z_loaned_hello_t *hello, void *context) { fprinthello(stdout, hello); fprintf(stdout, "\n"); (*(int *)context)++; diff --git a/examples/unix/c11/z_sub.c b/examples/unix/c11/z_sub.c index 95845e6e4..c1f67c311 100644 --- a/examples/unix/c11/z_sub.c +++ b/examples/unix/c11/z_sub.c @@ -24,7 +24,7 @@ static int msg_nb = 0; -void data_handler(const z_loaned_sample_t *sample, void *ctx) { +void data_handler(z_loaned_sample_t *sample, void *ctx) { (void)(ctx); z_view_string_t keystr; z_keyexpr_as_view_string(z_sample_keyexpr(sample), &keystr); diff --git a/examples/unix/c11/z_sub_attachment.c b/examples/unix/c11/z_sub_attachment.c index 84a351941..336f187ec 100644 --- a/examples/unix/c11/z_sub_attachment.c +++ b/examples/unix/c11/z_sub_attachment.c @@ -70,7 +70,7 @@ void drop_attachment(kv_pairs_t *kvp) { z_free(kvp->data); } -void data_handler(const z_loaned_sample_t *sample, void *ctx) { +void data_handler(z_loaned_sample_t *sample, void *ctx) { (void)(ctx); z_view_string_t keystr; z_keyexpr_as_view_string(z_sample_keyexpr(sample), &keystr); diff --git a/examples/unix/c11/z_sub_st.c b/examples/unix/c11/z_sub_st.c index 5ce01d3fe..003b8a0fe 100644 --- a/examples/unix/c11/z_sub_st.c +++ b/examples/unix/c11/z_sub_st.c @@ -23,7 +23,7 @@ static int msg_nb = 0; -void data_handler(const z_loaned_sample_t *sample, void *ctx) { +void data_handler(z_loaned_sample_t *sample, void *ctx) { (void)(ctx); z_view_string_t keystr; z_keyexpr_as_view_string(z_sample_keyexpr(sample), &keystr); diff --git a/examples/unix/c11/z_sub_thr.c b/examples/unix/c11/z_sub_thr.c index 9fbda3059..f65e08402 100644 --- a/examples/unix/c11/z_sub_thr.c +++ b/examples/unix/c11/z_sub_thr.c @@ -39,7 +39,7 @@ z_stats_t *z_stats_make(void) { return stats; } -void on_sample(const z_loaned_sample_t *sample, void *context) { +void on_sample(z_loaned_sample_t *sample, void *context) { (void)sample; z_stats_t *stats = (z_stats_t *)context; stats->count++; diff --git a/examples/unix/c99/z_get.c b/examples/unix/c99/z_get.c index 717ccc341..e672c2d0a 100644 --- a/examples/unix/c99/z_get.c +++ b/examples/unix/c99/z_get.c @@ -29,7 +29,7 @@ void reply_dropper(void *ctx) { z_condvar_drop(z_condvar_move(&cond)); } -void reply_handler(const z_loaned_reply_t *reply, void *ctx) { +void reply_handler(z_loaned_reply_t *reply, void *ctx) { (void)(ctx); if (z_reply_is_ok(reply)) { const z_loaned_sample_t *sample = z_reply_ok(reply); diff --git a/examples/unix/c99/z_info.c b/examples/unix/c99/z_info.c index 4474b1467..c5b0c3c2b 100644 --- a/examples/unix/c99/z_info.c +++ b/examples/unix/c99/z_info.c @@ -18,7 +18,7 @@ #include #include -void print_zid(const z_id_t *id, void *ctx) { +void print_zid(z_id_t *id, void *ctx) { (void)(ctx); printf(" "); for (int i = 15; i >= 0; i--) { diff --git a/examples/unix/c99/z_ping.c b/examples/unix/c99/z_ping.c index 4ae767e74..0e0b348bd 100644 --- a/examples/unix/c99/z_ping.c +++ b/examples/unix/c99/z_ping.c @@ -31,7 +31,7 @@ static z_owned_condvar_t cond; static z_owned_mutex_t mutex; -void callback(const z_loaned_sample_t* sample, void* context) { +void callback(z_loaned_sample_t* sample, void* context) { (void)sample; (void)context; z_condvar_signal(z_condvar_loan_mut(&cond)); diff --git a/examples/unix/c99/z_pong.c b/examples/unix/c99/z_pong.c index 81ef5daaa..d6baa2125 100644 --- a/examples/unix/c99/z_pong.c +++ b/examples/unix/c99/z_pong.c @@ -17,7 +17,7 @@ #include "zenoh-pico/api/primitives.h" #if Z_FEATURE_SUBSCRIPTION == 1 && Z_FEATURE_PUBLICATION == 1 -void callback(const z_loaned_sample_t* sample, void* context) { +void callback(z_loaned_sample_t* sample, void* context) { const z_loaned_publisher_t* pub = z_publisher_loan((z_owned_publisher_t*)context); z_owned_bytes_t payload; z_bytes_clone(&payload, z_sample_payload(sample)); diff --git a/examples/unix/c99/z_queryable.c b/examples/unix/c99/z_queryable.c index 43b6ca35e..a8a676a20 100644 --- a/examples/unix/c99/z_queryable.c +++ b/examples/unix/c99/z_queryable.c @@ -22,7 +22,7 @@ const char *keyexpr = "demo/example/zenoh-pico-queryable"; const char *value = "Queryable from Pico!"; -void query_handler(const z_loaned_query_t *query, void *ctx) { +void query_handler(z_loaned_query_t *query, void *ctx) { (void)(ctx); z_view_string_t keystr; z_keyexpr_as_view_string(z_query_keyexpr(query), &keystr); diff --git a/examples/unix/c99/z_scout.c b/examples/unix/c99/z_scout.c index 22ee39e31..412bb73b2 100644 --- a/examples/unix/c99/z_scout.c +++ b/examples/unix/c99/z_scout.c @@ -60,7 +60,7 @@ void fprinthello(FILE *stream, const z_loaned_hello_t *hello) { fprintf(stream, " }"); } -void callback(const z_loaned_hello_t *hello, void *context) { +void callback(z_loaned_hello_t *hello, void *context) { fprinthello(stdout, hello); fprintf(stdout, "\n"); (*(int *)context)++; diff --git a/examples/unix/c99/z_sub.c b/examples/unix/c99/z_sub.c index 998ab0e93..7094ff83b 100644 --- a/examples/unix/c99/z_sub.c +++ b/examples/unix/c99/z_sub.c @@ -20,7 +20,7 @@ #include #if Z_FEATURE_SUBSCRIPTION == 1 -void data_handler(const z_loaned_sample_t *sample, void *arg) { +void data_handler(z_loaned_sample_t *sample, void *arg) { (void)(arg); z_view_string_t keystr; z_keyexpr_as_view_string(z_sample_keyexpr(sample), &keystr); diff --git a/examples/unix/c99/z_sub_st.c b/examples/unix/c99/z_sub_st.c index 17e30a088..320c653d4 100644 --- a/examples/unix/c99/z_sub_st.c +++ b/examples/unix/c99/z_sub_st.c @@ -23,7 +23,7 @@ static int msg_nb = 0; -void data_handler(const z_loaned_sample_t *sample, void *arg) { +void data_handler(z_loaned_sample_t *sample, void *arg) { (void)(arg); z_view_string_t keystr; z_keyexpr_as_view_string(z_sample_keyexpr(sample), &keystr); diff --git a/examples/windows/z_get.c b/examples/windows/z_get.c index 4f54fb19b..46f588293 100644 --- a/examples/windows/z_get.c +++ b/examples/windows/z_get.c @@ -28,7 +28,7 @@ void reply_dropper(void *ctx) { z_drop(z_move(cond)); } -void reply_handler(const z_loaned_reply_t *reply, void *ctx) { +void reply_handler(z_loaned_reply_t *reply, void *ctx) { (void)(ctx); if (z_reply_is_ok(reply)) { const z_loaned_sample_t *sample = z_reply_ok(reply); diff --git a/examples/windows/z_info.c b/examples/windows/z_info.c index 2cb405257..5c9adc141 100644 --- a/examples/windows/z_info.c +++ b/examples/windows/z_info.c @@ -17,7 +17,7 @@ #include #include -void print_zid(const z_id_t *id, void *ctx) { +void print_zid(z_id_t *id, void *ctx) { (void)(ctx); printf(" "); for (int i = 15; i >= 0; i--) { diff --git a/examples/windows/z_ping.c b/examples/windows/z_ping.c index 922f03c0c..33fa2ce9f 100644 --- a/examples/windows/z_ping.c +++ b/examples/windows/z_ping.c @@ -30,7 +30,7 @@ static z_owned_condvar_t cond; static z_owned_mutex_t mutex; -void callback(const z_loaned_sample_t* sample, void* context) { +void callback(z_loaned_sample_t* sample, void* context) { (void)sample; (void)context; z_condvar_signal(z_loan_mut(cond)); diff --git a/examples/windows/z_pong.c b/examples/windows/z_pong.c index 9da0d51fe..f0ecd2c25 100644 --- a/examples/windows/z_pong.c +++ b/examples/windows/z_pong.c @@ -16,7 +16,7 @@ #include "zenoh-pico.h" #if Z_FEATURE_SUBSCRIPTION == 1 && Z_FEATURE_PUBLICATION == 1 -void callback(const z_loaned_sample_t* sample, void* context) { +void callback(z_loaned_sample_t* sample, void* context) { const z_loaned_publisher_t* pub = z_loan(*(z_owned_publisher_t*)context); z_owned_bytes_t payload; z_bytes_clone(&payload, z_sample_payload(sample)); diff --git a/examples/windows/z_queryable.c b/examples/windows/z_queryable.c index b4e59cd31..7ab31a1b7 100644 --- a/examples/windows/z_queryable.c +++ b/examples/windows/z_queryable.c @@ -21,7 +21,7 @@ const char *keyexpr = "demo/example/zenoh-pico-queryable"; const char *value = "Queryable from Pico!"; -void query_handler(const z_loaned_query_t *query, void *ctx) { +void query_handler(z_loaned_query_t *query, void *ctx) { (void)(ctx); z_view_string_t keystr; z_keyexpr_as_view_string(z_query_keyexpr(query), &keystr); diff --git a/examples/windows/z_scout.c b/examples/windows/z_scout.c index cc1aa5eb4..b8de576be 100644 --- a/examples/windows/z_scout.c +++ b/examples/windows/z_scout.c @@ -60,7 +60,7 @@ void fprinthello(FILE *stream, const z_loaned_hello_t *hello) { fprintf(stream, " }"); } -void callback(const z_loaned_hello_t *hello, void *context) { +void callback(z_loaned_hello_t *hello, void *context) { fprinthello(stdout, hello); fprintf(stdout, "\n"); (*(int *)context)++; diff --git a/examples/windows/z_sub.c b/examples/windows/z_sub.c index 252d10b6d..d9d824aad 100644 --- a/examples/windows/z_sub.c +++ b/examples/windows/z_sub.c @@ -19,7 +19,7 @@ #include #if Z_FEATURE_SUBSCRIPTION == 1 -void data_handler(const z_loaned_sample_t *sample, void *ctx) { +void data_handler(z_loaned_sample_t *sample, void *ctx) { (void)(ctx); z_view_string_t keystr; z_keyexpr_as_view_string(z_sample_keyexpr(sample), &keystr); diff --git a/examples/windows/z_sub_st.c b/examples/windows/z_sub_st.c index 99186aaa6..bcd675d29 100644 --- a/examples/windows/z_sub_st.c +++ b/examples/windows/z_sub_st.c @@ -22,7 +22,7 @@ int msg_nb = 0; #if Z_FEATURE_SUBSCRIPTION == 1 -void data_handler(const z_loaned_sample_t *sample, void *ctx) { +void data_handler(z_loaned_sample_t *sample, void *ctx) { (void)(ctx); z_view_string_t keystr; z_keyexpr_as_view_string(z_sample_keyexpr(sample), &keystr); diff --git a/examples/zephyr/z_get.c b/examples/zephyr/z_get.c index 2164d10dc..d8e6830f9 100644 --- a/examples/zephyr/z_get.c +++ b/examples/zephyr/z_get.c @@ -34,7 +34,7 @@ void reply_dropper(void *ctx) { printf(" >> Received query final notification\n"); } -void reply_handler(const z_loaned_reply_t *oreply, void *ctx) { +void reply_handler(z_loaned_reply_t *oreply, void *ctx) { if (z_reply_is_ok(oreply)) { const z_loaned_sample_t *sample = z_reply_ok(oreply); z_view_string_t keystr; diff --git a/examples/zephyr/z_queryable.c b/examples/zephyr/z_queryable.c index bb9a80f1b..c763a804b 100644 --- a/examples/zephyr/z_queryable.c +++ b/examples/zephyr/z_queryable.c @@ -31,7 +31,7 @@ #define KEYEXPR "demo/example/zenoh-pico-queryable" #define VALUE "[STSTM32]{nucleo-F767ZI} Queryable from Zenoh-Pico!" -void query_handler(const z_loaned_query_t *query, void *ctx) { +void query_handler(z_loaned_query_t *query, void *ctx) { (void)(ctx); z_view_string_t keystr; z_keyexpr_as_view_string(z_query_keyexpr(query), &keystr); diff --git a/examples/zephyr/z_scout.c b/examples/zephyr/z_scout.c index 84eacae2f..1ae6b9be0 100644 --- a/examples/zephyr/z_scout.c +++ b/examples/zephyr/z_scout.c @@ -57,7 +57,7 @@ void fprinthello(FILE *stream, const z_loaned_hello_t *hello) { fprintf(stream, " }"); } -void callback(const z_loaned_hello_t *hello, void *context) { +void callback(z_loaned_hello_t *hello, void *context) { fprinthello(stdout, hello); fprintf(stdout, "\n"); (*(int *)context)++; diff --git a/examples/zephyr/z_sub.c b/examples/zephyr/z_sub.c index fc37d91f4..780916b97 100644 --- a/examples/zephyr/z_sub.c +++ b/examples/zephyr/z_sub.c @@ -29,7 +29,7 @@ #define KEYEXPR "demo/example/**" -void data_handler(const z_loaned_sample_t *sample, void *arg) { +void data_handler(z_loaned_sample_t *sample, void *arg) { z_view_string_t keystr; z_keyexpr_as_view_string(z_sample_keyexpr(sample), &keystr); z_owned_string_t value; From 55642b17ade7ab27d1556dc84312fe3b4a27ddaa Mon Sep 17 00:00:00 2001 From: Alexander Bushnev Date: Thu, 12 Sep 2024 16:13:22 +0200 Subject: [PATCH 4/4] Revert const for z_id_t --- examples/unix/c11/z_info.c | 2 +- examples/unix/c99/z_info.c | 2 +- examples/windows/z_info.c | 2 +- include/zenoh-pico/api/macros.h | 4 ++-- include/zenoh-pico/api/types.h | 6 +++--- src/api/api.c | 2 +- tests/z_api_alignment_test.c | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/unix/c11/z_info.c b/examples/unix/c11/z_info.c index 701789bdb..303a134ef 100644 --- a/examples/unix/c11/z_info.c +++ b/examples/unix/c11/z_info.c @@ -18,7 +18,7 @@ #include #include -void print_zid(z_id_t *id, void *ctx) { +void print_zid(const z_id_t *id, void *ctx) { (void)(ctx); printf(" "); for (int i = 15; i >= 0; i--) { diff --git a/examples/unix/c99/z_info.c b/examples/unix/c99/z_info.c index c5b0c3c2b..4474b1467 100644 --- a/examples/unix/c99/z_info.c +++ b/examples/unix/c99/z_info.c @@ -18,7 +18,7 @@ #include #include -void print_zid(z_id_t *id, void *ctx) { +void print_zid(const z_id_t *id, void *ctx) { (void)(ctx); printf(" "); for (int i = 15; i >= 0; i--) { diff --git a/examples/windows/z_info.c b/examples/windows/z_info.c index 5c9adc141..2cb405257 100644 --- a/examples/windows/z_info.c +++ b/examples/windows/z_info.c @@ -17,7 +17,7 @@ #include #include -void print_zid(z_id_t *id, void *ctx) { +void print_zid(const z_id_t *id, void *ctx) { (void)(ctx); printf(" "); for (int i = 15; i >= 0; i--) { diff --git a/include/zenoh-pico/api/macros.h b/include/zenoh-pico/api/macros.h index 65f886eb3..541203ad5 100644 --- a/include/zenoh-pico/api/macros.h +++ b/include/zenoh-pico/api/macros.h @@ -511,7 +511,7 @@ inline void z_call(const z_loaned_closure_reply_t &closure, z_loaned_reply_t *re { z_closure_reply_call(&closure, reply); } inline void z_call(const z_loaned_closure_hello_t &closure, z_loaned_hello_t *hello) { z_closure_hello_call(&closure, hello); } -inline void z_call(const z_loaned_closure_zid_t &closure, z_id_t *zid) +inline void z_call(const z_loaned_closure_zid_t &closure, const z_id_t *zid) { z_closure_zid_call(&closure, zid); } inline void z_closure( @@ -552,7 +552,7 @@ inline void z_closure( }; inline void z_closure( z_owned_closure_zid_t* closure, - void (*call)(z_id_t*, void*), + void (*call)(const z_id_t*, void*), void (*drop)(void*) = NULL, void *context = NULL) { closure->_val.context = context; diff --git a/include/zenoh-pico/api/types.h b/include/zenoh-pico/api/types.h index 252c52152..fed282823 100644 --- a/include/zenoh-pico/api/types.h +++ b/include/zenoh-pico/api/types.h @@ -579,7 +579,7 @@ _Z_OWNED_TYPE_VALUE(_z_closure_hello_t, closure_hello) void z_closure_hello_call(const z_loaned_closure_hello_t *closure, z_loaned_hello_t *hello); -typedef void (*z_id_handler_t)(z_id_t *id, void *arg); +typedef void (*z_id_handler_t)(const z_id_t *id, void *arg); typedef struct { void *context; @@ -593,13 +593,13 @@ typedef struct { * * Members: * void *context: a pointer to an arbitrary state. - * z_id_handler_t call: `void (*z_id_handler_t)(z_id_t *id, void *arg)` is the callback function. + * z_id_handler_t call: `void (*z_id_handler_t)(const z_id_t *id, void *arg)` is the callback function. * z_dropper_handler_t drop: `void *drop(void*)` allows the callback's state to be freed. * void *context: a pointer to an arbitrary state. */ _Z_OWNED_TYPE_VALUE(_z_closure_zid_t, closure_zid) -void z_closure_zid_call(const z_loaned_closure_zid_t *closure, z_id_t *id); +void z_closure_zid_call(const z_loaned_closure_zid_t *closure, const z_id_t *id); #ifdef __cplusplus } diff --git a/src/api/api.c b/src/api/api.c index 6faab5736..9f12a9d49 100644 --- a/src/api/api.c +++ b/src/api/api.c @@ -736,7 +736,7 @@ void z_closure_hello_call(const z_loaned_closure_hello_t *closure, z_loaned_hell } } -void z_closure_zid_call(const z_loaned_closure_zid_t *closure, z_id_t *id) { +void z_closure_zid_call(const z_loaned_closure_zid_t *closure, const z_id_t *id) { if (closure->call != NULL) { (closure->call)(id, closure->context); } diff --git a/tests/z_api_alignment_test.c b/tests/z_api_alignment_test.c index a53be3b3a..1943defb1 100644 --- a/tests/z_api_alignment_test.c +++ b/tests/z_api_alignment_test.c @@ -44,7 +44,7 @@ const char *value = "Test value"; volatile unsigned int zids = 0; -void zid_handler(z_id_t *id, void *arg) { +void zid_handler(const z_id_t *id, void *arg) { (void)(arg); (void)(id); printf("%s\n", __func__);