From 52cdb36c0d9f67939adb3be9376fbda414d7e776 Mon Sep 17 00:00:00 2001 From: Jean-Roland Gosse Date: Fri, 17 Nov 2023 15:30:37 +0100 Subject: [PATCH] fix: use same time in the struct to reduce size --- include/zenoh-pico/link/link.h | 6 +++--- include/zenoh-pico/transport/common/tx.h | 4 ++-- src/transport/common/tx.c | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/zenoh-pico/link/link.h b/include/zenoh-pico/link/link.h index 568d9c68e..32c9ebb42 100644 --- a/include/zenoh-pico/link/link.h +++ b/include/zenoh-pico/link/link.h @@ -76,9 +76,9 @@ typedef enum { * reserved: 4 bits, reserved for futur use */ typedef struct _z_link_capabilities_t { - _z_link_cap_transport_t _transport : 2; - _z_link_cap_flow_t _flow : 1; - _Bool _is_reliable : 1; + uint8_t _transport : 2; + uint8_t _flow : 1; + uint8_t _is_reliable : 1; uint8_t _reserved : 4; } _z_link_capabilities_t; diff --git a/include/zenoh-pico/transport/common/tx.h b/include/zenoh-pico/transport/common/tx.h index d11c1c80e..d7870c54a 100644 --- a/include/zenoh-pico/transport/common/tx.h +++ b/include/zenoh-pico/transport/common/tx.h @@ -19,8 +19,8 @@ #include "zenoh-pico/net/session.h" #include "zenoh-pico/transport/transport.h" -void __unsafe_z_prepare_wbuf(_z_wbuf_t *buf, _z_link_cap_flow_t flow); -void __unsafe_z_finalize_wbuf(_z_wbuf_t *buf, _z_link_cap_flow_t flow); +void __unsafe_z_prepare_wbuf(_z_wbuf_t *buf, uint8_t link_flow_capability); +void __unsafe_z_finalize_wbuf(_z_wbuf_t *buf, uint8_t link_flow_capability); /*This function is unsafe because it operates in potentially concurrent data.*Make sure that the following mutexes are locked before calling this function : *-ztu->mutex_tx */ int8_t __unsafe_z_serialize_zenoh_fragment(_z_wbuf_t *dst, _z_wbuf_t *src, z_reliability_t reliability, size_t sn); diff --git a/src/transport/common/tx.c b/src/transport/common/tx.c index 12fc69e24..6f38ac365 100644 --- a/src/transport/common/tx.c +++ b/src/transport/common/tx.c @@ -27,10 +27,10 @@ * Make sure that the following mutexes are locked before calling this function: * - ztu->mutex_tx */ -void __unsafe_z_prepare_wbuf(_z_wbuf_t *buf, _z_link_cap_flow_t flow) { +void __unsafe_z_prepare_wbuf(_z_wbuf_t *buf, uint8_t link_flow_capability) { _z_wbuf_reset(buf); - switch (flow) { + switch (link_flow_capability) { // Stream capable links case Z_LINK_CAP_FLOW_STREAM: for (uint8_t i = 0; i < _Z_MSG_LEN_ENC_SIZE; i++) { @@ -50,8 +50,8 @@ void __unsafe_z_prepare_wbuf(_z_wbuf_t *buf, _z_link_cap_flow_t flow) { * Make sure that the following mutexes are locked before calling this function: * - ztu->mutex_tx */ -void __unsafe_z_finalize_wbuf(_z_wbuf_t *buf, _z_link_cap_flow_t flow) { - switch (flow) { +void __unsafe_z_finalize_wbuf(_z_wbuf_t *buf, uint8_t link_flow_capability) { + switch (link_flow_capability) { // Stream capable links case Z_LINK_CAP_FLOW_STREAM: { size_t len = _z_wbuf_len(buf) - _Z_MSG_LEN_ENC_SIZE;