Skip to content

Commit

Permalink
warning fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisBiryukov91 committed Jun 24, 2024
1 parent 99abc68 commit 61afacc
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 26 deletions.
4 changes: 2 additions & 2 deletions include/zenoh-pico/collections/arc_slice.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include "zenoh-pico/system/platform-common.h"


_Z_REFCOUNT_DEFINE(_z_slice, _z_slice);
_Z_REFCOUNT_DEFINE(_z_slice, _z_slice)

/*-------- ArcSlice --------*/
/**
Expand Down Expand Up @@ -53,4 +53,4 @@ int8_t _z_arc_slice_copy(_z_arc_slice_t *dst, const _z_arc_slice_t *src);
int8_t _z_arc_slice_move(_z_arc_slice_t *dst, _z_arc_slice_t *src);
int8_t _z_arc_slice_drop(_z_arc_slice_t *s);

#endif /* ZENOH_PICO_COLLECTIONS_ARC_SLICE_H */
#endif /* ZENOH_PICO_COLLECTIONS_ARC_SLICE_H */
4 changes: 2 additions & 2 deletions include/zenoh-pico/collections/bytes.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

inline size_t _z_arc_slice_size(const _z_arc_slice_t *s) {
(void)s;
return sizeof(_z_arc_slice_size);
return sizeof(_z_arc_slice_t);
}
static inline void _z_arc_slice_elem_move(void *dst, void *src) {
_z_arc_slice_move((_z_arc_slice_t *)dst, (_z_arc_slice_t*)src);
Expand Down Expand Up @@ -95,4 +95,4 @@ int8_t _zz_bytes_reader_read_slices(_zz_bytes_reader_t* reader, size_t len, _zz_
int8_t _zz_bytes_reader_read(_zz_bytes_reader_t *reader, uint8_t* buf, size_t len);
int8_t _zz_bytes_reader_read_next(_zz_bytes_reader_t* reader, _zz_bytes_t* out);

#endif /* ZENOH_PICO_COLLECTIONS_BYTES_H */
#endif /* ZENOH_PICO_COLLECTIONS_BYTES_H */
2 changes: 1 addition & 1 deletion src/collections/arc_slice.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,4 @@ int8_t _z_arc_slice_drop(_z_arc_slice_t *s) {
s->len = 0;
s->start = 0;
return _Z_RES_OK;
}
}
3 changes: 1 addition & 2 deletions src/collections/bytes.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,6 @@ int8_t _zz_bytes_reader_read_next(_zz_bytes_reader_t* reader, _zz_bytes_t* out)
if (_zz_bytes_reader_read_zint(reader, &len) != _Z_RES_OK) {
return _Z_ERR_DID_NOT_READ;
}
size_t offset = _zz_bytes_reader_tell(reader);

return _zz_bytes_reader_read_slices(reader, len, out);
}
}
20 changes: 10 additions & 10 deletions src/collections/vec.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ void __z_svec_copy_inner(void *dst, const void *src, z_element_copy_f copy, size
} else {
size_t offset = 0;
for (size_t i = 0; i < num_elements; i++) {
copy(dst + offset, src + offset);
copy((uint8_t*)dst + offset, (uint8_t*)src + offset);
offset += element_size;
}
}
Expand All @@ -160,7 +160,7 @@ void __z_svec_move_inner(void *dst, void *src, z_element_move_f move, size_t num
} else {
size_t offset = 0;
for (size_t i = 0; i < num_elements; i++) {
move(dst + offset, src + offset);
move((uint8_t*)dst + offset, (uint8_t*)src + offset);
offset += element_size;
}
}
Expand All @@ -181,7 +181,7 @@ void _z_svec_reset(_z_svec_t *v, z_element_clear_f clear, size_t element_size) {
if (clear != NULL) {
size_t offset = 0;
for (size_t i = 0; i < v->_len; i++) {
clear(v->_val + offset);
clear((uint8_t*)v->_val + offset);
offset += element_size;
}
}
Expand Down Expand Up @@ -229,34 +229,34 @@ bool _z_svec_append(_z_svec_t *v, const void *e, z_element_move_f move, size_t e
// Update the current vector
v->_val = _val;
v->_capacity = _capacity;
memcpy(v->_val + v->_len * element_size, e, element_size);
memcpy((uint8_t*)v->_val + v->_len * element_size, e, element_size);
v->_len++;
} else {
return false;
}
} else {
memcpy(v->_val + v->_len * element_size, e, element_size);
memcpy((uint8_t*)v->_val + v->_len * element_size, e, element_size);
v->_len++;
}
return true;
}

void *_z_svec_get(const _z_svec_t *v, size_t i, size_t element_size) {
assert(i < v->_len);
return v->_val + i * element_size;
return (uint8_t*)v->_val + i * element_size;
}

void _z_svec_set(_z_svec_t *v, size_t i, void *e, z_element_clear_f clear, size_t element_size) {
assert(i < v->_len);
clear(v->_val + i * element_size);
memcpy(v->_val + i * element_size, e, element_size);
clear((uint8_t*)v->_val + i * element_size);
memcpy((uint8_t*)v->_val + i * element_size, e, element_size);
}

void _z_svec_remove(_z_svec_t *v, size_t pos, z_element_clear_f clear, z_element_move_f move, size_t element_size) {
assert(pos < v->_len);
clear(v->_val + pos * element_size);
clear((uint8_t*)v->_val + pos * element_size);
__z_svec_move_inner(
v->_val + pos * element_size, v->_val + (pos + 1) * element_size,
(uint8_t*)v->_val + pos * element_size, (uint8_t*)v->_val + (pos + 1) * element_size,
move, (v->_len - pos - 1) * element_size, element_size
);

Expand Down
17 changes: 8 additions & 9 deletions tests/z_bytes_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#undef NDEBUG
#include <assert.h>

void test_null_bytes() {
void test_null_bytes(void) {
_zz_bytes_t b = _zz_bytes_null();
assert(_zz_bytes_len(&b) == 0);
assert(_zz_bytes_is_empty(&b));
Expand All @@ -30,9 +30,9 @@ void test_null_bytes() {
_zz_bytes_drop(&b); // no crush
}

void test_slice() {
void test_slice(void) {
uint8_t data[5] = {1, 2, 3, 4, 5};
uint8_t data_out[5] = {};
uint8_t data_out[5] = {0};
_z_slice_t s = _z_slice_wrap_copy(data, 5);
_zz_bytes_t b = _zz_bytes_from_slice(s);

Expand All @@ -48,12 +48,12 @@ void test_slice() {
_zz_bytes_drop(&b);
}

void test_append() {
void test_append(void) {
uint8_t data1[5] = {1, 2, 3, 4, 5};
uint8_t data2[5] = {1, 2, 6, 7, 8};
uint8_t data3[3] = {3, 9, 10};
uint8_t data_in[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
uint8_t data_out[10] = {};
uint8_t data_out[10] = {0};
_z_arc_slice_t s1 = _z_arc_slice_wrap(_z_slice_wrap_copy(data1, 5), 0, 5);
_z_arc_slice_t s2 = _z_arc_slice_wrap(_z_slice_wrap_copy(data2, 5), 2, 3);
_z_arc_slice_t s3 = _z_arc_slice_wrap(_z_slice_wrap_copy(data3, 3), 1, 2);
Expand All @@ -78,12 +78,12 @@ void test_append() {
_zz_bytes_drop(&b);
}

void test_reader_read() {
void test_reader_read(void) {
uint8_t data1[5] = {1, 2, 3, 4, 5};
uint8_t data2[5] = {1, 2, 6, 7, 8};
uint8_t data3[3] = {3, 9, 10};
uint8_t data_in[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
uint8_t data_out[10] = {};
uint8_t data_out[10] = {0};
_z_arc_slice_t s1 = _z_arc_slice_wrap(_z_slice_wrap_copy(data1, 5), 0, 5);
_z_arc_slice_t s2 = _z_arc_slice_wrap(_z_slice_wrap_copy(data2, 5), 2, 3);
_z_arc_slice_t s3 = _z_arc_slice_wrap(_z_slice_wrap_copy(data3, 3), 1, 2);
Expand Down Expand Up @@ -113,7 +113,7 @@ void test_reader_read() {
_zz_bytes_drop(&b);
}

void test_reader_seek() {
void test_reader_seek(void) {
uint8_t data1[5] = {1, 2, 3, 4, 5};
uint8_t data2[5] = {1, 2, 6, 7, 8};
uint8_t data3[3] = {3, 9, 10};
Expand All @@ -129,7 +129,6 @@ void test_reader_seek() {

_zz_bytes_reader_t reader = _zz_bytes_get_reader(&b);

uint8_t out;
assert(_zz_bytes_reader_tell(&reader) == 0);
assert(_zz_bytes_reader_seek(&reader, 3, SEEK_CUR) == 0);
assert(_zz_bytes_reader_tell(&reader) == 3);
Expand Down

0 comments on commit 61afacc

Please sign in to comment.