From 7773a433725a89ff0633787dc1305cbacac07692 Mon Sep 17 00:00:00 2001 From: Pierre Avital Date: Mon, 7 Aug 2023 15:19:06 +0200 Subject: [PATCH] fix lints for embedded compilers --- include/zenoh-pico/protocol/core.h | 2 +- src/protocol/codec/network.c | 1 + src/session/rx.c | 14 +++++++------- src/transport/multicast/link/rx.c | 3 --- src/transport/unicast/link/rx.c | 3 --- src/transport/utils.c | 6 ++++-- 6 files changed, 13 insertions(+), 16 deletions(-) diff --git a/include/zenoh-pico/protocol/core.h b/include/zenoh-pico/protocol/core.h index fabdcb6cd..45ac5f731 100644 --- a/include/zenoh-pico/protocol/core.h +++ b/include/zenoh-pico/protocol/core.h @@ -109,7 +109,7 @@ static inline _Bool _z_keyexpr_is_local(const _z_keyexpr_t *key) { } static inline _z_mapping_t _z_keyexpr_mapping(uint16_t id, _Bool owns_suffix) { assert(id <= _Z_KEYEXPR_MAPPING_UNKNOWN_REMOTE); - return (_z_mapping_t){._val = (owns_suffix ? 0x8000 : 0) | id}; + return (_z_mapping_t){._val = (owns_suffix ? (uint16_t)0x8000 : (uint16_t)0) | id}; } static inline void _z_keyexpr_set_mapping(_z_keyexpr_t *ke, uint16_t id) { assert(id <= _Z_KEYEXPR_MAPPING_UNKNOWN_REMOTE); diff --git a/src/protocol/codec/network.c b/src/protocol/codec/network.c index 61769bdb0..857e391aa 100644 --- a/src/protocol/codec/network.c +++ b/src/protocol/codec/network.c @@ -486,6 +486,7 @@ int8_t _z_network_message_encode(_z_wbuf_t *wbf, const _z_network_message_t *msg return _z_response_final_encode(wbf, &msg->_body._response_final); } break; } + return _Z_ERR_GENERIC; } int8_t _z_network_message_decode(_z_network_message_t *msg, _z_zbuf_t *zbf) { uint8_t header; diff --git a/src/session/rx.c b/src/session/rx.c index b99c3d162..1abd30e98 100644 --- a/src/session/rx.c +++ b/src/session/rx.c @@ -43,7 +43,7 @@ int8_t _z_handle_zenoh_message(_z_session_t *zn, _z_zenoh_message_t *msg, uint16 _z_resource_t *res = (_z_resource_t *)z_malloc(sizeof(_z_resource_t)); res->_id = decl._decl._body._decl_kexpr._id; res->_key = decl._decl._body._decl_kexpr._keyexpr; - _z_register_resource(zn, res); + ret = _z_register_resource(zn, res); } break; case _Z_UNDECL_KEXPR: { _z_resource_t res = {._id = decl._decl._body._undecl_kexpr._id}; @@ -105,8 +105,8 @@ int8_t _z_handle_zenoh_message(_z_session_t *zn, _z_zenoh_message_t *msg, uint16 } break; case _Z_REQUEST_DEL: { _z_msg_del_t del = req._body._del; - int8_t result = _z_trigger_subscriptions(zn, req._key, _z_bytes_empty(), z_encoding_default(), - Z_SAMPLE_KIND_DELETE, del._commons._timestamp); + ret = _z_trigger_subscriptions(zn, req._key, _z_bytes_empty(), z_encoding_default(), + Z_SAMPLE_KIND_DELETE, del._commons._timestamp); if (ret == _Z_RES_OK) { _z_network_message_t ack = _z_n_msg_make_ack(req._rid, &req._key); ret = _z_send_n_msg(zn, &ack, Z_RELIABILITY_RELIABLE, Z_CONGESTION_CONTROL_BLOCK); @@ -124,8 +124,8 @@ int8_t _z_handle_zenoh_message(_z_session_t *zn, _z_zenoh_message_t *msg, uint16 switch (response._tag) { case _Z_RESPONSE_BODY_REPLY: { _z_msg_reply_t reply = response._body._reply; - _z_trigger_query_reply_partial(zn, response._request_id, response._key, reply._value.payload, - reply._value.encoding, Z_SAMPLE_KIND_PUT, reply._timestamp); + ret = _z_trigger_query_reply_partial(zn, response._request_id, response._key, reply._value.payload, + reply._value.encoding, Z_SAMPLE_KIND_PUT, reply._timestamp); } break; case _Z_RESPONSE_BODY_ERR: { // @TODO: expose errors to the user @@ -144,8 +144,8 @@ int8_t _z_handle_zenoh_message(_z_session_t *zn, _z_zenoh_message_t *msg, uint16 } break; case _Z_RESPONSE_BODY_DEL: { _z_msg_del_t del = response._body._del; - int8_t result = _z_trigger_subscriptions(zn, response._key, _z_bytes_empty(), z_encoding_default(), - Z_SAMPLE_KIND_DELETE, del._commons._timestamp); + ret = _z_trigger_subscriptions(zn, response._key, _z_bytes_empty(), z_encoding_default(), + Z_SAMPLE_KIND_DELETE, del._commons._timestamp); } break; } } break; diff --git a/src/transport/multicast/link/rx.c b/src/transport/multicast/link/rx.c index 54cbcc214..6c90b0b92 100644 --- a/src/transport/multicast/link/rx.c +++ b/src/transport/multicast/link/rx.c @@ -89,9 +89,6 @@ int8_t _z_multicast_recv_t_msg_na(_z_transport_multicast_t *ztm, _z_transport_me } } while (false); // The 1-iteration loop to use continue to break the entire loop on error - // Wrap the main buffer for to_read bytes - _z_zbuf_t zbuf = _z_zbuf_view(&ztm->_zbuf, to_read); - if (ret == _Z_RES_OK) { _Z_DEBUG(">> \t transport_message_decode\n"); ret = _z_transport_message_decode(t_msg, &ztm->_zbuf); diff --git a/src/transport/unicast/link/rx.c b/src/transport/unicast/link/rx.c index 8fa69a5b4..8a58147a0 100644 --- a/src/transport/unicast/link/rx.c +++ b/src/transport/unicast/link/rx.c @@ -68,9 +68,6 @@ int8_t _z_unicast_recv_t_msg_na(_z_transport_unicast_t *ztu, _z_transport_messag } } while (false); // The 1-iteration loop to use continue to break the entire loop on error - // Wrap the main buffer for to_read bytes - _z_zbuf_t zbuf = _z_zbuf_view(&ztu->_zbuf, to_read); - if (ret == _Z_RES_OK) { _Z_DEBUG(">> \t transport_message_decode\n"); ret = _z_transport_message_decode(t_msg, &ztu->_zbuf); diff --git a/src/transport/utils.c b/src/transport/utils.c index 87d589139..9e3ad968c 100644 --- a/src/transport/utils.c +++ b/src/transport/utils.c @@ -14,6 +14,8 @@ #include "zenoh-pico/transport/utils.h" +#include "zenoh-pico/protocol/core.h" + #define U8_MAX 0xFF #define U16_MAX 0xFFFF #define U32_MAX 0xFFFFFFFF @@ -35,7 +37,7 @@ _z_zint_t _z_sn_max(uint8_t bits) { } break; case 0x03: { - ret = U64_MAX >> 1; + ret = (_z_zint_t)(U64_MAX >> 1); } break; default: { @@ -64,7 +66,7 @@ _z_zint_t _z_sn_modulo_mask(uint8_t bits) { } break; case 0x03: { - ret = U64_MAX >> 1; + ret = (_z_zint_t)(U64_MAX >> 1); } break; default: {