Skip to content

Commit

Permalink
cbor: align function naming with clib
Browse files Browse the repository at this point in the history
  • Loading branch information
bkleiner committed Oct 22, 2023
1 parent 9015ed7 commit 4b0ebb9
Show file tree
Hide file tree
Showing 17 changed files with 215 additions and 215 deletions.
24 changes: 12 additions & 12 deletions lib/cbor/include/cbor.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ uint32_t cbor_decode_array_size(cbor_value_t *dec, cbor_container_t *array);
cbor_result_t cbor_decode_map(cbor_value_t *dec, cbor_container_t *map);
uint32_t cbor_decode_map_size(cbor_value_t *dec, cbor_container_t *map);

cbor_result_t cbor_decode_uint8(cbor_value_t *dec, uint8_t *val);
cbor_result_t cbor_decode_uint16(cbor_value_t *dec, uint16_t *val);
cbor_result_t cbor_decode_uint32(cbor_value_t *dec, uint32_t *val);
cbor_result_t cbor_decode_uint8_t(cbor_value_t *dec, uint8_t *val);
cbor_result_t cbor_decode_uint16_t(cbor_value_t *dec, uint16_t *val);
cbor_result_t cbor_decode_uint32_t(cbor_value_t *dec, uint32_t *val);

cbor_result_t cbor_decode_int8(cbor_value_t *dec, int8_t *val);
cbor_result_t cbor_decode_int16(cbor_value_t *dec, int16_t *val);
cbor_result_t cbor_decode_int32(cbor_value_t *dec, int32_t *val);
cbor_result_t cbor_decode_int8_t(cbor_value_t *dec, int8_t *val);
cbor_result_t cbor_decode_int16_t(cbor_value_t *dec, int16_t *val);
cbor_result_t cbor_decode_int32_t(cbor_value_t *dec, int32_t *val);

cbor_result_t cbor_decode_float(cbor_value_t *dec, float *val);

Expand All @@ -80,13 +80,13 @@ cbor_result_t cbor_encode_array_indefinite(cbor_value_t *enc);
cbor_result_t cbor_encode_map_indefinite(cbor_value_t *enc);
cbor_result_t cbor_encode_end_indefinite(cbor_value_t *enc);

cbor_result_t cbor_encode_uint8(cbor_value_t *enc, const uint8_t *val);
cbor_result_t cbor_encode_uint16(cbor_value_t *enc, const uint16_t *val);
cbor_result_t cbor_encode_uint32(cbor_value_t *enc, const uint32_t *val);
cbor_result_t cbor_encode_uint8_t(cbor_value_t *enc, const uint8_t *val);
cbor_result_t cbor_encode_uint16_t(cbor_value_t *enc, const uint16_t *val);
cbor_result_t cbor_encode_uint32_t(cbor_value_t *enc, const uint32_t *val);

cbor_result_t cbor_encode_int8(cbor_value_t *enc, const int8_t *val);
cbor_result_t cbor_encode_int16(cbor_value_t *enc, const int16_t *val);
cbor_result_t cbor_encode_int32(cbor_value_t *enc, const int32_t *val);
cbor_result_t cbor_encode_int8_t(cbor_value_t *enc, const int8_t *val);
cbor_result_t cbor_encode_int16_t(cbor_value_t *enc, const int16_t *val);
cbor_result_t cbor_encode_int32_t(cbor_value_t *enc, const int32_t *val);

cbor_result_t cbor_encode_float(cbor_value_t *enc, const float *val);

Expand Down
28 changes: 14 additions & 14 deletions lib/cbor/src/cbor.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,29 +280,29 @@ uint32_t cbor_decode_map_size(cbor_value_t *dec, cbor_container_t *map) {
return UINT32_MAX;
}

cbor_result_t cbor_decode_uint8(cbor_value_t *dec, uint8_t *val) {
cbor_result_t cbor_decode_uint8_t(cbor_value_t *dec, uint8_t *val) {
cbor_result_t type = _cbor_decode_ensure_type(dec, CBOR_TYPE_UINT);
if (type < 0) {
return type;
}
return _cbor_advance(dec, _cbor_decode_raw(dec, (uint8_t *)val, CBOR_SIZE_BYTE));
}
cbor_result_t cbor_decode_uint16(cbor_value_t *dec, uint16_t *val) {
cbor_result_t cbor_decode_uint16_t(cbor_value_t *dec, uint16_t *val) {
cbor_result_t type = _cbor_decode_ensure_type(dec, CBOR_TYPE_UINT);
if (type < 0) {
return type;
}
return _cbor_advance(dec, _cbor_decode_raw(dec, (uint8_t *)val, CBOR_SIZE_SHORT));
}
cbor_result_t cbor_decode_uint32(cbor_value_t *dec, uint32_t *val) {
cbor_result_t cbor_decode_uint32_t(cbor_value_t *dec, uint32_t *val) {
cbor_result_t type = _cbor_decode_ensure_type(dec, CBOR_TYPE_UINT);
if (type < 0) {
return type;
}
return _cbor_advance(dec, _cbor_decode_raw(dec, (uint8_t *)val, CBOR_SIZE_WORD));
}

cbor_result_t cbor_decode_int8(cbor_value_t *dec, int8_t *val) {
cbor_result_t cbor_decode_int8_t(cbor_value_t *dec, int8_t *val) {
if (_cbor_remaining(dec) <= 0) {
return CBOR_ERR_EOF;
}
Expand All @@ -322,7 +322,7 @@ cbor_result_t cbor_decode_int8(cbor_value_t *dec, int8_t *val) {
}
return res;
}
cbor_result_t cbor_decode_int16(cbor_value_t *dec, int16_t *val) {
cbor_result_t cbor_decode_int16_t(cbor_value_t *dec, int16_t *val) {
if (_cbor_remaining(dec) <= 0) {
return CBOR_ERR_EOF;
}
Expand All @@ -342,7 +342,7 @@ cbor_result_t cbor_decode_int16(cbor_value_t *dec, int16_t *val) {
}
return res;
}
cbor_result_t cbor_decode_int32(cbor_value_t *dec, int32_t *val) {
cbor_result_t cbor_decode_int32_t(cbor_value_t *dec, int32_t *val) {
if (_cbor_remaining(dec) <= 0) {
return CBOR_ERR_EOF;
}
Expand Down Expand Up @@ -404,7 +404,7 @@ cbor_result_t cbor_decode_float(cbor_value_t *dec, float *val) {
switch (type) {
case CBOR_TYPE_NINT: {
int32_t intval = 0;
cbor_result_t res = cbor_decode_int32(dec, &intval);
cbor_result_t res = cbor_decode_int32_t(dec, &intval);
if (res < CBOR_OK) {
return res;
}
Expand All @@ -414,7 +414,7 @@ cbor_result_t cbor_decode_float(cbor_value_t *dec, float *val) {

case CBOR_TYPE_UINT: {
uint32_t intval = 0;
cbor_result_t res = cbor_decode_uint32(dec, &intval);
cbor_result_t res = cbor_decode_uint32_t(dec, &intval);
if (res < CBOR_OK) {
return res;
}
Expand Down Expand Up @@ -522,31 +522,31 @@ cbor_result_t cbor_encode_end_indefinite(cbor_value_t *enc) {
return CBOR_OK;
}

cbor_result_t cbor_encode_uint8(cbor_value_t *enc, const uint8_t *val) {
cbor_result_t cbor_encode_uint8_t(cbor_value_t *enc, const uint8_t *val) {
return _cbor_encode_raw(enc, CBOR_TYPE_UINT, (const uint8_t *)val, _cbor_size_for_value(*val));
}
cbor_result_t cbor_encode_uint16(cbor_value_t *enc, const uint16_t *val) {
cbor_result_t cbor_encode_uint16_t(cbor_value_t *enc, const uint16_t *val) {
return _cbor_encode_raw(enc, CBOR_TYPE_UINT, (const uint8_t *)val, _cbor_size_for_value(*val));
}
cbor_result_t cbor_encode_uint32(cbor_value_t *enc, const uint32_t *val) {
cbor_result_t cbor_encode_uint32_t(cbor_value_t *enc, const uint32_t *val) {
return _cbor_encode_raw(enc, CBOR_TYPE_UINT, (const uint8_t *)val, _cbor_size_for_value(*val));
}

cbor_result_t cbor_encode_int8(cbor_value_t *enc, const int8_t *val) {
cbor_result_t cbor_encode_int8_t(cbor_value_t *enc, const int8_t *val) {
if (*val >= 0) {
return _cbor_encode_raw(enc, CBOR_TYPE_UINT, (const uint8_t *)val, _cbor_size_for_value(*val));
}
uint8_t proxy = (uint8_t)(-*val - 1);
return _cbor_encode_raw(enc, CBOR_TYPE_NINT, (const uint8_t *)&proxy, _cbor_size_for_value(proxy));
}
cbor_result_t cbor_encode_int16(cbor_value_t *enc, const int16_t *val) {
cbor_result_t cbor_encode_int16_t(cbor_value_t *enc, const int16_t *val) {
if (*val >= 0) {
return _cbor_encode_raw(enc, CBOR_TYPE_UINT, (const uint8_t *)val, _cbor_size_for_value(*val));
}
uint16_t proxy = (uint16_t)(-*val - 1);
return _cbor_encode_raw(enc, CBOR_TYPE_NINT, (const uint8_t *)&proxy, _cbor_size_for_value(proxy));
}
cbor_result_t cbor_encode_int32(cbor_value_t *enc, const int32_t *val) {
cbor_result_t cbor_encode_int32_t(cbor_value_t *enc, const int32_t *val) {
if (*val >= 0) {
return _cbor_encode_raw(enc, CBOR_TYPE_UINT, (const uint8_t *)val, _cbor_size_for_value(*val));
}
Expand Down
20 changes: 10 additions & 10 deletions lib/cbor/test/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ cbor_result_t print_value(cbor_value_t *dec, cJSON *decoded) {
}
case CBOR_TYPE_UINT: {
uint32_t val = 0;
cbor_result_t res = cbor_decode_uint32(dec, &val);
cbor_result_t res = cbor_decode_uint32_t(dec, &val);
if (res < CBOR_OK) {
printf("CBOR uint error %d\n", res);
return res;
Expand All @@ -80,7 +80,7 @@ cbor_result_t print_value(cbor_value_t *dec, cJSON *decoded) {
}
case CBOR_TYPE_NINT: {
int32_t val = 0;
cbor_result_t res = cbor_decode_int32(dec, &val);
cbor_result_t res = cbor_decode_int32_t(dec, &val);
if (res < CBOR_OK) {
printf("CBOR int error %d\n", res);
return res;
Expand Down Expand Up @@ -199,7 +199,7 @@ int main(int argc, char const *argv[]) {
cbor_value_t enc;
{
cbor_encoder_init(&enc, buf, 512);
cbor_encode_uint16(&enc, 1337);
cbor_encode_uint16_t(&enc, 1337);
uint32_t len = cbor_encoder_len(&enc);

cbor_value_t dec;
Expand All @@ -208,7 +208,7 @@ int main(int argc, char const *argv[]) {
}
{
cbor_encoder_init(&enc, buf, 512);
cbor_encode_int16(&enc, -1337);
cbor_encode_int16_t(&enc, -1337);
uint32_t len = cbor_encoder_len(&enc);

cbor_value_t dec;
Expand Down Expand Up @@ -237,8 +237,8 @@ int main(int argc, char const *argv[]) {
cbor_encoder_init(&enc, buf, 512);

cbor_encode_array(&enc, 3);
cbor_encode_uint16(&enc, 1337);
cbor_encode_int16(&enc, -1337);
cbor_encode_uint16_t(&enc, 1337);
cbor_encode_int16_t(&enc, -1337);
cbor_encode_float(&enc, -13.37f);
uint32_t len = cbor_encoder_len(&enc);

Expand All @@ -251,9 +251,9 @@ int main(int argc, char const *argv[]) {

cbor_encode_map(&enc, 3);
cbor_encode_tstr(&enc, (uint8_t *)"KEY1", 4);
cbor_encode_uint16(&enc, 1337);
cbor_encode_uint16_t(&enc, 1337);
cbor_encode_tstr(&enc, (uint8_t *)"KEY2", 4);
cbor_encode_int16(&enc, -1337);
cbor_encode_int16_t(&enc, -1337);
cbor_encode_tstr(&enc, (uint8_t *)"KEY3", 4);
cbor_encode_float(&enc, -13.37f);
uint32_t len = cbor_encoder_len(&enc);
Expand All @@ -267,9 +267,9 @@ int main(int argc, char const *argv[]) {

cbor_encode_map_indefinite(&enc);
cbor_encode_tstr(&enc, (uint8_t *)"KEY1", 4);
cbor_encode_uint16(&enc, 1337);
cbor_encode_uint16_t(&enc, 1337);
cbor_encode_tstr(&enc, (uint8_t *)"KEY2", 4);
cbor_encode_int16(&enc, -1337);
cbor_encode_int16_t(&enc, -1337);
cbor_encode_tstr(&enc, (uint8_t *)"KEY3", 4);
cbor_encode_float(&enc, -13.37f);
cbor_encode_end_indefinite(&enc);
Expand Down
2 changes: 1 addition & 1 deletion src/core/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void perf_counter_update() {
#define ENCODE_CYCLES(val) \
{ \
const uint32_t us = (val) / (SYS_CLOCK_FREQ_HZ / 1000000); \
CBOR_CHECK_ERROR(res = cbor_encode_uint32(enc, &us)); \
CBOR_CHECK_ERROR(res = cbor_encode_uint32_t(enc, &us)); \
}

cbor_result_t cbor_encode_perf_counters(cbor_value_t *enc) {
Expand Down
4 changes: 2 additions & 2 deletions src/core/flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ flash_storage_t flash_storage;
rx_bind_storage_t bind_storage;

CBOR_START_STRUCT_ENCODER(rx_bind_storage_t)
CBOR_ENCODE_MEMBER(bind_saved, uint8)
CBOR_ENCODE_MEMBER(bind_saved, uint8_t)
CBOR_ENCODE_BSTR_MEMBER(raw, BIND_RAW_STORAGE_SIZE)
CBOR_END_STRUCT_ENCODER()

CBOR_START_STRUCT_DECODER(rx_bind_storage_t)
CBOR_DECODE_MEMBER(bind_saved, uint8)
CBOR_DECODE_MEMBER(bind_saved, uint8_t)
CBOR_DECODE_BSTR_MEMBER(raw, BIND_RAW_STORAGE_SIZE)
CBOR_END_STRUCT_DECODER()

Expand Down
6 changes: 3 additions & 3 deletions src/core/profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -548,13 +548,13 @@ cbor_result_t cbor_encode_profile_metadata_t(cbor_value_t *enc, const profile_me

const uint32_t version = PROFILE_VERSION;
CBOR_CHECK_ERROR(res = cbor_encode_str(enc, "version"));
CBOR_CHECK_ERROR(res = cbor_encode_uint32(enc, &version));
CBOR_CHECK_ERROR(res = cbor_encode_uint32_t(enc, &version));

CBOR_CHECK_ERROR(res = cbor_encode_str(enc, "name"));
CBOR_CHECK_ERROR(res = cbor_encode_tstr(enc, meta->name, 36));

CBOR_CHECK_ERROR(res = cbor_encode_str(enc, "datetime"));
CBOR_CHECK_ERROR(res = cbor_encode_uint32(enc, &meta->datetime));
CBOR_CHECK_ERROR(res = cbor_encode_uint32_t(enc, &meta->datetime));

CBOR_CHECK_ERROR(res = cbor_encode_end_indefinite(enc));
return res;
Expand Down Expand Up @@ -623,7 +623,7 @@ cbor_result_t cbor_decode_profile_metadata_t(cbor_value_t *dec, profile_metadata
}

if (buf_equal_string(name, name_len, "datetime")) {
CBOR_CHECK_ERROR(res = cbor_decode_uint32(dec, &meta->datetime));
CBOR_CHECK_ERROR(res = cbor_decode_uint32_t(dec, &meta->datetime));
continue;
}

Expand Down
Loading

0 comments on commit 4b0ebb9

Please sign in to comment.