Skip to content

Commit

Permalink
Fix issues (#26)
Browse files Browse the repository at this point in the history
* fix: missed dedicated initializers

* fix: missing stop condition on wbuf_len
  • Loading branch information
jean-roland authored Dec 5, 2024
1 parent 08d1f57 commit 11548a1
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 26 deletions.
18 changes: 9 additions & 9 deletions include/zenoh-pico/net/query.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ static inline bool _z_queryable_check(const _z_queryable_t *queryable) { return
static inline _z_query_t _z_query_alias(_z_value_t *value, _z_keyexpr_t *key, const _z_slice_t *parameters,
_z_session_rc_t *zn, uint32_t request_id, const _z_bytes_t *attachment,
bool anyke) {
return (_z_query_t){
._key = _z_keyexpr_alias(*key),
._value = _z_value_alias(*value),
._request_id = request_id,
._zn = _z_session_rc_clone_as_weak(zn),
._attachment = _z_bytes_alias(*attachment),
._parameters = _z_string_alias_slice(parameters),
._anyke = anyke,
};
_z_query_t ret;
ret._key = _z_keyexpr_alias(*key);
ret._value = _z_value_alias(*value);
ret._request_id = request_id;
ret._zn = _z_session_rc_clone_as_weak(zn);
ret._attachment = _z_bytes_alias(*attachment);
ret._parameters = _z_string_alias_slice(parameters);
ret._anyke = anyke;
return ret;
}
void _z_queryable_clear(_z_queryable_t *qbl);
void _z_queryable_free(_z_queryable_t **qbl);
Expand Down
20 changes: 10 additions & 10 deletions include/zenoh-pico/net/sample.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,16 @@ static inline _z_sample_t _z_sample_alias(const _z_keyexpr_t *key, const _z_byte
const _z_timestamp_t *timestamp, const _z_encoding_t *encoding,
const z_sample_kind_t kind, const _z_qos_t qos, const _z_bytes_t *attachment,
z_reliability_t reliability) {
return (_z_sample_t){
.keyexpr = *key,
.payload = *payload,
.timestamp = *timestamp,
.encoding = *encoding,
.kind = kind,
.qos = qos,
.attachment = *attachment,
.reliability = reliability,
};
_z_sample_t ret;
ret.keyexpr = *key;
ret.payload = *payload;
ret.timestamp = *timestamp;
ret.encoding = *encoding;
ret.kind = kind;
ret.qos = qos;
ret.attachment = *attachment;
ret.reliability = reliability;
return ret;
}
void _z_sample_move(_z_sample_t *dst, _z_sample_t *src);

Expand Down
10 changes: 5 additions & 5 deletions include/zenoh-pico/protocol/keyexpr.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ bool _z_keyexpr_suffix_equals(const _z_keyexpr_t *left, const _z_keyexpr_t *righ
// Warning: None of the sub-types require a non-0 initialization. Add a init function if it changes.
static inline _z_keyexpr_t _z_keyexpr_null(void) { return (_z_keyexpr_t){0}; }
static inline _z_keyexpr_t _z_keyexpr_alias(const _z_keyexpr_t src) {
return (_z_keyexpr_t){
._id = src._id,
._mapping = src._mapping,
._suffix = _z_string_alias(src._suffix),
};
_z_keyexpr_t ret;
ret._id = src._id;
ret._mapping = src._mapping;
ret._suffix = _z_string_alias(src._suffix);
return ret;
}

_z_keyexpr_t _z_keyexpr_from_string(uint16_t rid, _z_string_t *str);
Expand Down
2 changes: 1 addition & 1 deletion src/protocol/iobuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ size_t _z_wbuf_capacity(const _z_wbuf_t *wbf) {

size_t _z_wbuf_len(const _z_wbuf_t *wbf) {
size_t len = 0;
for (size_t i = wbf->_r_idx; i <= wbf->_w_idx; i++) {
for (size_t i = wbf->_r_idx; (i < _z_wbuf_len_iosli(wbf)) && (i <= wbf->_w_idx); i++) {
_z_iosli_t *ios = _z_wbuf_get_iosli(wbf, i);
len = len + _z_iosli_readable(ios);
}
Expand Down
2 changes: 1 addition & 1 deletion src/transport/multicast/rx.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ z_result_t _z_multicast_handle_transport_message(_z_transport_multicast_t *ztm,
break;
}
}
if (!consecutive && _z_wbuf_len(dbuf) > 0) {
if (!consecutive && (_z_wbuf_len(dbuf) > 0)) {
_z_wbuf_clear(dbuf);
*dbuf_state = _Z_DBUF_STATE_NULL;
_Z_INFO("Defragmentation buffer dropped because non-consecutive fragments received");
Expand Down

0 comments on commit 11548a1

Please sign in to comment.