From 6e5af8a9537944ec9651b9b203872c8fe5ad92b0 Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Wed, 27 Dec 2023 16:44:19 +0100 Subject: [PATCH 1/3] feat: switch to compiler log macro with newline --- CMakeLists.txt | 1 + include/zenoh-pico/utils/logging.h | 80 +++++++++++++++--------------- 2 files changed, 42 insertions(+), 39 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f734f072..c1e7bcf2c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -123,6 +123,7 @@ add_definition(Z_FEATURE_SUBSCRIPTION=${Z_FEATURE_SUBSCRIPTION}) add_definition(Z_FEATURE_QUERY=${Z_FEATURE_QUERY}) add_definition(Z_FEATURE_QUERYABLE=${Z_FEATURE_QUERYABLE}) add_definition(Z_FEATURE_RAWETH_TRANSPORT=${Z_FEATURE_RAWETH_TRANSPORT}) +add_compile_definitions("Z_BUILD_DEBUG=$") message(STATUS "Building with feature confing:\n\ * MULTI-THREAD: ${Z_FEATURE_MULTI_THREAD}\n\ * PUBLICATION: ${Z_FEATURE_PUBLICATION}\n\ diff --git a/include/zenoh-pico/utils/logging.h b/include/zenoh-pico/utils/logging.h index 3066fcc91..f3a5467a3 100644 --- a/include/zenoh-pico/utils/logging.h +++ b/include/zenoh-pico/utils/logging.h @@ -17,55 +17,57 @@ #include +// Logging values +#define _Z_LOG_LVL_ERROR 1 +#define _Z_LOG_LVL_INFO 2 +#define _Z_LOG_LVL_DEBUG 3 + +// Timestamp function static inline void __z_print_timestamp(void) { char ret[64]; printf("[%s ", z_time_now_as_str(ret, sizeof(ret))); } +// Logging macros #define _Z_LOG_PREFIX(prefix) \ __z_print_timestamp(); \ printf(#prefix " ::%s] ", __func__); -#if (ZENOH_DEBUG == 3) -#define _Z_DEBUG(x, ...) \ - _Z_LOG_PREFIX(DEBUG); \ - printf(x, ##__VA_ARGS__); -#define _Z_DEBUG_CONTINUE(x, ...) printf(x, ##__VA_ARGS__); -#define _Z_INFO(x, ...) \ - _Z_LOG_PREFIX(INFO); \ - printf(x, ##__VA_ARGS__); -#define _Z_INFO_CONTINUE(x, ...) printf(x, ##__VA_ARGS__); -#define _Z_ERROR(x, ...) \ - _Z_LOG_PREFIX(ERROR); \ - printf(x, ##__VA_ARGS__); -#define _Z_ERROR_CONTINUE(x, ...) printf(x, ##__VA_ARGS__); +// Ignore print only if log deactivated and build is release +#if ZENOH_DEBUG == 0 && !defined(Z_BUILD_DEBUG) + +#define _Z_DEBUG(...) (void)(0) +#define _Z_INFO(...) (void)(0) +#define _Z_ERROR(...) (void)(0) + +#else // ZENOH_DEBUG != 0 || defined(Z_BUILD_DEBUG) -#elif (ZENOH_DEBUG == 2) -#define _Z_DEBUG(x, ...) (void)(0) -#define _Z_DEBUG_CONTINUE(x, ...) (void)(0); -#define _Z_INFO(x, ...) \ - _Z_LOG_PREFIX(INFO); \ - printf(x, ##__VA_ARGS__); -#define _Z_INFO_CONTINUE(x, ...) printf(x, ##__VA_ARGS__); -#define _Z_ERROR(x, ...) \ - _Z_LOG_PREFIX(ERROR); \ - printf(x, ##__VA_ARGS__); -#define _Z_ERROR_CONTINUE(x, ...) printf(x, ##__VA_ARGS__); +#define _Z_DEBUG(...) \ + do { \ + if (ZENOH_DEBUG >= _Z_LOG_LVL_DEBUG) { \ + _Z_LOG_PREFIX(DEBUG); \ + printf(__VA_ARGS__); \ + printf("\n"); \ + } \ + } while (false) -#elif (ZENOH_DEBUG == 1) -#define _Z_DEBUG(x, ...) (void)(0) -#define _Z_DEBUG_CONTINUE(x, ...) (void)(0); -#define _Z_INFO(x, ...) (void)(0); -#define _Z_INFO_CONTINUE(x, ...) (void)(0); -#define _Z_ERROR(x, ...) \ - _Z_LOG_PREFIX(ERROR); \ - printf(x, ##__VA_ARGS__); -#define _Z_ERROR_CONTINUE(x, ...) printf(x, ##__VA_ARGS__); +#define _Z_INFO(...) \ + do { \ + if (ZENOH_DEBUG >= _Z_LOG_LVL_INFO) { \ + _Z_LOG_PREFIX(INFO); \ + printf(__VA_ARGS__); \ + printf("\n"); \ + } \ + } while (false) -#elif (ZENOH_DEBUG == 0) -#define _Z_DEBUG(x, ...) (void)(0) -#define _Z_INFO(x, ...) (void)(0) -#define _Z_ERROR(x, ...) (void)(0) -#endif +#define _Z_ERROR(...) \ + do { \ + if (ZENOH_DEBUG >= _Z_LOG_LVL_ERROR) { \ + _Z_LOG_PREFIX(ERROR); \ + printf(__VA_ARGS__); \ + printf("\n"); \ + } \ + } while (false) +#endif // ZENOH_DEBUG == 0 && !defined(Z_BUILD_DEBUG) -#endif /* ZENOH_PICO_UTILS_LOGGING_H */ +#endif // ZENOH_PICO_UTILS_LOGGING_H From d80eab685d84944050cd9bfc25aa703b4797c17e Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Wed, 27 Dec 2023 16:44:28 +0100 Subject: [PATCH 2/3] fix: remove extra newline from logs --- src/net/primitives.c | 2 +- src/net/session.c | 4 ++-- src/protocol/codec.c | 6 +++--- src/protocol/codec/ext.c | 12 +++++------ src/protocol/codec/message.c | 30 +++++++++++++------------- src/protocol/codec/network.c | 8 +++---- src/protocol/codec/transport.c | 32 ++++++++++++++-------------- src/protocol/definitions/transport.c | 8 +++---- src/protocol/ext.c | 4 ++-- src/session/query.c | 2 +- src/session/queryable.c | 2 +- src/session/resource.c | 2 +- src/session/rx.c | 14 ++++++------ src/session/scout.c | 6 +++--- src/session/subscription.c | 8 +++---- src/session/tx.c | 2 +- src/transport/multicast/lease.c | 2 +- src/transport/multicast/read.c | 2 +- src/transport/multicast/rx.c | 20 ++++++++--------- src/transport/multicast/transport.c | 2 +- src/transport/multicast/tx.c | 6 +++--- src/transport/raweth/read.c | 2 +- src/transport/raweth/rx.c | 4 ++-- src/transport/raweth/tx.c | 8 +++---- src/transport/unicast/lease.c | 2 +- src/transport/unicast/read.c | 2 +- src/transport/unicast/rx.c | 18 ++++++++-------- src/transport/unicast/transport.c | 8 +++---- src/transport/unicast/tx.c | 6 +++--- 29 files changed, 112 insertions(+), 112 deletions(-) diff --git a/src/net/primitives.c b/src/net/primitives.c index 7f0123695..1ad25d86a 100644 --- a/src/net/primitives.c +++ b/src/net/primitives.c @@ -76,7 +76,7 @@ uint16_t _z_declare_resource(_z_session_t *zn, _z_keyexpr_t keyexpr) { int8_t _z_undeclare_resource(_z_session_t *zn, uint16_t rid) { int8_t ret = _Z_RES_OK; - _Z_DEBUG("Undeclaring local keyexpr %d\n", rid); + _Z_DEBUG("Undeclaring local keyexpr %d", rid); _z_resource_t *r = _z_get_resource_by_id(zn, _Z_KEYEXPR_MAPPING_LOCAL, rid); if (r != NULL) { // Build the declare message to send on the wire diff --git a/src/net/session.c b/src/net/session.c index b9c4c947d..3423bbded 100644 --- a/src/net/session.c +++ b/src/net/session.c @@ -135,12 +135,12 @@ int8_t _z_open(_z_session_t *zn, _z_config_t *config) { break; } } else { - _Z_ERROR("Trying to configure an invalid mode.\n"); + _Z_ERROR("Trying to configure an invalid mode."); } } _z_str_array_clear(&locators); } else { - _Z_ERROR("A valid config is missing.\n"); + _Z_ERROR("A valid config is missing."); ret = _Z_ERR_GENERIC; } diff --git a/src/protocol/codec.c b/src/protocol/codec.c index 225253418..65e13ec07 100644 --- a/src/protocol/codec.c +++ b/src/protocol/codec.c @@ -141,7 +141,7 @@ int8_t _z_uint8_decode(uint8_t *u8, _z_zbuf_t *zbf) { if (_z_zbuf_can_read(zbf) == true) { *u8 = _z_zbuf_read(zbf); } else { - _Z_DEBUG("WARNING: Not enough bytes to read\n"); + _Z_DEBUG("WARNING: Not enough bytes to read"); ret |= _Z_ERR_MESSAGE_DESERIALIZATION_FAILED; } @@ -322,7 +322,7 @@ int8_t _z_bytes_val_decode_na(_z_bytes_t *bs, _z_zbuf_t *zbf) { *bs = _z_bytes_wrap(_z_zbuf_get_rptr(zbf), bs->len); // Decode without allocating _z_zbuf_set_rpos(zbf, _z_zbuf_get_rpos(zbf) + bs->len); // Move the read position } else { - _Z_DEBUG("WARNING: Not enough bytes to read\n"); + _Z_DEBUG("WARNING: Not enough bytes to read"); bs->len = 0; bs->start = NULL; ret |= _Z_ERR_MESSAGE_DESERIALIZATION_FAILED; @@ -372,7 +372,7 @@ int8_t _z_str_decode(char **str, _z_zbuf_t *zbf) { } *str = tmp; } else { - _Z_DEBUG("WARNING: Not enough bytes to read\n"); + _Z_DEBUG("WARNING: Not enough bytes to read"); *str = NULL; ret |= _Z_ERR_MESSAGE_DESERIALIZATION_FAILED; } diff --git a/src/protocol/codec/ext.c b/src/protocol/codec/ext.c index fd4f478f2..5e52f64a4 100644 --- a/src/protocol/codec/ext.c +++ b/src/protocol/codec/ext.c @@ -90,7 +90,7 @@ int8_t _z_msg_ext_encode(_z_wbuf_t *wbf, const _z_msg_ext_t *ext, _Bool has_next } break; default: { - _Z_DEBUG("WARNING: Trying to copy message extension with unknown encoding(%d)\n", enc); + _Z_DEBUG("WARNING: Trying to copy message extension with unknown encoding(%d)", enc); } break; } @@ -114,7 +114,7 @@ int8_t _z_msg_ext_unknown_body_decode(_z_msg_ext_body_t *body, uint8_t enc, _z_z } break; default: { - _Z_DEBUG("WARNING: Trying to copy message extension with unknown encoding(%d)\n", enc); + _Z_DEBUG("WARNING: Trying to copy message extension with unknown encoding(%d)", enc); } break; } @@ -171,12 +171,12 @@ int8_t _z_msg_ext_unknown_error(_z_msg_ext_t *extension, uint8_t trace_id) { #if (ZENOH_DEBUG >= 1) switch (_Z_EXT_ENC(extension->_header)) { case _Z_MSG_EXT_ENC_UNIT: { - _Z_ERROR("Unknown mandatory extension found (extension_id: %02x, trace_id: %02x), UNIT\n", ext_id, + _Z_ERROR("Unknown mandatory extension found (extension_id: %02x, trace_id: %02x), UNIT", ext_id, trace_id); break; } case _Z_MSG_EXT_ENC_ZINT: { - _Z_ERROR("Unknown mandatory extension found (extension_id: %02x, trace_id: %02x), ZINT(%02jx)\n", ext_id, + _Z_ERROR("Unknown mandatory extension found (extension_id: %02x, trace_id: %02x), ZINT(%02jx)", ext_id, trace_id, (uintmax_t)extension->_body._zint._val); break; } @@ -186,13 +186,13 @@ int8_t _z_msg_ext_unknown_error(_z_msg_ext_t *extension, uint8_t trace_id) { for (size_t i = 0; i < buf.len; ++i) { snprintf(hex + 2 * i, 3, "%02x", buf.start[i]); } - _Z_ERROR("Unknown mandatory extension found (extension_id: %02x, trace_id: %02x), ZBUF(%.*s)\n", ext_id, + _Z_ERROR("Unknown mandatory extension found (extension_id: %02x, trace_id: %02x), ZBUF(%.*s)", ext_id, trace_id, (int)buf.len * 2, hex); z_free(hex); break; } default: { - _Z_ERROR("Unknown mandatory extension found (extension_id: %02x, trace_id: %02x), UNKOWN_ENCODING\n", + _Z_ERROR("Unknown mandatory extension found (extension_id: %02x, trace_id: %02x), UNKOWN_ENCODING", ext_id, trace_id); } } diff --git a/src/protocol/codec/message.c b/src/protocol/codec/message.c index ad4279fe8..aebeeacfb 100644 --- a/src/protocol/codec/message.c +++ b/src/protocol/codec/message.c @@ -41,14 +41,14 @@ /*------------------ Payload field ------------------*/ int8_t _z_payload_encode(_z_wbuf_t *wbf, const _z_bytes_t *pld) { int8_t ret = _Z_RES_OK; - _Z_DEBUG("Encoding _PAYLOAD\n"); + _Z_DEBUG("Encoding _PAYLOAD"); ret |= _z_bytes_encode(wbf, pld); return ret; } int8_t _z_payload_decode_na(_z_bytes_t *pld, _z_zbuf_t *zbf) { - _Z_DEBUG("Decoding _PAYLOAD\n"); + _Z_DEBUG("Decoding _PAYLOAD"); return _z_bytes_decode(pld, zbf); } @@ -84,7 +84,7 @@ int8_t _z_id_decode_as_zbytes(_z_id_t *id, _z_zbuf_t *zbf) { /*------------------ Timestamp Field ------------------*/ int8_t _z_timestamp_encode(_z_wbuf_t *wbf, const _z_timestamp_t *ts) { int8_t ret = _Z_RES_OK; - _Z_DEBUG("Encoding _TIMESTAMP\n"); + _Z_DEBUG("Encoding _TIMESTAMP"); _Z_RETURN_IF_ERR(_z_uint64_encode(wbf, ts->time)) ret |= _z_id_encode_as_zbytes(wbf, &ts->id); @@ -97,7 +97,7 @@ int8_t _z_timestamp_encode_ext(_z_wbuf_t *wbf, const _z_timestamp_t *ts) { } int8_t _z_timestamp_decode(_z_timestamp_t *ts, _z_zbuf_t *zbf) { - _Z_DEBUG("Decoding _TIMESTAMP\n"); + _Z_DEBUG("Decoding _TIMESTAMP"); int8_t ret = _Z_RES_OK; ret |= _z_uint64_decode(&ts->time, zbf); @@ -109,7 +109,7 @@ int8_t _z_timestamp_decode(_z_timestamp_t *ts, _z_zbuf_t *zbf) { /*------------------ ResKey Field ------------------*/ int8_t _z_keyexpr_encode(_z_wbuf_t *wbf, _Bool has_suffix, const _z_keyexpr_t *fld) { int8_t ret = _Z_RES_OK; - _Z_DEBUG("Encoding _RESKEY\n"); + _Z_DEBUG("Encoding _RESKEY"); _Z_RETURN_IF_ERR(_z_zint_encode(wbf, fld->_id)) if (has_suffix == true) { @@ -120,7 +120,7 @@ int8_t _z_keyexpr_encode(_z_wbuf_t *wbf, _Bool has_suffix, const _z_keyexpr_t *f } int8_t _z_keyexpr_decode(_z_keyexpr_t *ke, _z_zbuf_t *zbf, _Bool has_suffix) { - _Z_DEBUG("Decoding _RESKEY\n"); + _Z_DEBUG("Decoding _RESKEY"); int8_t ret = _Z_RES_OK; ret |= _z_zint16_decode(&ke->_id, zbf); @@ -144,7 +144,7 @@ int8_t _z_keyexpr_decode(_z_keyexpr_t *ke, _z_zbuf_t *zbf, _Bool has_suffix) { /*------------------ Locators Field ------------------*/ int8_t _z_locators_encode(_z_wbuf_t *wbf, const _z_locator_array_t *la) { int8_t ret = _Z_RES_OK; - _Z_DEBUG("Encoding _LOCATORS\n"); + _Z_DEBUG("Encoding _LOCATORS"); _Z_RETURN_IF_ERR(_z_zint_encode(wbf, la->_len)) for (size_t i = 0; i < la->_len; i++) { char *s = _z_locator_to_str(&la->_val[i]); @@ -156,7 +156,7 @@ int8_t _z_locators_encode(_z_wbuf_t *wbf, const _z_locator_array_t *la) { } int8_t _z_locators_decode_na(_z_locator_array_t *a_loc, _z_zbuf_t *zbf) { - _Z_DEBUG("Decoding _LOCATORS\n"); + _Z_DEBUG("Decoding _LOCATORS"); int8_t ret = _Z_RES_OK; _z_zint_t len = 0; // Number of elements in the array @@ -453,7 +453,7 @@ int8_t _z_query_decode_extensions(_z_msg_ext_t *extension, void *ctx) { } int8_t _z_query_decode(_z_msg_query_t *msg, _z_zbuf_t *zbf, uint8_t header) { - _Z_DEBUG("Decoding _Z_MID_Z_QUERY\n"); + _Z_DEBUG("Decoding _Z_MID_Z_QUERY"); *msg = (_z_msg_query_t){0}; msg->_ext_consolidation = Z_CONSOLIDATION_MODE_AUTO; int8_t ret = _Z_RES_OK; @@ -732,7 +732,7 @@ int8_t _z_pull_decode(_z_msg_pull_t *pull, _z_zbuf_t *zbf, uint8_t header) { int8_t _z_scout_encode(_z_wbuf_t *wbf, uint8_t header, const _z_s_msg_scout_t *msg) { int8_t ret = _Z_RES_OK; (void)(header); - _Z_DEBUG("Encoding _Z_MID_SCOUT\n"); + _Z_DEBUG("Encoding _Z_MID_SCOUT"); _Z_RETURN_IF_ERR(_z_uint8_encode(wbf, msg->_version)) @@ -753,7 +753,7 @@ int8_t _z_scout_encode(_z_wbuf_t *wbf, uint8_t header, const _z_s_msg_scout_t *m int8_t _z_scout_decode(_z_s_msg_scout_t *msg, _z_zbuf_t *zbf, uint8_t header) { int8_t ret = _Z_RES_OK; (void)(header); - _Z_DEBUG("Decoding _Z_MID_SCOUT\n"); + _Z_DEBUG("Decoding _Z_MID_SCOUT"); *msg = (_z_s_msg_scout_t){0}; ret |= _z_uint8_decode(&msg->_version, zbf); @@ -773,7 +773,7 @@ int8_t _z_scout_decode(_z_s_msg_scout_t *msg, _z_zbuf_t *zbf, uint8_t header) { /*------------------ Hello Message ------------------*/ int8_t _z_hello_encode(_z_wbuf_t *wbf, uint8_t header, const _z_s_msg_hello_t *msg) { int8_t ret = _Z_RES_OK; - _Z_DEBUG("Encoding _Z_MID_HELLO\n"); + _Z_DEBUG("Encoding _Z_MID_HELLO"); _Z_RETURN_IF_ERR(_z_uint8_encode(wbf, msg->_version)) uint8_t zidlen = _z_id_len(msg->_zid); @@ -791,7 +791,7 @@ int8_t _z_hello_encode(_z_wbuf_t *wbf, uint8_t header, const _z_s_msg_hello_t *m } int8_t _z_hello_decode_na(_z_s_msg_hello_t *msg, _z_zbuf_t *zbf, uint8_t header) { - _Z_DEBUG("Decoding _Z_MID_HELLO\n"); + _Z_DEBUG("Decoding _Z_MID_HELLO"); int8_t ret = _Z_RES_OK; *msg = (_z_s_msg_hello_t){0}; @@ -841,7 +841,7 @@ int8_t _z_scouting_message_encode(_z_wbuf_t *wbf, const _z_scouting_message_t *m } break; default: { - _Z_DEBUG("WARNING: Trying to encode session message with unknown ID(%d)\n", _Z_MID(msg->_header)); + _Z_DEBUG("WARNING: Trying to encode session message with unknown ID(%d)", _Z_MID(msg->_header)); ret |= _Z_ERR_MESSAGE_TRANSPORT_UNKNOWN; } break; } @@ -870,7 +870,7 @@ int8_t _z_scouting_message_decode_na(_z_scouting_message_t *msg, _z_zbuf_t *zbf) } break; default: { - _Z_DEBUG("WARNING: Trying to decode scouting message with unknown ID(0x%x)\n", mid); + _Z_DEBUG("WARNING: Trying to decode scouting message with unknown ID(0x%x)", mid); ret |= _Z_ERR_MESSAGE_TRANSPORT_UNKNOWN; is_last = true; } break; diff --git a/src/protocol/codec/network.c b/src/protocol/codec/network.c index bdbbdfb84..22615cc09 100644 --- a/src/protocol/codec/network.c +++ b/src/protocol/codec/network.c @@ -247,7 +247,7 @@ int8_t _z_request_decode(_z_n_msg_request_t *msg, _z_zbuf_t *zbf, const uint8_t int8_t _z_response_encode(_z_wbuf_t *wbf, const _z_n_msg_response_t *msg) { int8_t ret = _Z_RES_OK; uint8_t header = _Z_MID_N_RESPONSE; - _Z_DEBUG("Encoding _Z_MID_N_RESPONSE\n"); + _Z_DEBUG("Encoding _Z_MID_N_RESPONSE"); _Bool has_qos_ext = msg->_ext_qos._val != _Z_N_QOS_DEFAULT._val; _Bool has_ts_ext = _z_timestamp_check(&msg->_ext_timestamp); _Bool has_responder_ext = _z_id_check(msg->_ext_responder._zid) || msg->_ext_responder._eid != 0; @@ -353,7 +353,7 @@ int8_t _z_response_decode_extension(_z_msg_ext_t *extension, void *ctx) { } int8_t _z_response_decode(_z_n_msg_response_t *msg, _z_zbuf_t *zbf, uint8_t header) { - _Z_DEBUG("Decoding _Z_MID_N_RESPONSE\n"); + _Z_DEBUG("Decoding _Z_MID_N_RESPONSE"); *msg = (_z_n_msg_response_t){0}; msg->_ext_qos = _Z_N_QOS_DEFAULT; int8_t ret = _Z_RES_OK; @@ -395,7 +395,7 @@ int8_t _z_response_decode(_z_n_msg_response_t *msg, _z_zbuf_t *zbf, uint8_t head break; } default: { - _Z_ERROR("Unknown N_MID: %d\n", _Z_MID(inner_header)); + _Z_ERROR("Unknown N_MID: %d", _Z_MID(inner_header)); ret = _Z_ERR_MESSAGE_DESERIALIZATION_FAILED; } } @@ -405,7 +405,7 @@ int8_t _z_response_decode(_z_n_msg_response_t *msg, _z_zbuf_t *zbf, uint8_t head /*------------------ Response Final Message ------------------*/ int8_t _z_response_final_encode(_z_wbuf_t *wbf, const _z_n_msg_response_final_t *msg) { int8_t ret = _Z_RES_OK; - _Z_DEBUG("Encoding _Z_MID_N_RESPONSE\n"); + _Z_DEBUG("Encoding _Z_MID_N_RESPONSE"); uint8_t header = _Z_MID_N_RESPONSE_FINAL; _Z_RETURN_IF_ERR(_z_uint8_encode(wbf, header)); _Z_RETURN_IF_ERR(_z_zint_encode(wbf, msg->_request_id)); diff --git a/src/protocol/codec/transport.c b/src/protocol/codec/transport.c index 79fe71b4c..2e0266447 100644 --- a/src/protocol/codec/transport.c +++ b/src/protocol/codec/transport.c @@ -30,7 +30,7 @@ /*------------------ Join Message ------------------*/ int8_t _z_join_encode(_z_wbuf_t *wbf, uint8_t header, const _z_t_msg_join_t *msg) { int8_t ret = _Z_RES_OK; - _Z_DEBUG("Encoding _Z_MID_T_JOIN\n"); + _Z_DEBUG("Encoding _Z_MID_T_JOIN"); _Z_RETURN_IF_ERR(_z_wbuf_write(wbf, msg->_version)); @@ -95,7 +95,7 @@ int8_t _z_join_decode_ext(_z_msg_ext_t *extension, void *ctx) { } int8_t _z_join_decode(_z_t_msg_join_t *msg, _z_zbuf_t *zbf, uint8_t header) { - _Z_DEBUG("Decoding _Z_MID_T_JOIN\n"); + _Z_DEBUG("Decoding _Z_MID_T_JOIN"); int8_t ret = _Z_RES_OK; *msg = (_z_t_msg_join_t){0}; @@ -147,7 +147,7 @@ int8_t _z_join_decode(_z_t_msg_join_t *msg, _z_zbuf_t *zbf, uint8_t header) { /*------------------ Init Message ------------------*/ int8_t _z_init_encode(_z_wbuf_t *wbf, uint8_t header, const _z_t_msg_init_t *msg) { - _Z_DEBUG("Encoding _Z_MID_T_INIT\n"); + _Z_DEBUG("Encoding _Z_MID_T_INIT"); int8_t ret = _Z_RES_OK; _Z_RETURN_IF_ERR(_z_wbuf_write(wbf, msg->_version)) @@ -175,7 +175,7 @@ int8_t _z_init_encode(_z_wbuf_t *wbf, uint8_t header, const _z_t_msg_init_t *msg } int8_t _z_init_decode(_z_t_msg_init_t *msg, _z_zbuf_t *zbf, uint8_t header) { - _Z_DEBUG("Decoding _Z_MID_T_INIT\n"); + _Z_DEBUG("Decoding _Z_MID_T_INIT"); *msg = (_z_t_msg_init_t){0}; int8_t ret = _Z_RES_OK; @@ -223,7 +223,7 @@ int8_t _z_init_decode(_z_t_msg_init_t *msg, _z_zbuf_t *zbf, uint8_t header) { /*------------------ Open Message ------------------*/ int8_t _z_open_encode(_z_wbuf_t *wbf, uint8_t header, const _z_t_msg_open_t *msg) { int8_t ret = _Z_RES_OK; - _Z_DEBUG("Encoding _Z_MID_T_OPEN\n"); + _Z_DEBUG("Encoding _Z_MID_T_OPEN"); if (_Z_HAS_FLAG(header, _Z_FLAG_T_OPEN_T) == true) { _Z_RETURN_IF_ERR(_z_zint_encode(wbf, msg->_lease / 1000)) @@ -241,7 +241,7 @@ int8_t _z_open_encode(_z_wbuf_t *wbf, uint8_t header, const _z_t_msg_open_t *msg } int8_t _z_open_decode(_z_t_msg_open_t *msg, _z_zbuf_t *zbf, uint8_t header) { - _Z_DEBUG("Decoding _Z_MID_T_OPEN\n"); + _Z_DEBUG("Decoding _Z_MID_T_OPEN"); int8_t ret = _Z_RES_OK; *msg = (_z_t_msg_open_t){0}; @@ -271,7 +271,7 @@ int8_t _z_open_decode(_z_t_msg_open_t *msg, _z_zbuf_t *zbf, uint8_t header) { int8_t _z_close_encode(_z_wbuf_t *wbf, uint8_t header, const _z_t_msg_close_t *msg) { (void)(header); int8_t ret = _Z_RES_OK; - _Z_DEBUG("Encoding _Z_MID_T_CLOSE\n"); + _Z_DEBUG("Encoding _Z_MID_T_CLOSE"); ret |= _z_wbuf_write(wbf, msg->_reason); @@ -282,7 +282,7 @@ int8_t _z_close_decode(_z_t_msg_close_t *msg, _z_zbuf_t *zbf, uint8_t header) { (void)(header); int8_t ret = _Z_RES_OK; *msg = (_z_t_msg_close_t){0}; - _Z_DEBUG("Decoding _Z_MID_T_CLOSE\n"); + _Z_DEBUG("Decoding _Z_MID_T_CLOSE"); ret |= _z_uint8_decode(&msg->_reason, zbf); @@ -296,7 +296,7 @@ int8_t _z_keep_alive_encode(_z_wbuf_t *wbf, uint8_t header, const _z_t_msg_keep_ (void)(msg); int8_t ret = _Z_RES_OK; - _Z_DEBUG("Encoding _Z_MID_T_KEEP_ALIVE\n"); + _Z_DEBUG("Encoding _Z_MID_T_KEEP_ALIVE"); return ret; } @@ -308,7 +308,7 @@ int8_t _z_keep_alive_decode(_z_t_msg_keep_alive_t *msg, _z_zbuf_t *zbf, uint8_t *msg = (_z_t_msg_keep_alive_t){0}; int8_t ret = _Z_RES_OK; - _Z_DEBUG("Decoding _Z_MID_T_KEEP_ALIVE\n"); + _Z_DEBUG("Decoding _Z_MID_T_KEEP_ALIVE"); if (_Z_HAS_FLAG(header, _Z_FLAG_Z_Z)) { ret |= _z_msg_ext_skip_non_mandatories(zbf, 0x03); @@ -376,7 +376,7 @@ int8_t _z_frame_decode(_z_t_msg_frame_t *msg, _z_zbuf_t *zbf, uint8_t header) { /*------------------ Fragment Message ------------------*/ int8_t _z_fragment_encode(_z_wbuf_t *wbf, uint8_t header, const _z_t_msg_fragment_t *msg) { int8_t ret = _Z_RES_OK; - _Z_DEBUG("Encoding _Z_TRANSPORT_FRAGMENT\n"); + _Z_DEBUG("Encoding _Z_TRANSPORT_FRAGMENT"); _Z_RETURN_IF_ERR(_z_zint_encode(wbf, msg->_sn)) if (_Z_HAS_FLAG(header, _Z_FLAG_T_Z)) { ret = _Z_ERR_MESSAGE_SERIALIZATION_FAILED; @@ -392,7 +392,7 @@ int8_t _z_fragment_decode(_z_t_msg_fragment_t *msg, _z_zbuf_t *zbf, uint8_t head int8_t ret = _Z_RES_OK; *msg = (_z_t_msg_fragment_t){0}; - _Z_DEBUG("Decoding _Z_TRANSPORT_FRAGMENT\n"); + _Z_DEBUG("Decoding _Z_TRANSPORT_FRAGMENT"); ret |= _z_zint_decode(&msg->_sn, zbf); if ((ret == _Z_RES_OK) && (_Z_HAS_FLAG(header, _Z_FLAG_T_Z) == true)) { @@ -411,7 +411,7 @@ int8_t _z_extensions_encode(_z_wbuf_t *wbf, uint8_t header, const _z_msg_ext_vec (void)(header); int8_t ret = _Z_RES_OK; - _Z_DEBUG("Encoding _Z_TRANSPORT_EXTENSIONS\n"); + _Z_DEBUG("Encoding _Z_TRANSPORT_EXTENSIONS"); if (_Z_HAS_FLAG(header, _Z_FLAG_T_Z) == true) { ret |= _z_msg_ext_vec_encode(wbf, v_ext); } @@ -423,7 +423,7 @@ int8_t _z_extensions_decode(_z_msg_ext_vec_t *v_ext, _z_zbuf_t *zbf, uint8_t hea (void)(header); int8_t ret = _Z_RES_OK; - _Z_DEBUG("Decoding _Z_TRANSPORT_EXTENSIONS\n"); + _Z_DEBUG("Decoding _Z_TRANSPORT_EXTENSIONS"); if (_Z_HAS_FLAG(header, _Z_FLAG_T_Z) == true) { ret |= _z_msg_ext_vec_decode(v_ext, zbf); } else { @@ -463,7 +463,7 @@ int8_t _z_transport_message_encode(_z_wbuf_t *wbf, const _z_transport_message_t ret |= _z_close_encode(wbf, msg->_header, &msg->_body._close); } break; default: { - _Z_DEBUG("WARNING: Trying to encode session message with unknown ID(%d)\n", _Z_MID(msg->_header)); + _Z_DEBUG("WARNING: Trying to encode session message with unknown ID(%d)", _Z_MID(msg->_header)); ret |= _Z_ERR_MESSAGE_TRANSPORT_UNKNOWN; } break; } @@ -500,7 +500,7 @@ int8_t _z_transport_message_decode(_z_transport_message_t *msg, _z_zbuf_t *zbf) ret |= _z_close_decode(&msg->_body._close, zbf, msg->_header); } break; default: { - _Z_DEBUG("WARNING: Trying to decode session message with unknown ID(0x%x) (header=0x%x)\n", mid, + _Z_DEBUG("WARNING: Trying to decode session message with unknown ID(0x%x) (header=0x%x)", mid, msg->_header); ret |= _Z_ERR_MESSAGE_TRANSPORT_UNKNOWN; } break; diff --git a/src/protocol/definitions/transport.c b/src/protocol/definitions/transport.c index 6960672a4..44efd5837 100644 --- a/src/protocol/definitions/transport.c +++ b/src/protocol/definitions/transport.c @@ -70,7 +70,7 @@ void _z_t_msg_clear(_z_transport_message_t *msg) { } break; default: { - _Z_DEBUG("WARNING: Trying to clear transport message with unknown ID(%d)\n", mid); + _Z_DEBUG("WARNING: Trying to clear transport message with unknown ID(%d)", mid); } break; } } @@ -330,7 +330,7 @@ void _z_t_msg_copy(_z_transport_message_t *clone, _z_transport_message_t *msg) { } break; default: { - _Z_DEBUG("WARNING: Trying to copy transport message with unknown ID(%d)\n", mid); + _Z_DEBUG("WARNING: Trying to copy transport message with unknown ID(%d)", mid); } break; } } @@ -347,7 +347,7 @@ void _z_s_msg_clear(_z_scouting_message_t *msg) { } break; default: { - _Z_DEBUG("WARNING: Trying to clear session message with unknown ID(%d)\n", mid); + _Z_DEBUG("WARNING: Trying to clear session message with unknown ID(%d)", mid); } break; } } @@ -411,7 +411,7 @@ void _z_s_msg_copy(_z_scouting_message_t *clone, _z_scouting_message_t *msg) { } break; default: { - _Z_DEBUG("WARNING: Trying to copy session message with unknown ID(%d)\n", mid); + _Z_DEBUG("WARNING: Trying to copy session message with unknown ID(%d)", mid); } break; } } \ No newline at end of file diff --git a/src/protocol/ext.c b/src/protocol/ext.c index 6202c11df..0f3c3a56c 100644 --- a/src/protocol/ext.c +++ b/src/protocol/ext.c @@ -88,7 +88,7 @@ void _z_msg_ext_copy(_z_msg_ext_t *clone, const _z_msg_ext_t *ext) { } break; default: { - _Z_DEBUG("WARNING: Trying to copy message extension with unknown encoding(%d)\n", enc); + _Z_DEBUG("WARNING: Trying to copy message extension with unknown encoding(%d)", enc); } break; } } @@ -109,7 +109,7 @@ void _z_msg_ext_clear(_z_msg_ext_t *ext) { } break; default: { - _Z_DEBUG("WARNING: Trying to free message extension with unknown encoding(%d)\n", enc); + _Z_DEBUG("WARNING: Trying to free message extension with unknown encoding(%d)", enc); } break; } } diff --git a/src/session/query.c b/src/session/query.c index d6a7a7910..9cb40da5f 100644 --- a/src/session/query.c +++ b/src/session/query.c @@ -118,7 +118,7 @@ _z_pending_query_t *_z_get_pending_query_by_id(_z_session_t *zn, const _z_zint_t int8_t _z_register_pending_query(_z_session_t *zn, _z_pending_query_t *pen_qry) { int8_t ret = _Z_RES_OK; - _Z_DEBUG(">>> Allocating query for (%ju:%s,%s)\n", (uintmax_t)pen_qry->_key._id, pen_qry->_key._suffix, + _Z_DEBUG(">>> Allocating query for (%ju:%s,%s)", (uintmax_t)pen_qry->_key._id, pen_qry->_key._suffix, pen_qry->_parameters); #if Z_FEATURE_MULTI_THREAD == 1 diff --git a/src/session/queryable.c b/src/session/queryable.c index 243519b69..29aad8c79 100644 --- a/src/session/queryable.c +++ b/src/session/queryable.c @@ -119,7 +119,7 @@ _z_questionable_sptr_list_t *_z_get_questionable_by_key(_z_session_t *zn, const } _z_questionable_sptr_t *_z_register_questionable(_z_session_t *zn, _z_questionable_t *q) { - _Z_DEBUG(">>> Allocating queryable for (%ju:%s)\n", (uintmax_t)q->_key._id, q->_key._suffix); + _Z_DEBUG(">>> Allocating queryable for (%ju:%s)", (uintmax_t)q->_key._id, q->_key._suffix); _z_questionable_sptr_t *ret = NULL; #if Z_FEATURE_MULTI_THREAD == 1 diff --git a/src/session/resource.c b/src/session/resource.c index 8a36ef951..b3ff129d1 100644 --- a/src/session/resource.c +++ b/src/session/resource.c @@ -264,7 +264,7 @@ int16_t _z_register_resource(_z_session_t *zn, _z_keyexpr_t key, uint16_t id, ui void _z_unregister_resource(_z_session_t *zn, uint16_t id, uint16_t mapping) { _Bool is_local = mapping == _Z_KEYEXPR_MAPPING_LOCAL; - _Z_DEBUG("unregistering: id %d, mapping: %d\n", id, mapping); + _Z_DEBUG("unregistering: id %d, mapping: %d", id, mapping); #if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_lock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 diff --git a/src/session/rx.c b/src/session/rx.c index 00e708a14..af14e8d71 100644 --- a/src/session/rx.c +++ b/src/session/rx.c @@ -39,7 +39,7 @@ int8_t _z_handle_network_message(_z_session_t *zn, _z_zenoh_message_t *msg, uint switch (msg->_tag) { case _Z_N_DECLARE: { - _Z_DEBUG("Handling _Z_N_DECLARE\n"); + _Z_DEBUG("Handling _Z_N_DECLARE"); _z_n_msg_declare_t decl = msg->_body._declare; switch (decl._decl._tag) { case _Z_DECL_KEXPR: { @@ -81,12 +81,12 @@ int8_t _z_handle_network_message(_z_session_t *zn, _z_zenoh_message_t *msg, uint } } break; case _Z_N_PUSH: { - _Z_DEBUG("Handling _Z_N_PUSH\n"); + _Z_DEBUG("Handling _Z_N_PUSH"); _z_n_msg_push_t *push = &msg->_body._push; ret = _z_trigger_push(zn, push); } break; case _Z_N_REQUEST: { - _Z_DEBUG("Handling _Z_N_REQUEST\n"); + _Z_DEBUG("Handling _Z_N_REQUEST"); _z_n_msg_request_t req = msg->_body._request; switch (req._tag) { case _Z_REQUEST_QUERY: { @@ -94,7 +94,7 @@ int8_t _z_handle_network_message(_z_session_t *zn, _z_zenoh_message_t *msg, uint _z_msg_query_t *query = &req._body._query; ret = _z_trigger_queryables(zn, query, req._key, (uint32_t)req._rid); #else - _Z_DEBUG("_Z_REQUEST_QUERY dropped, queryables not supported\n"); + _Z_DEBUG("_Z_REQUEST_QUERY dropped, queryables not supported"); #endif } break; case _Z_REQUEST_PUT: { @@ -129,7 +129,7 @@ int8_t _z_handle_network_message(_z_session_t *zn, _z_zenoh_message_t *msg, uint } } break; case _Z_N_RESPONSE: { - _Z_DEBUG("Handling _Z_N_RESPONSE\n"); + _Z_DEBUG("Handling _Z_N_RESPONSE"); _z_n_msg_response_t response = msg->_body._response; switch (response._tag) { case _Z_RESPONSE_BODY_REPLY: { @@ -140,7 +140,7 @@ int8_t _z_handle_network_message(_z_session_t *zn, _z_zenoh_message_t *msg, uint // @TODO: expose errors to the user _z_msg_err_t error = response._body._err; _z_bytes_t payload = error._ext_value.payload; - _Z_ERROR("Received Err for query %zu: code=%d, message=%.*s\n", response._request_id, error._code, + _Z_ERROR("Received Err for query %zu: code=%d, message=%.*s", response._request_id, error._code, (int)payload.len, payload.start); } break; case _Z_RESPONSE_BODY_ACK: { @@ -163,7 +163,7 @@ int8_t _z_handle_network_message(_z_session_t *zn, _z_zenoh_message_t *msg, uint } } break; case _Z_N_RESPONSE_FINAL: { - _Z_DEBUG("Handling _Z_N_RESPONSE_FINAL\n"); + _Z_DEBUG("Handling _Z_N_RESPONSE_FINAL"); ret = _z_trigger_reply_final(zn, &msg->_body._response_final); } break; } diff --git a/src/session/scout.c b/src/session/scout.c index efdd80938..b3a8dffb8 100644 --- a/src/session/scout.c +++ b/src/session/scout.c @@ -69,13 +69,13 @@ _z_hello_list_t *__z_scout_loop(const _z_wbuf_t *wbf, const char *locator, unsig _z_scouting_message_t s_msg; err = _z_scouting_message_decode(&s_msg, &zbf); if (err != _Z_RES_OK) { - _Z_ERROR("Scouting loop received malformed message\n"); + _Z_ERROR("Scouting loop received malformed message"); continue; } switch (_Z_MID(s_msg._header)) { case _Z_MID_HELLO: { - _Z_INFO("Received _Z_HELLO message\n"); + _Z_INFO("Received _Z_HELLO message"); _z_hello_t *hello = (_z_hello_t *)z_malloc(sizeof(_z_hello_t)); if (hello != NULL) { hello->version = s_msg._body._hello._version; @@ -102,7 +102,7 @@ _z_hello_list_t *__z_scout_loop(const _z_wbuf_t *wbf, const char *locator, unsig } default: { err = _Z_ERR_MESSAGE_UNEXPECTED; - _Z_ERROR("Scouting loop received unexpected message\n"); + _Z_ERROR("Scouting loop received unexpected message"); break; } } diff --git a/src/session/subscription.c b/src/session/subscription.c index fbb52e6b0..487d927aa 100644 --- a/src/session/subscription.c +++ b/src/session/subscription.c @@ -125,7 +125,7 @@ _z_subscription_sptr_list_t *_z_get_subscriptions_by_key(_z_session_t *zn, uint8 } _z_subscription_sptr_t *_z_register_subscription(_z_session_t *zn, uint8_t is_local, _z_subscription_t *s) { - _Z_DEBUG(">>> Allocating sub decl for (%ju:%s)\n", (uintmax_t)s->_key._id, s->_key._suffix); + _Z_DEBUG(">>> Allocating sub decl for (%ju:%s)", (uintmax_t)s->_key._id, s->_key._suffix); _z_subscription_sptr_t *ret = NULL; #if Z_FEATURE_MULTI_THREAD == 1 @@ -160,9 +160,9 @@ int8_t _z_trigger_subscriptions(_z_session_t *zn, const _z_keyexpr_t keyexpr, co _z_mutex_lock(&zn->_mutex_inner); #endif // Z_FEATURE_MULTI_THREAD == 1 - _Z_DEBUG("Resolving %d - %s on mapping 0x%x\n", keyexpr._id, keyexpr._suffix, _z_keyexpr_mapping_id(&keyexpr)); + _Z_DEBUG("Resolving %d - %s on mapping 0x%x", keyexpr._id, keyexpr._suffix, _z_keyexpr_mapping_id(&keyexpr)); _z_keyexpr_t key = __unsafe_z_get_expanded_key_from_key(zn, &keyexpr); - _Z_DEBUG("Triggering subs for %d - %s\n", key._id, key._suffix); + _Z_DEBUG("Triggering subs for %d - %s", key._id, key._suffix); if (key._suffix != NULL) { _z_subscription_sptr_list_t *subs = __unsafe_z_get_subscriptions_by_key(zn, _Z_RESOURCE_IS_LOCAL, key); @@ -178,7 +178,7 @@ int8_t _z_trigger_subscriptions(_z_session_t *zn, const _z_keyexpr_t keyexpr, co s.kind = kind; s.timestamp = timestamp; _z_subscription_sptr_list_t *xs = subs; - _Z_DEBUG("Triggering %ju subs\n", (uintmax_t)_z_subscription_sptr_list_len(xs)); + _Z_DEBUG("Triggering %ju subs", (uintmax_t)_z_subscription_sptr_list_len(xs)); while (xs != NULL) { _z_subscription_sptr_t *sub = _z_subscription_sptr_list_head(xs); sub->ptr->_callback(&s, sub->ptr->_arg); diff --git a/src/session/tx.c b/src/session/tx.c index 8f5b925bb..50f55f9e4 100644 --- a/src/session/tx.c +++ b/src/session/tx.c @@ -21,7 +21,7 @@ int8_t _z_send_n_msg(_z_session_t *zn, const _z_network_message_t *z_msg, z_reliability_t reliability, z_congestion_control_t cong_ctrl) { int8_t ret = _Z_RES_OK; - _Z_DEBUG(">> send network message\n"); + _Z_DEBUG(">> send network message"); // Call transport function switch (zn->_tp._type) { case _Z_TRANSPORT_UNICAST_TYPE: diff --git a/src/transport/multicast/lease.c b/src/transport/multicast/lease.c index 2d3a0d496..733b46cb7 100644 --- a/src/transport/multicast/lease.c +++ b/src/transport/multicast/lease.c @@ -111,7 +111,7 @@ void *_zp_multicast_lease_task(void *ztm_arg) { entry->_next_lease = entry->_lease; it = _z_transport_peer_entry_list_tail(it); } else { - _Z_INFO("Remove peer from know list because it has expired after %zums\n", entry->_lease); + _Z_INFO("Remove peer from know list because it has expired after %zums", entry->_lease); ztm->_peers = _z_transport_peer_entry_list_drop_filter(ztm->_peers, _z_transport_peer_entry_eq, entry); it = ztm->_peers; diff --git a/src/transport/multicast/read.c b/src/transport/multicast/read.c index 6d50f580d..1e940fa04 100644 --- a/src/transport/multicast/read.c +++ b/src/transport/multicast/read.c @@ -115,7 +115,7 @@ void *_zp_multicast_read_task(void *ztm_arg) { continue; } } else { - _Z_ERROR("Connection closed due to malformed message\n"); + _Z_ERROR("Connection closed due to malformed message"); ztm->_read_task_running = false; continue; } diff --git a/src/transport/multicast/rx.c b/src/transport/multicast/rx.c index cb8fdeeb7..528da2398 100644 --- a/src/transport/multicast/rx.c +++ b/src/transport/multicast/rx.c @@ -30,7 +30,7 @@ #if Z_FEATURE_MULTICAST_TRANSPORT == 1 static int8_t _z_multicast_recv_t_msg_na(_z_transport_multicast_t *ztm, _z_transport_message_t *t_msg, _z_bytes_t *addr) { - _Z_DEBUG(">> recv session msg\n"); + _Z_DEBUG(">> recv session msg"); int8_t ret = _Z_RES_OK; #if Z_FEATURE_MULTI_THREAD == 1 @@ -77,7 +77,7 @@ static int8_t _z_multicast_recv_t_msg_na(_z_transport_multicast_t *ztm, _z_trans } while (false); // The 1-iteration loop to use continue to break the entire loop on error if (ret == _Z_RES_OK) { - _Z_DEBUG(">> \t transport_message_decode: %ju\n", (uintmax_t)_z_zbuf_len(&ztm->_zbuf)); + _Z_DEBUG(">> \t transport_message_decode: %ju", (uintmax_t)_z_zbuf_len(&ztm->_zbuf)); ret = _z_transport_message_decode(t_msg, &ztm->_zbuf); } @@ -132,7 +132,7 @@ int8_t _z_multicast_handle_transport_message(_z_transport_multicast_t *ztm, _z_t _z_transport_peer_entry_t *entry = _z_find_peer_entry(ztm->_peers, addr); switch (_Z_MID(t_msg->_header)) { case _Z_MID_T_FRAME: { - _Z_INFO("Received _Z_FRAME message\n"); + _Z_INFO("Received _Z_FRAME message"); if (entry == NULL) { break; } @@ -147,7 +147,7 @@ int8_t _z_multicast_handle_transport_message(_z_transport_multicast_t *ztm, _z_t entry->_sn_rx_sns._val._plain._reliable = t_msg->_body._frame._sn; } else { _z_wbuf_clear(&entry->_dbuf_reliable); - _Z_INFO("Reliable message dropped because it is out of order\n"); + _Z_INFO("Reliable message dropped because it is out of order"); break; } } else { @@ -156,7 +156,7 @@ int8_t _z_multicast_handle_transport_message(_z_transport_multicast_t *ztm, _z_t entry->_sn_rx_sns._val._plain._best_effort = t_msg->_body._frame._sn; } else { _z_wbuf_clear(&entry->_dbuf_best_effort); - _Z_INFO("Best effort message dropped because it is out of order\n"); + _Z_INFO("Best effort message dropped because it is out of order"); break; } } @@ -174,7 +174,7 @@ int8_t _z_multicast_handle_transport_message(_z_transport_multicast_t *ztm, _z_t } case _Z_MID_T_FRAGMENT: { - _Z_INFO("Received Z_FRAGMENT message\n"); + _Z_INFO("Received Z_FRAGMENT message"); if (entry == NULL) { break; } @@ -222,7 +222,7 @@ int8_t _z_multicast_handle_transport_message(_z_transport_multicast_t *ztm, _z_t } case _Z_MID_T_KEEP_ALIVE: { - _Z_INFO("Received _Z_KEEP_ALIVE message\n"); + _Z_INFO("Received _Z_KEEP_ALIVE message"); if (entry == NULL) { break; } @@ -242,7 +242,7 @@ int8_t _z_multicast_handle_transport_message(_z_transport_multicast_t *ztm, _z_t } case _Z_MID_T_JOIN: { - _Z_INFO("Received _Z_JOIN message\n"); + _Z_INFO("Received _Z_JOIN message"); if (t_msg->_body._join._version != Z_PROTO_VERSION) { break; } @@ -310,7 +310,7 @@ int8_t _z_multicast_handle_transport_message(_z_transport_multicast_t *ztm, _z_t } case _Z_MID_T_CLOSE: { - _Z_INFO("Closing session as requested by the remote peer\n"); + _Z_INFO("Closing session as requested by the remote peer"); if (entry == NULL) { break; @@ -321,7 +321,7 @@ int8_t _z_multicast_handle_transport_message(_z_transport_multicast_t *ztm, _z_t } default: { - _Z_ERROR("Unknown session message ID\n"); + _Z_ERROR("Unknown session message ID"); break; } } diff --git a/src/transport/multicast/transport.c b/src/transport/multicast/transport.c index 2e5796399..fb7742cb6 100644 --- a/src/transport/multicast/transport.c +++ b/src/transport/multicast/transport.c @@ -135,7 +135,7 @@ int8_t _z_multicast_open_peer(_z_transport_multicast_establish_param_t *param, c _z_transport_message_t jsm = _z_t_msg_make_join(Z_WHATAMI_PEER, Z_TRANSPORT_LEASE, zid, next_sn); // Encode and send the message - _Z_INFO("Sending Z_JOIN message\n"); + _Z_INFO("Sending Z_JOIN message"); switch (zl->_cap._transport) { case Z_LINK_CAP_TRANSPORT_MULTICAST: ret = _z_link_send_t_msg(zl, &jsm); diff --git a/src/transport/multicast/tx.c b/src/transport/multicast/tx.c index 4b2d77c6c..29c8a7986 100644 --- a/src/transport/multicast/tx.c +++ b/src/transport/multicast/tx.c @@ -42,7 +42,7 @@ _z_zint_t __unsafe_z_multicast_get_sn(_z_transport_multicast_t *ztm, z_reliabili int8_t _z_multicast_send_t_msg(_z_transport_multicast_t *ztm, const _z_transport_message_t *t_msg) { int8_t ret = _Z_RES_OK; - _Z_DEBUG(">> send session message\n"); + _Z_DEBUG(">> send session message"); #if Z_FEATURE_MULTI_THREAD == 1 // Acquire the lock @@ -74,7 +74,7 @@ int8_t _z_multicast_send_t_msg(_z_transport_multicast_t *ztm, const _z_transport int8_t _z_multicast_send_n_msg(_z_session_t *zn, const _z_network_message_t *n_msg, z_reliability_t reliability, z_congestion_control_t cong_ctrl) { int8_t ret = _Z_RES_OK; - _Z_DEBUG(">> send network message\n"); + _Z_DEBUG(">> send network message"); _z_transport_multicast_t *ztm = &zn->_tp._transport._multicast; @@ -88,7 +88,7 @@ int8_t _z_multicast_send_n_msg(_z_session_t *zn, const _z_network_message_t *n_m #if Z_FEATURE_MULTI_THREAD == 1 int8_t locked = _z_mutex_trylock(&ztm->_mutex_tx); if (locked != (int8_t)0) { - _Z_INFO("Dropping zenoh message because of congestion control\n"); + _Z_INFO("Dropping zenoh message because of congestion control"); // We failed to acquire the lock, drop the message drop = true; } diff --git a/src/transport/raweth/read.c b/src/transport/raweth/read.c index 11cb7141a..41de62795 100644 --- a/src/transport/raweth/read.c +++ b/src/transport/raweth/read.c @@ -67,7 +67,7 @@ void *_zp_raweth_read_task(void *ztm_arg) { break; default: // Drop message & stop task - _Z_ERROR("Connection closed due to malformed message\n"); + _Z_ERROR("Connection closed due to malformed message"); ztm->_read_task_running = false; continue; break; diff --git a/src/transport/raweth/rx.c b/src/transport/raweth/rx.c index 6deec0839..35fd9bba3 100644 --- a/src/transport/raweth/rx.c +++ b/src/transport/raweth/rx.c @@ -73,7 +73,7 @@ static size_t _z_raweth_link_recv_zbuf(const _z_link_t *link, _z_zbuf_t *zbf, _z /*------------------ Reception helper ------------------*/ int8_t _z_raweth_recv_t_msg_na(_z_transport_multicast_t *ztm, _z_transport_message_t *t_msg, _z_bytes_t *addr) { - _Z_DEBUG(">> recv session msg\n"); + _Z_DEBUG(">> recv session msg"); int8_t ret = _Z_RES_OK; #if Z_FEATURE_MULTI_THREAD == 1 @@ -101,7 +101,7 @@ int8_t _z_raweth_recv_t_msg_na(_z_transport_multicast_t *ztm, _z_transport_messa } // Decode message if (ret == _Z_RES_OK) { - _Z_DEBUG(">> \t transport_message_decode: %ju\n", (uintmax_t)_z_zbuf_len(&ztm->_zbuf)); + _Z_DEBUG(">> \t transport_message_decode: %ju", (uintmax_t)_z_zbuf_len(&ztm->_zbuf)); ret = _z_transport_message_decode(t_msg, &ztm->_zbuf); } diff --git a/src/transport/raweth/tx.c b/src/transport/raweth/tx.c index 80d96f7b6..55c04555b 100644 --- a/src/transport/raweth/tx.c +++ b/src/transport/raweth/tx.c @@ -69,7 +69,7 @@ static int8_t _zp_raweth_set_socket(const _z_keyexpr_t *keyexpr, _z_raweth_socke // Key not found case if (idx < 0) { idx = 0; // Set to default entry - _Z_DEBUG("Key '%s' wasn't found in config mapping, sending to default address\n", keyexpr->_suffix); + _Z_DEBUG("Key '%s' wasn't found in config mapping, sending to default address", keyexpr->_suffix); } // Store data into socket memcpy(&sock->_dmac, &_ZP_RAWETH_CFG_ARRAY[idx]._dmac, _ZP_MAC_ADDR_LENGTH); @@ -192,7 +192,7 @@ int8_t _z_raweth_link_send_t_msg(const _z_link_t *zl, const _z_transport_message int8_t _z_raweth_send_t_msg(_z_transport_multicast_t *ztm, const _z_transport_message_t *t_msg) { int8_t ret = _Z_RES_OK; - _Z_DEBUG(">> send session message\n"); + _Z_DEBUG(">> send session message"); #if Z_FEATURE_MULTI_THREAD == 1 _z_mutex_lock(&ztm->_mutex_tx); @@ -223,7 +223,7 @@ int8_t _z_raweth_send_n_msg(_z_session_t *zn, const _z_network_message_t *n_msg, z_congestion_control_t cong_ctrl) { int8_t ret = _Z_RES_OK; _z_transport_multicast_t *ztm = &zn->_tp._transport._raweth; - _Z_DEBUG(">> send network message\n"); + _Z_DEBUG(">> send network message"); // Acquire the lock and drop the message if needed #if Z_FEATURE_MULTI_THREAD == 1 @@ -231,7 +231,7 @@ int8_t _z_raweth_send_n_msg(_z_session_t *zn, const _z_network_message_t *n_msg, _z_mutex_lock(&ztm->_mutex_tx); } else { if (_z_mutex_trylock(&ztm->_mutex_tx) != (int8_t)0) { - _Z_INFO("Dropping zenoh message because of congestion control\n"); + _Z_INFO("Dropping zenoh message because of congestion control"); // We failed to acquire the lock, drop the message return ret; } diff --git a/src/transport/unicast/lease.c b/src/transport/unicast/lease.c index cd63416f5..a263b3e61 100644 --- a/src/transport/unicast/lease.c +++ b/src/transport/unicast/lease.c @@ -53,7 +53,7 @@ void *_zp_unicast_lease_task(void *ztu_arg) { // Reset the lease parameters ztu->_received = false; } else { - _Z_INFO("Closing session because it has expired after %zums\n", ztu->_lease); + _Z_INFO("Closing session because it has expired after %zums", ztu->_lease); ztu->_lease_task_running = false; _z_unicast_transport_close(ztu, _Z_CLOSE_EXPIRED); break; diff --git a/src/transport/unicast/read.c b/src/transport/unicast/read.c index 36598118a..f99bbbaf1 100644 --- a/src/transport/unicast/read.c +++ b/src/transport/unicast/read.c @@ -109,7 +109,7 @@ void *_zp_unicast_read_task(void *ztu_arg) { continue; } } else { - _Z_ERROR("Connection closed due to malformed message\n\n\n"); + _Z_ERROR("Connection closed due to malformed message"); ztu->_read_task_running = false; continue; } diff --git a/src/transport/unicast/rx.c b/src/transport/unicast/rx.c index f925600f7..98ea0c5d8 100644 --- a/src/transport/unicast/rx.c +++ b/src/transport/unicast/rx.c @@ -28,7 +28,7 @@ #if Z_FEATURE_UNICAST_TRANSPORT == 1 int8_t _z_unicast_recv_t_msg_na(_z_transport_unicast_t *ztu, _z_transport_message_t *t_msg) { - _Z_DEBUG(">> recv session msg\n"); + _Z_DEBUG(">> recv session msg"); int8_t ret = _Z_RES_OK; #if Z_FEATURE_MULTI_THREAD == 1 // Acquire the lock @@ -75,7 +75,7 @@ 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 if (ret == _Z_RES_OK) { - _Z_DEBUG(">> \t transport_message_decode\n"); + _Z_DEBUG(">> \t transport_message_decode"); ret = _z_transport_message_decode(t_msg, &ztu->_zbuf); // Mark the session that we have received data @@ -100,7 +100,7 @@ int8_t _z_unicast_handle_transport_message(_z_transport_unicast_t *ztu, _z_trans switch (_Z_MID(t_msg->_header)) { case _Z_MID_T_FRAME: { - _Z_INFO("Received Z_FRAME message\n"); + _Z_INFO("Received Z_FRAME message"); // Check if the SN is correct if (_Z_HAS_FLAG(t_msg->_header, _Z_FLAG_T_FRAME_R) == true) { // @TODO: amend once reliability is in place. For the time being only @@ -109,7 +109,7 @@ int8_t _z_unicast_handle_transport_message(_z_transport_unicast_t *ztu, _z_trans ztu->_sn_rx_reliable = t_msg->_body._frame._sn; } else { _z_wbuf_clear(&ztu->_dbuf_reliable); - _Z_INFO("Reliable message dropped because it is out of order\n"); + _Z_INFO("Reliable message dropped because it is out of order"); break; } } else { @@ -117,7 +117,7 @@ int8_t _z_unicast_handle_transport_message(_z_transport_unicast_t *ztu, _z_trans ztu->_sn_rx_best_effort = t_msg->_body._frame._sn; } else { _z_wbuf_clear(&ztu->_dbuf_best_effort); - _Z_INFO("Best effort message dropped because it is out of order\n"); + _Z_INFO("Best effort message dropped because it is out of order"); break; } } @@ -164,7 +164,7 @@ int8_t _z_unicast_handle_transport_message(_z_transport_unicast_t *ztu, _z_trans _z_msg_clear(&zm); // Clear must be explicitly called for fragmented zenoh messages. Non-fragmented // zenoh messages are released when their transport message is released. } else { - _Z_DEBUG("Failed to decode defragmented message\n"); + _Z_DEBUG("Failed to decode defragmented message"); } // Free the decoding buffer @@ -176,7 +176,7 @@ int8_t _z_unicast_handle_transport_message(_z_transport_unicast_t *ztu, _z_trans } case _Z_MID_T_KEEP_ALIVE: { - _Z_INFO("Received Z_KEEP_ALIVE message\n"); + _Z_INFO("Received Z_KEEP_ALIVE message"); break; } @@ -191,13 +191,13 @@ int8_t _z_unicast_handle_transport_message(_z_transport_unicast_t *ztu, _z_trans } case _Z_MID_T_CLOSE: { - _Z_INFO("Closing session as requested by the remote peer\n"); + _Z_INFO("Closing session as requested by the remote peer"); ret = _Z_ERR_CONNECTION_CLOSED; break; } default: { - _Z_ERROR("Unknown session message ID\n"); + _Z_ERROR("Unknown session message ID"); break; } } diff --git a/src/transport/unicast/transport.c b/src/transport/unicast/transport.c index b41a9ce55..564169f23 100644 --- a/src/transport/unicast/transport.c +++ b/src/transport/unicast/transport.c @@ -157,7 +157,7 @@ int8_t _z_unicast_open_client(_z_transport_unicast_establish_param_t *param, con param->_batch_size = ism._body._init._batch_size; // The announced batch size // Encode and send the message - _Z_INFO("Sending Z_INIT(Syn)\n"); + _Z_INFO("Sending Z_INIT(Syn)"); ret = _z_link_send_t_msg(zl, &ism); _z_t_msg_clear(&ism); if (ret == _Z_RES_OK) { @@ -165,7 +165,7 @@ int8_t _z_unicast_open_client(_z_transport_unicast_establish_param_t *param, con ret = _z_link_recv_t_msg(&iam, zl); if (ret == _Z_RES_OK) { if ((_Z_MID(iam._header) == _Z_MID_T_INIT) && (_Z_HAS_FLAG(iam._header, _Z_FLAG_T_INIT_A) == true)) { - _Z_INFO("Received Z_INIT(Ack)\n"); + _Z_INFO("Received Z_INIT(Ack)"); // Any of the size parameters in the InitAck must be less or equal than the one in the InitSyn, // otherwise the InitAck message is considered invalid and it should be treated as a @@ -208,7 +208,7 @@ int8_t _z_unicast_open_client(_z_transport_unicast_establish_param_t *param, con _z_transport_message_t osm = _z_t_msg_make_open_syn(lease, initial_sn, cookie); // Encode and send the message - _Z_INFO("Sending Z_OPEN(Syn)\n"); + _Z_INFO("Sending Z_OPEN(Syn)"); ret = _z_link_send_t_msg(zl, &osm); if (ret == _Z_RES_OK) { _z_transport_message_t oam; @@ -216,7 +216,7 @@ int8_t _z_unicast_open_client(_z_transport_unicast_establish_param_t *param, con if (ret == _Z_RES_OK) { if ((_Z_MID(oam._header) == _Z_MID_T_OPEN) && (_Z_HAS_FLAG(oam._header, _Z_FLAG_T_OPEN_A) == true)) { - _Z_INFO("Received Z_OPEN(Ack)\n"); + _Z_INFO("Received Z_OPEN(Ack)"); param->_lease = oam._body._open._lease; // The session lease // The initial SN at RX side. Initialize the session as we had already received diff --git a/src/transport/unicast/tx.c b/src/transport/unicast/tx.c index 7fce59560..3406bac64 100644 --- a/src/transport/unicast/tx.c +++ b/src/transport/unicast/tx.c @@ -45,7 +45,7 @@ _z_zint_t __unsafe_z_unicast_get_sn(_z_transport_unicast_t *ztu, z_reliability_t int8_t _z_unicast_send_t_msg(_z_transport_unicast_t *ztu, const _z_transport_message_t *t_msg) { int8_t ret = _Z_RES_OK; - _Z_DEBUG(">> send session message\n"); + _Z_DEBUG(">> send session message"); #if Z_FEATURE_MULTI_THREAD == 1 // Acquire the lock @@ -77,7 +77,7 @@ int8_t _z_unicast_send_t_msg(_z_transport_unicast_t *ztu, const _z_transport_mes int8_t _z_unicast_send_n_msg(_z_session_t *zn, const _z_network_message_t *n_msg, z_reliability_t reliability, z_congestion_control_t cong_ctrl) { int8_t ret = _Z_RES_OK; - _Z_DEBUG(">> send network message\n"); + _Z_DEBUG(">> send network message"); _z_transport_unicast_t *ztu = &zn->_tp._transport._unicast; @@ -91,7 +91,7 @@ int8_t _z_unicast_send_n_msg(_z_session_t *zn, const _z_network_message_t *n_msg #if Z_FEATURE_MULTI_THREAD == 1 int8_t locked = _z_mutex_trylock(&ztu->_mutex_tx); if (locked != (int8_t)0) { - _Z_INFO("Dropping zenoh message because of congestion control\n"); + _Z_INFO("Dropping zenoh message because of congestion control"); // We failed to acquire the lock, drop the message drop = true; } From 2313ad1cf15e3e2143b581e84d76a1068f654429 Mon Sep 17 00:00:00 2001 From: Jean-Roland Date: Wed, 27 Dec 2023 16:47:57 +0100 Subject: [PATCH 3/3] fix: clang format --- src/protocol/codec/ext.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/protocol/codec/ext.c b/src/protocol/codec/ext.c index 5e52f64a4..503a887f7 100644 --- a/src/protocol/codec/ext.c +++ b/src/protocol/codec/ext.c @@ -171,8 +171,7 @@ int8_t _z_msg_ext_unknown_error(_z_msg_ext_t *extension, uint8_t trace_id) { #if (ZENOH_DEBUG >= 1) switch (_Z_EXT_ENC(extension->_header)) { case _Z_MSG_EXT_ENC_UNIT: { - _Z_ERROR("Unknown mandatory extension found (extension_id: %02x, trace_id: %02x), UNIT", ext_id, - trace_id); + _Z_ERROR("Unknown mandatory extension found (extension_id: %02x, trace_id: %02x), UNIT", ext_id, trace_id); break; } case _Z_MSG_EXT_ENC_ZINT: { @@ -192,8 +191,8 @@ int8_t _z_msg_ext_unknown_error(_z_msg_ext_t *extension, uint8_t trace_id) { break; } default: { - _Z_ERROR("Unknown mandatory extension found (extension_id: %02x, trace_id: %02x), UNKOWN_ENCODING", - ext_id, trace_id); + _Z_ERROR("Unknown mandatory extension found (extension_id: %02x, trace_id: %02x), UNKOWN_ENCODING", ext_id, + trace_id); } } #endif