From 03c361da6008e875e49f7db33530a9ad1f596ac8 Mon Sep 17 00:00:00 2001 From: Alexander Bushnev Date: Tue, 11 Jun 2024 14:21:04 +0200 Subject: [PATCH] Remove z_query_value --- build-resources/opaque-types/src/lib.rs | 5 --- examples/z_queryable.c | 2 +- examples/z_queryable_with_channels.c | 2 +- include/zenoh_commons.h | 54 ++++++++++--------------- include/zenoh_macros.h | 11 ----- splitguide.yaml | 2 - src/commons.rs | 43 -------------------- src/get.rs | 21 ++++++++-- src/queryable.rs | 20 ++++++--- tests/z_api_alignment_test.c | 10 +++-- tests/z_int_queryable_attachment_test.c | 41 ++++++++----------- tests/z_int_queryable_test.c | 1 - 12 files changed, 80 insertions(+), 132 deletions(-) diff --git a/build-resources/opaque-types/src/lib.rs b/build-resources/opaque-types/src/lib.rs index 6d677a823..fa7e01085 100644 --- a/build-resources/opaque-types/src/lib.rs +++ b/build-resources/opaque-types/src/lib.rs @@ -120,11 +120,6 @@ get_opaque_type_data!(Option, z_owned_reply_t); /// A loaned reply. get_opaque_type_data!(Reply, z_loaned_reply_t); -/// A Zenoh value - a compination of payload and its encoding. -get_opaque_type_data!(Value, z_owned_value_t); -/// A loaned Zenoh value. -get_opaque_type_data!(Value, z_loaned_value_t); - /// An owned Zenoh query received by a queryable. /// /// Queries are atomically reference-counted, letting you extract them from the callback that handed them to you by cloning. diff --git a/examples/z_queryable.c b/examples/z_queryable.c index 1d52602a8..4cfd02faf 100644 --- a/examples/z_queryable.c +++ b/examples/z_queryable.c @@ -26,7 +26,7 @@ void query_handler(const z_loaned_query_t *query, void *context) { z_view_string_t params; z_query_parameters(query, ¶ms); - const z_loaned_bytes_t* payload = z_value_payload(z_query_value(query)); + const z_loaned_bytes_t *payload = z_query_payload(query); if (z_bytes_len(payload) > 0) { z_owned_string_t payload_string; z_bytes_decode_into_string(payload, &payload_string); diff --git a/examples/z_queryable_with_channels.c b/examples/z_queryable_with_channels.c index ae8dae2ed..617bd52e2 100644 --- a/examples/z_queryable_with_channels.c +++ b/examples/z_queryable_with_channels.c @@ -70,7 +70,7 @@ int main(int argc, char **argv) { z_view_string_t params; z_query_parameters(query, ¶ms); - const z_loaned_bytes_t* payload = z_value_payload(z_query_value(query)); + const z_loaned_bytes_t *payload = z_query_payload(query); if (z_bytes_len(payload) > 0) { z_owned_string_t payload_string; z_bytes_decode_into_string(payload, &payload_string); diff --git a/include/zenoh_commons.h b/include/zenoh_commons.h index e8b899a47..2e01edb51 100644 --- a/include/zenoh_commons.h +++ b/include/zenoh_commons.h @@ -2381,6 +2381,13 @@ ZENOHC_API struct z_query_consolidation_t z_query_consolidation_none(void); * Destroys the query resetting it to its gravestone value. */ ZENOHC_API void z_query_drop(struct z_owned_query_t *this_); +/** + * Gets query payload encoding. + * + * Returns NULL if query does not hame an encoding. + */ +ZENOHC_API +const struct z_loaned_encoding_t *z_query_encoding(const struct z_loaned_query_t *this_); /** * Gets query key expression. */ @@ -2399,6 +2406,13 @@ ZENOHC_API void z_query_null(struct z_owned_query_t *this_); ZENOHC_API void z_query_parameters(const struct z_loaned_query_t *this_, struct z_view_string_t *parameters); +/** + * Gets query payload. + * + * Returns NULL if query does not contain a payload. + */ +ZENOHC_API +const struct z_loaned_bytes_t *z_query_payload(const struct z_loaned_query_t *this_); /** * Sends a reply to a query. * @@ -2471,13 +2485,6 @@ ZENOHC_API void z_query_reply_options_default(struct z_query_reply_options_t *th * Create a default `z_query_target_t`. */ ZENOHC_API enum z_query_target_t z_query_target_default(void); -/** - * Gets query payload value. - * - * Returns NULL if query does not contain a value. - */ -ZENOHC_API -const struct z_loaned_value_t *z_query_value(const struct z_loaned_query_t *this_); /** * Returns ``true`` if queryable is valid, ``false`` otherwise. */ @@ -2532,12 +2539,19 @@ ZENOHC_API void z_reply_clone(const struct z_loaned_reply_t *this_, struct z_own * Frees reply, resetting it to its gravestone state. */ ZENOHC_API void z_reply_drop(struct z_owned_reply_t *this_); +/** + * Yields the encoding of the contents of the reply by asserting it indicates a failure. + * + * Returns `NULL` if reply does not contain a error (i. e. if `z_reply_is_ok` returns ``true``). + */ +ZENOHC_API +const struct z_loaned_encoding_t *z_reply_err_encoding(const struct z_loaned_reply_t *this_); /** * Yields the contents of the reply by asserting it indicates a failure. * * Returns `NULL` if reply does not contain a error (i. e. if `z_reply_is_ok` returns ``true``). */ -ZENOHC_API const struct z_loaned_value_t *z_reply_err(const struct z_loaned_reply_t *this_); +ZENOHC_API const struct z_loaned_bytes_t *z_reply_err_payload(const struct z_loaned_reply_t *this_); /** * Returns ``true`` if reply contains a valid response, ``false`` otherwise (in this case it contains a errror value). */ @@ -3460,30 +3474,6 @@ ZENOHC_API z_error_t z_undeclare_queryable(struct z_owned_queryable_t *this_); * @return 0 in case of success, negative error code otherwise. */ ZENOHC_API z_error_t z_undeclare_subscriber(struct z_owned_subscriber_t *this_); -/** - * Returns ``true`` if value is in non-default state, ``false`` otherwise. - */ -ZENOHC_API bool z_value_check(const struct z_owned_value_t *this_); -/** - * Frees the memory and resets the value it to its default value. - */ -ZENOHC_API void z_value_drop(struct z_owned_value_t *this_); -/** - * Returns value encoding. - */ -ZENOHC_API const struct z_loaned_encoding_t *z_value_encoding(const struct z_loaned_value_t *this_); -/** - * Borrows value. - */ -ZENOHC_API const struct z_loaned_value_t *z_value_loan(const struct z_owned_value_t *this_); -/** - * Constructs an empty `z_owned_value_t`. - */ -ZENOHC_API void z_value_null(struct z_owned_value_t *this_); -/** - * Returns value payload. - */ -ZENOHC_API const struct z_loaned_bytes_t *z_value_payload(const struct z_loaned_value_t *this_); /** * Returns ``true`` if `keyexpr` is valid, ``false`` if it is in gravestone state. */ diff --git a/include/zenoh_macros.h b/include/zenoh_macros.h index fcbabc901..be9203ad1 100644 --- a/include/zenoh_macros.h +++ b/include/zenoh_macros.h @@ -37,7 +37,6 @@ z_owned_string_array_t : z_string_array_loan, \ z_owned_string_t : z_string_loan, \ z_owned_subscriber_t : z_subscriber_loan, \ - z_owned_value_t : z_value_loan, \ z_view_keyexpr_t : z_view_keyexpr_loan, \ z_view_slice_t : z_view_slice_loan, \ z_view_string_t : z_view_string_loan, \ @@ -91,7 +90,6 @@ z_owned_string_array_t* : z_string_array_drop, \ z_owned_string_t* : z_string_drop, \ z_owned_subscriber_t* : z_subscriber_drop, \ - z_owned_value_t* : z_value_drop, \ zc_owned_liveliness_token_t* : zc_liveliness_token_drop, \ zcu_owned_closure_matching_status_t* : zcu_closure_matching_status_drop, \ ze_owned_publication_cache_t* : ze_publication_cache_drop, \ @@ -134,7 +132,6 @@ z_owned_string_t* : z_string_null, \ z_owned_subscriber_t* : z_subscriber_null, \ z_owned_task_t* : z_task_null, \ - z_owned_value_t* : z_value_null, \ z_view_keyexpr_t* : z_view_keyexpr_null, \ z_view_slice_t* : z_view_slice_null, \ z_view_string_t* : z_view_string_null, \ @@ -178,7 +175,6 @@ z_owned_string_t : z_string_check, \ z_owned_subscriber_t : z_subscriber_check, \ z_owned_task_t : z_task_check, \ - z_owned_value_t : z_value_check, \ z_view_keyexpr_t : z_view_keyexpr_check, \ z_view_slice_t : z_view_slice_check, \ z_view_string_t : z_view_string_check, \ @@ -256,7 +252,6 @@ inline const z_loaned_source_info_t* z_loan(const z_owned_source_info_t& this_) inline const z_loaned_string_array_t* z_loan(const z_owned_string_array_t& this_) { return z_string_array_loan(&this_); }; inline const z_loaned_string_t* z_loan(const z_owned_string_t& this_) { return z_string_loan(&this_); }; inline const z_loaned_subscriber_t* z_loan(const z_owned_subscriber_t& this_) { return z_subscriber_loan(&this_); }; -inline const z_loaned_value_t* z_loan(const z_owned_value_t& this_) { return z_value_loan(&this_); }; inline const z_loaned_keyexpr_t* z_loan(const z_view_keyexpr_t& this_) { return z_view_keyexpr_loan(&this_); }; inline const z_loaned_slice_t* z_loan(const z_view_slice_t& this_) { return z_view_slice_loan(&this_); }; inline const z_loaned_string_t* z_loan(const z_view_string_t& this_) { return z_view_string_loan(&this_); }; @@ -306,7 +301,6 @@ inline void z_drop(z_owned_source_info_t* this_) { return z_source_info_drop(thi inline void z_drop(z_owned_string_array_t* this_) { return z_string_array_drop(this_); }; inline void z_drop(z_owned_string_t* this_) { return z_string_drop(this_); }; inline void z_drop(z_owned_subscriber_t* this_) { return z_subscriber_drop(this_); }; -inline void z_drop(z_owned_value_t* this_) { return z_value_drop(this_); }; inline void z_drop(zc_owned_liveliness_token_t* this_) { return zc_liveliness_token_drop(this_); }; inline void z_drop(zcu_owned_closure_matching_status_t* closure) { return zcu_closure_matching_status_drop(closure); }; inline void z_drop(ze_owned_publication_cache_t* this_) { return ze_publication_cache_drop(this_); }; @@ -345,7 +339,6 @@ inline z_owned_source_info_t* z_move(z_owned_source_info_t& this_) { return (&th inline z_owned_string_array_t* z_move(z_owned_string_array_t& this_) { return (&this_); }; inline z_owned_string_t* z_move(z_owned_string_t& this_) { return (&this_); }; inline z_owned_subscriber_t* z_move(z_owned_subscriber_t& this_) { return (&this_); }; -inline z_owned_value_t* z_move(z_owned_value_t& this_) { return (&this_); }; inline zc_owned_liveliness_token_t* z_move(zc_owned_liveliness_token_t& this_) { return (&this_); }; inline zcu_owned_closure_matching_status_t* z_move(zcu_owned_closure_matching_status_t& closure) { return (&closure); }; inline ze_owned_publication_cache_t* z_move(ze_owned_publication_cache_t& this_) { return (&this_); }; @@ -384,7 +377,6 @@ inline void z_null(z_owned_string_array_t* this_) { return z_string_array_null(t inline void z_null(z_owned_string_t* this_) { return z_string_null(this_); }; inline void z_null(z_owned_subscriber_t* this_) { return z_subscriber_null(this_); }; inline void z_null(z_owned_task_t* this_) { return z_task_null(this_); }; -inline void z_null(z_owned_value_t* this_) { return z_value_null(this_); }; inline void z_null(z_view_keyexpr_t* this_) { return z_view_keyexpr_null(this_); }; inline void z_null(z_view_slice_t* this_) { return z_view_slice_null(this_); }; inline void z_null(z_view_string_t* this_) { return z_view_string_null(this_); }; @@ -426,7 +418,6 @@ inline bool z_check(const z_owned_string_array_t& this_) { return z_string_array inline bool z_check(const z_owned_string_t& this_) { return z_string_check(&this_); }; inline bool z_check(const z_owned_subscriber_t& this_) { return z_subscriber_check(&this_); }; inline bool z_check(const z_owned_task_t& this_) { return z_task_check(&this_); }; -inline bool z_check(const z_owned_value_t& this_) { return z_value_check(&this_); }; inline bool z_check(const z_view_keyexpr_t& this_) { return z_view_keyexpr_check(&this_); }; inline bool z_check(const z_view_slice_t& this_) { return z_view_slice_check(&this_); }; inline bool z_check(const z_view_string_t& this_) { return z_view_string_check(&this_); }; @@ -627,8 +618,6 @@ template<> struct z_loaned_to_owned_type_t { typedef z_owned_ template<> struct z_owned_to_loaned_type_t { typedef z_loaned_string_t type; }; template<> struct z_loaned_to_owned_type_t { typedef z_owned_subscriber_t type; }; template<> struct z_owned_to_loaned_type_t { typedef z_loaned_subscriber_t type; }; -template<> struct z_loaned_to_owned_type_t { typedef z_owned_value_t type; }; -template<> struct z_owned_to_loaned_type_t { typedef z_loaned_value_t type; }; template<> struct z_loaned_to_owned_type_t { typedef zc_owned_liveliness_token_t type; }; template<> struct z_owned_to_loaned_type_t { typedef zc_loaned_liveliness_token_t type; }; template<> struct z_loaned_to_owned_type_t { typedef zcu_owned_closure_matching_status_t type; }; diff --git a/splitguide.yaml b/splitguide.yaml index 9b2a4f936..cc97ff1c9 100644 --- a/splitguide.yaml +++ b/splitguide.yaml @@ -29,8 +29,6 @@ zenoh_opaque.h: - z_loaned_encoding_t! - z_owned_reply_t! - z_loaned_reply_t! - - z_owned_value_t! - - z_loaned_value_t! - z_owned_query_t! - z_loaned_query_t! - z_owned_queryable_t! diff --git a/src/commons.rs b/src/commons.rs index 3699d57b9..6f8321563 100644 --- a/src/commons.rs +++ b/src/commons.rs @@ -45,7 +45,6 @@ use zenoh::sample::Sample; use zenoh::sample::SampleKind; use zenoh::sample::SourceInfo; use zenoh::time::Timestamp; -use zenoh::value::Value; use zenoh_protocol::core::EntityGlobalId; use zenoh_protocol::zenoh::Consolidation; @@ -312,48 +311,6 @@ pub extern "C" fn z_encoding_loan(this: &z_owned_encoding_t) -> &z_loaned_encodi this.transmute_ref().transmute_handle() } -pub use crate::opaque_types::z_owned_value_t; -decl_transmute_owned!(Value, z_owned_value_t); -pub use crate::opaque_types::z_loaned_value_t; -decl_transmute_handle!(Value, z_loaned_value_t); - -/// Constructs an empty `z_owned_value_t`. -#[no_mangle] -pub extern "C" fn z_value_null(this: *mut MaybeUninit) { - Inplace::empty(this.transmute_uninit_ptr()); -} - -/// Returns ``true`` if value is in non-default state, ``false`` otherwise. -#[no_mangle] -#[allow(clippy::missing_safety_doc)] -pub extern "C" fn z_value_check(this: &'static z_owned_value_t) -> bool { - !this.transmute_ref().is_empty() -} - -/// Returns value payload. -#[no_mangle] -pub extern "C" fn z_value_payload(this: &z_loaned_value_t) -> &z_loaned_bytes_t { - this.transmute_ref().payload().transmute_handle() -} - -/// Returns value encoding. -#[no_mangle] -pub extern "C" fn z_value_encoding(this: &z_loaned_value_t) -> &z_loaned_encoding_t { - this.transmute_ref().encoding().transmute_handle() -} - -/// Borrows value. -#[no_mangle] -pub extern "C" fn z_value_loan(this: &z_owned_value_t) -> &z_loaned_value_t { - this.transmute_ref().transmute_handle() -} - -/// Frees the memory and resets the value it to its default value. -#[no_mangle] -pub extern "C" fn z_value_drop(this: &mut z_owned_value_t) { - Inplace::drop(this.transmute_mut()); -} - /// The locality of samples to be received by subscribers or targeted by publishers. #[repr(C)] #[derive(Clone, Copy, Debug)] diff --git a/src/get.rs b/src/get.rs index 45b7d8882..39da363a1 100644 --- a/src/get.rs +++ b/src/get.rs @@ -32,8 +32,9 @@ use crate::transmute::TransmuteRef; use crate::transmute::TransmuteUninitPtr; use crate::z_closure_reply_loan; use crate::z_consolidation_mode_t; +use crate::z_loaned_bytes_t; +use crate::z_loaned_encoding_t; use crate::z_loaned_sample_t; -use crate::z_loaned_value_t; use crate::z_owned_bytes_t; use crate::z_owned_encoding_t; use crate::z_owned_source_info_t; @@ -72,10 +73,24 @@ pub unsafe extern "C" fn z_reply_ok(this: &z_loaned_reply_t) -> *const z_loaned_ /// Returns `NULL` if reply does not contain a error (i. e. if `z_reply_is_ok` returns ``true``). #[no_mangle] #[allow(clippy::missing_safety_doc)] -pub unsafe extern "C" fn z_reply_err(this: &z_loaned_reply_t) -> *const z_loaned_value_t { +pub unsafe extern "C" fn z_reply_err_payload(this: &z_loaned_reply_t) -> *const z_loaned_bytes_t { match this.transmute_ref().result() { Ok(_) => null(), - Err(v) => v.transmute_handle(), + Err(v) => v.payload().transmute_handle(), + } +} + +/// Yields the encoding of the contents of the reply by asserting it indicates a failure. +/// +/// Returns `NULL` if reply does not contain a error (i. e. if `z_reply_is_ok` returns ``true``). +#[no_mangle] +#[allow(clippy::missing_safety_doc)] +pub unsafe extern "C" fn z_reply_err_encoding( + this: &z_loaned_reply_t, +) -> *const z_loaned_encoding_t { + match this.transmute_ref().result() { + Ok(_) => null(), + Err(v) => v.encoding().transmute_handle(), } } diff --git a/src/queryable.rs b/src/queryable.rs index 20f0cf10a..a7e455a07 100644 --- a/src/queryable.rs +++ b/src/queryable.rs @@ -17,7 +17,7 @@ use crate::transmute::{ }; use crate::{ errors, z_closure_query_call, z_closure_query_loan, z_congestion_control_t, z_loaned_bytes_t, - z_loaned_keyexpr_t, z_loaned_session_t, z_loaned_value_t, z_owned_bytes_t, + z_loaned_encoding_t, z_loaned_keyexpr_t, z_loaned_session_t, z_owned_bytes_t, z_owned_closure_query_t, z_owned_encoding_t, z_owned_source_info_t, z_priority_t, z_timestamp_t, z_view_string_from_substring, z_view_string_t, }; @@ -428,12 +428,22 @@ pub unsafe extern "C" fn z_query_parameters( unsafe { z_view_string_from_substring(parameters, params.as_ptr() as _, params.len()) }; } -/// Gets query payload value. +/// Gets query payload. /// -/// Returns NULL if query does not contain a value. +/// Returns NULL if query does not contain a payload. #[no_mangle] -pub extern "C" fn z_query_value(this: &z_loaned_query_t) -> Option<&z_loaned_value_t> { - this.transmute_ref().value().map(|v| v.transmute_handle()) +pub extern "C" fn z_query_payload(this: &z_loaned_query_t) -> Option<&z_loaned_bytes_t> { + this.transmute_ref().payload().map(|v| v.transmute_handle()) +} + +/// Gets query payload encoding. +/// +/// Returns NULL if query does not hame an encoding. +#[no_mangle] +pub extern "C" fn z_query_encoding(this: &z_loaned_query_t) -> Option<&z_loaned_encoding_t> { + this.transmute_ref() + .encoding() + .map(|v| v.transmute_handle()) } /// Gets query attachment. diff --git a/tests/z_api_alignment_test.c b/tests/z_api_alignment_test.c index c787ab05b..e6f3c95e3 100644 --- a/tests/z_api_alignment_test.c +++ b/tests/z_api_alignment_test.c @@ -55,8 +55,10 @@ void query_handler(const z_loaned_query_t *query, void *arg) { z_view_string_t params; z_query_parameters(query, ¶ms); (void)(params); - const z_loaned_value_t* payload_value = z_query_value(query); - (void)(payload_value); + const z_loaned_bytes_t *in_payload = z_query_payload(query); + (void)(in_payload); + const z_loaned_encoding_t *encoding = z_query_encoding(query); + (void)(encoding); z_query_reply_options_t _ret_qreply_opt; z_query_reply_options_default(&_ret_qreply_opt); @@ -80,8 +82,8 @@ void reply_handler(const z_loaned_reply_t *reply, void *arg) { } #endif } else { - const z_loaned_value_t* _ret_zvalue = z_reply_err(reply); - (void)(_ret_zvalue); + const z_loaned_bytes_t *_ret_zpayload = z_reply_err_payload(reply); + (void)(_ret_zpayload); } } diff --git a/tests/z_int_queryable_attachment_test.c b/tests/z_int_queryable_attachment_test.c index 1ef3edee6..6f652147f 100644 --- a/tests/z_int_queryable_attachment_test.c +++ b/tests/z_int_queryable_attachment_test.c @@ -30,14 +30,14 @@ const char *const K_CONST = "k_const"; const char *const V_CONST = "v const"; typedef struct attachement_context_t { - const char* keys[2]; - const char* values[2]; + const char *keys[2]; + const char *values[2]; size_t num_items; size_t iteration_index; } attachement_context_t; -bool create_attachement_it(z_owned_bytes_t* kv_pair, void* context) { - attachement_context_t *ctx = (attachement_context_t*)(context); +bool create_attachement_it(z_owned_bytes_t *kv_pair, void *context) { + attachement_context_t *ctx = (attachement_context_t *)(context); z_owned_bytes_t k, v; if (ctx->iteration_index >= ctx->num_items) { return false; @@ -51,7 +51,7 @@ bool create_attachement_it(z_owned_bytes_t* kv_pair, void* context) { return true; }; -z_error_t check_attachement(const z_loaned_bytes_t* attachement, const attachement_context_t* ctx) { +z_error_t check_attachement(const z_loaned_bytes_t *attachement, const attachement_context_t *ctx) { z_bytes_iterator_t iter = z_bytes_get_iterator(attachement); for (size_t i = 0; i < ctx->num_items; i++) { z_owned_bytes_t kv, k, v; @@ -84,23 +84,20 @@ z_error_t check_attachement(const z_loaned_bytes_t* attachement, const attacheme return 0; }; - void query_handler(const z_loaned_query_t *query, void *context) { static int value_num = 0; z_view_string_t params; z_query_parameters(query, ¶ms); - const z_loaned_value_t* payload_value = z_query_value(query); - const z_loaned_bytes_t* attachment = z_query_attachment(query); + const z_loaned_bytes_t *attachment = z_query_attachment(query); if (attachment == NULL) { perror("Missing attachment!"); exit(-1); } attachement_context_t in_attachment_context = (attachement_context_t){ - .keys = {K_CONST, K_VAR}, .values = {V_CONST, values[value_num]}, .num_items = 2, .iteration_index = 0 - }; + .keys = {K_CONST, K_VAR}, .values = {V_CONST, values[value_num]}, .num_items = 2, .iteration_index = 0}; if (check_attachement(attachment, &in_attachment_context) != 0) { perror("Failed to validate attachment"); exit(-1); @@ -108,12 +105,11 @@ void query_handler(const z_loaned_query_t *query, void *context) { z_query_reply_options_t options; z_query_reply_options_default(&options); - + z_owned_bytes_t reply_attachment; - attachement_context_t out_attachment_context = (attachement_context_t){ - .keys = {K_CONST}, .values = {V_CONST}, .num_items = 1, .iteration_index = 0 - }; - z_bytes_encode_from_iter(&reply_attachment, create_attachement_it, (void*)&out_attachment_context); + attachement_context_t out_attachment_context = + (attachement_context_t){.keys = {K_CONST}, .values = {V_CONST}, .num_items = 1, .iteration_index = 0}; + z_bytes_encode_from_iter(&reply_attachment, create_attachement_it, (void *)&out_attachment_context); options.attachment = &reply_attachment; @@ -175,18 +171,16 @@ int run_get() { z_get_options_t opts; z_get_options_default(&opts); - for (int val_num = 0; val_num < values_count; ++val_num) { attachement_context_t out_attachment_context = (attachement_context_t){ - .keys = {K_CONST, K_VAR}, .values = {V_CONST, values[val_num]}, .num_items = 2, .iteration_index = 0 - }; + .keys = {K_CONST, K_VAR}, .values = {V_CONST, values[val_num]}, .num_items = 2, .iteration_index = 0}; z_owned_fifo_handler_reply_t handler; z_owned_closure_reply_t closure; z_fifo_channel_reply_new(&closure, &handler, 16); z_owned_bytes_t attachment; - z_bytes_encode_from_iter(&attachment, create_attachement_it, (void*)&out_attachment_context); + z_bytes_encode_from_iter(&attachment, create_attachement_it, (void *)&out_attachment_context); opts.attachment = &attachment; z_get(z_loan(s), z_loan(ke), "", z_move(closure), &opts); @@ -194,7 +188,7 @@ int run_get() { for (z_recv(z_loan(handler), &reply); z_check(reply); z_recv(z_loan(handler), &reply)) { assert(z_reply_is_ok(z_loan(reply))); - const z_loaned_sample_t* sample = z_reply_ok(z_loan(reply)); + const z_loaned_sample_t *sample = z_reply_ok(z_loan(reply)); z_owned_string_t payload_str; z_bytes_decode_into_string(z_sample_payload(sample), &payload_str); if (strncmp(values[val_num], z_string_data(z_loan(payload_str)), z_string_len(z_loan(payload_str)))) { @@ -203,14 +197,13 @@ int run_get() { exit(-1); } - const z_loaned_bytes_t* received_attachment = z_sample_attachment(sample); + const z_loaned_bytes_t *received_attachment = z_sample_attachment(sample); if (received_attachment == NULL) { perror("Missing attachment!"); exit(-1); } - attachement_context_t in_attachment_context = (attachement_context_t){ - .keys = {K_CONST}, .values = {V_CONST}, .num_items = 1, .iteration_index = 0 - }; + attachement_context_t in_attachment_context = + (attachement_context_t){.keys = {K_CONST}, .values = {V_CONST}, .num_items = 1, .iteration_index = 0}; if (check_attachement(received_attachment, &in_attachment_context) != 0) { perror("Failed to validate attachment"); exit(-1); diff --git a/tests/z_int_queryable_test.c b/tests/z_int_queryable_test.c index f6e0a0a4a..be751d7f7 100644 --- a/tests/z_int_queryable_test.c +++ b/tests/z_int_queryable_test.c @@ -35,7 +35,6 @@ void query_handler(const z_loaned_query_t *query, void *context) { z_view_string_t params; z_query_parameters(query, ¶ms); - const z_loaned_value_t *payload_value = z_query_value(query); z_query_reply_options_t options; z_query_reply_options_default(&options);