From b8975a4aef38bdb14dd0489801d83740e6f36396 Mon Sep 17 00:00:00 2001 From: Alexander Bushnev Date: Tue, 28 May 2024 14:00:07 +0200 Subject: [PATCH] Fix sting usage in _zp_*_info_session + Formatting fix --- examples/mbed/z_get.cpp | 10 +++++----- src/transport/multicast.c | 5 +++-- src/transport/unicast.c | 7 ++++--- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/examples/mbed/z_get.cpp b/examples/mbed/z_get.cpp index 4b912c254..ded6f7e9e 100644 --- a/examples/mbed/z_get.cpp +++ b/examples/mbed/z_get.cpp @@ -81,11 +81,11 @@ int main(int argc, char **argv) { z_get_options_default(&opts); // Value encoding if (strcmp(VALUE, "") != 0) { - z_view_string_t value_str; - z_view_str_wrap(&value_str, VALUE); - z_owned_bytes_t payload; - z_bytes_encode_from_string(&payload, z_view_string_loan(&value_str)); - opts.payload = &payload; + z_view_string_t value_str; + z_view_str_wrap(&value_str, VALUE); + z_owned_bytes_t payload; + z_bytes_encode_from_string(&payload, z_view_string_loan(&value_str)); + opts.payload = &payload; } z_owned_closure_reply_t callback; z_closure_reply(&callback, reply_handler, reply_dropper, NULL); diff --git a/src/transport/multicast.c b/src/transport/multicast.c index 6b2b83feb..14d0fe4df 100644 --- a/src/transport/multicast.c +++ b/src/transport/multicast.c @@ -46,8 +46,9 @@ void _zp_multicast_info_session(const _z_transport_t *zt, _z_config_t *ps) { while (xs != NULL) { _z_transport_peer_entry_t *peer = _z_transport_peer_entry_list_head(xs); _z_bytes_t remote_zid = _z_bytes_wrap(peer->_remote_zid.id, _z_id_len(peer->_remote_zid)); - // TODO(sashacmc): double check! - _zp_config_insert(ps, Z_INFO_PEER_PID_KEY, _z_string_from_bytes(&remote_zid).val); + _z_string_t remote_zid_str = _z_string_from_bytes(&remote_zid); + _zp_config_insert(ps, Z_INFO_PEER_PID_KEY, remote_zid_str.val); + _z_string_clear(&remote_zid_str); xs = _z_transport_peer_entry_list_tail(xs); } diff --git a/src/transport/unicast.c b/src/transport/unicast.c index 75e29a56b..f7d066bb8 100644 --- a/src/transport/unicast.c +++ b/src/transport/unicast.c @@ -39,9 +39,10 @@ void _zp_unicast_fetch_zid(const _z_transport_t *zt, z_owned_closure_zid_t *call void _zp_unicast_info_session(const _z_transport_t *zt, _z_config_t *ps) { _z_id_t remote_zid = zt->_transport._unicast._remote_zid; - _z_bytes_t remote_zidbytes = _z_bytes_wrap(remote_zid.id, _z_id_len(remote_zid)); - // TODO(sashacmc): double check! - _zp_config_insert(ps, Z_INFO_ROUTER_PID_KEY, _z_string_from_bytes(&remote_zidbytes).val); + _z_bytes_t remote_zid_bytes = _z_bytes_wrap(remote_zid.id, _z_id_len(remote_zid)); + _z_string_t remote_zid_str = _z_string_from_bytes(&remote_zid_bytes); + _zp_config_insert(ps, Z_INFO_ROUTER_PID_KEY, remote_zid_str.val); + _z_string_clear(&remote_zid_str); } #else