From 44c88b8b22b4c8fbf22006397f97a34f66d8b105 Mon Sep 17 00:00:00 2001 From: Jean-Roland Gosse Date: Thu, 5 Dec 2024 15:18:53 +0100 Subject: [PATCH] fix: intializer & const init (#29) --- include/zenoh-pico/protocol/definitions/network.h | 8 ++++++-- src/protocol/definitions/network.c | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/include/zenoh-pico/protocol/definitions/network.h b/include/zenoh-pico/protocol/definitions/network.h index bf056aaf6..8895b77ed 100644 --- a/include/zenoh-pico/protocol/definitions/network.h +++ b/include/zenoh-pico/protocol/definitions/network.h @@ -95,11 +95,15 @@ static inline z_congestion_control_t _z_n_qos_get_congestion_control(_z_n_qos_t (n_qos._val & 0x08) ? Z_CONGESTION_CONTROL_BLOCK : Z_CONGESTION_CONTROL_DROP; // 0b1000 return ret; } -static inline bool _z_n_qos_get_express(_z_n_qos_t n_qos) { return (bool)(n_qos._val & 0x10 /* 0b10000 */); } +static inline bool _z_n_qos_get_express(_z_n_qos_t n_qos) { + bool ret = (n_qos._val & 0x10) != 0; // 0b10000 + return ret; +} #define _z_n_qos_make(express, nodrop, priority) \ _z_n_qos_create((bool)express, nodrop ? Z_CONGESTION_CONTROL_BLOCK : Z_CONGESTION_CONTROL_DROP, \ (z_priority_t)priority) -static const _z_qos_t _Z_N_QOS_DEFAULT = {._val = 5}; + +extern const _z_qos_t _Z_N_QOS_DEFAULT; // RESPONSE FINAL message flags: // Z Extensions if Z==1 then Zenoh extensions are present diff --git a/src/protocol/definitions/network.c b/src/protocol/definitions/network.c index 1364ac039..1a84ea1cd 100644 --- a/src/protocol/definitions/network.c +++ b/src/protocol/definitions/network.c @@ -19,6 +19,8 @@ #include "zenoh-pico/protocol/definitions/message.h" #include "zenoh-pico/utils/logging.h" +const _z_qos_t _Z_N_QOS_DEFAULT = {._val = 5}; + _z_n_msg_request_exts_t _z_n_msg_request_needed_exts(const _z_n_msg_request_t *msg) { _z_n_msg_request_exts_t ret = {.n = 0, .ext_budget = msg->_ext_budget != 0,