diff --git a/include/zenoh-pico/net/reply.h b/include/zenoh-pico/net/reply.h index 3a47c9199..23aa1bce0 100644 --- a/include/zenoh-pico/net/reply.h +++ b/include/zenoh-pico/net/reply.h @@ -58,7 +58,9 @@ typedef struct _z_reply_data_t { } _z_reply_data_t; // Warning: None of the sub-types require a non-0 initialization. Add a init function if it changes. -static inline _z_reply_data_t _z_reply_data_null(void) { return (_z_reply_data_t){0}; } +static inline _z_reply_data_t _z_reply_data_init(void) { + return (_z_reply_data_t){.replier_id = {.id = {0}}, ._result.sample = _z_sample_null(), ._tag = _Z_REPLY_TAG_NONE}; +} void _z_reply_data_clear(_z_reply_data_t *rd); z_result_t _z_reply_data_copy(_z_reply_data_t *dst, const _z_reply_data_t *src); diff --git a/src/net/reply.c b/src/net/reply.c index 0efd92823..a331ae6cf 100644 --- a/src/net/reply.c +++ b/src/net/reply.c @@ -39,13 +39,13 @@ void _z_reply_data_free(_z_reply_data_t **reply_data) { } z_result_t _z_reply_data_copy(_z_reply_data_t *dst, const _z_reply_data_t *src) { - *dst = _z_reply_data_null(); - dst->_tag = src->_tag; + *dst = _z_reply_data_init(); if (src->_tag == _Z_REPLY_TAG_DATA) { _Z_RETURN_IF_ERR(_z_sample_copy(&dst->_result.sample, &src->_result.sample)); } else if (src->_tag == _Z_REPLY_TAG_ERROR) { _Z_RETURN_IF_ERR(_z_value_copy(&dst->_result.error, &src->_result.error)); } + dst->_tag = src->_tag; dst->replier_id = src->replier_id; return _Z_RES_OK; }