From 2df5186cbd834c31ad5281246d48668329180099 Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Mon, 11 Dec 2023 16:42:36 +0100 Subject: [PATCH] fix: replace magic number --- include/zenoh-pico/protocol/definitions/transport.h | 2 ++ src/transport/multicast/tx.c | 2 +- src/transport/raweth/tx.c | 2 +- src/transport/unicast/tx.c | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/zenoh-pico/protocol/definitions/transport.h b/include/zenoh-pico/protocol/definitions/transport.h index f92bd3ae3..3bcb5ce33 100644 --- a/include/zenoh-pico/protocol/definitions/transport.h +++ b/include/zenoh-pico/protocol/definitions/transport.h @@ -477,6 +477,8 @@ typedef struct { } _z_t_msg_fragment_t; void _z_t_msg_fragment_clear(_z_t_msg_fragment_t *msg); +#define _Z_FRAGMENT_HEADER_SIZE 12 + /*------------------ Transport Message ------------------*/ typedef union { _z_t_msg_join_t _join; diff --git a/src/transport/multicast/tx.c b/src/transport/multicast/tx.c index 3d5b18c0d..4b9d034b5 100644 --- a/src/transport/multicast/tx.c +++ b/src/transport/multicast/tx.c @@ -116,7 +116,7 @@ int8_t _z_multicast_send_n_msg(_z_session_t *zn, const _z_network_message_t *n_m } else { // The message does not fit in the current batch, let's fragment it // Create an expandable wbuf for fragmentation - _z_wbuf_t fbf = _z_wbuf_make(ztm->_wbuf._capacity - 12, true); + _z_wbuf_t fbf = _z_wbuf_make(ztm->_wbuf._capacity - _Z_FRAGMENT_HEADER_SIZE, true); ret = _z_network_message_encode(&fbf, n_msg); // Encode the message on the expandable wbuf if (ret == _Z_RES_OK) { diff --git a/src/transport/raweth/tx.c b/src/transport/raweth/tx.c index 4fb0b643d..65f1231ce 100644 --- a/src/transport/raweth/tx.c +++ b/src/transport/raweth/tx.c @@ -270,7 +270,7 @@ int8_t _z_raweth_send_n_msg(_z_session_t *zn, const _z_network_message_t *n_msg, ztm->_transmitted = true; } else { // The message does not fit in the current batch, let's fragment it // Create an expandable wbuf for fragmentation - _z_wbuf_t fbf = _z_wbuf_make(ztm->_wbuf._capacity - 12, true); + _z_wbuf_t fbf = _z_wbuf_make(ztm->_wbuf._capacity - _Z_FRAGMENT_HEADER_SIZE, true); // Encode the message on the expandable wbuf _Z_RETURN_IF_ERR(_z_network_message_encode(&fbf, n_msg)); // Fragment and send the message diff --git a/src/transport/unicast/tx.c b/src/transport/unicast/tx.c index f2ac6feee..25caabee6 100644 --- a/src/transport/unicast/tx.c +++ b/src/transport/unicast/tx.c @@ -125,7 +125,7 @@ int8_t _z_unicast_send_n_msg(_z_session_t *zn, const _z_network_message_t *n_msg } else { // The message does not fit in the current batch, let's fragment it // Create an expandable wbuf for fragmentation - _z_wbuf_t fbf = _z_wbuf_make(ztu->_wbuf._capacity - 12, true); + _z_wbuf_t fbf = _z_wbuf_make(ztu->_wbuf._capacity - _Z_FRAGMENT_HEADER_SIZE, true); ret = _z_network_message_encode(&fbf, n_msg); // Encode the message on the expandable wbuf if (ret == _Z_RES_OK) {