Skip to content

Upgrade to zcbor 0.6.0 #51219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions doc/releases/release-notes-3.3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,10 @@ Libraries / Subsystems
enabled and the command is sent on the same UART as the logging system, in
which a filesystem error was emitted.

* LwM2M

* The ``lwm2m_senml_cbor_*`` files have been regenerated using zcbor 0.6.0.

HALs
****

Expand All @@ -261,6 +265,19 @@ MCUboot
Trusted Firmware-M
******************

zcbor
*****

Upgraded zcbor to 0.6.0. Among other things, this brings in a few convenient
changes for Zephyr:

* In the zcbor codebase, the ``ARRAY_SIZE`` macro has been renamed to
``ZCBOR_ARRAY_SIZE`` to not collide with Zephyr's :c:macro:`ARRAY_SIZE` macro.
* The zcbor codebase now better supports being used in C++ code.

The entire release notes can be found at
https://github.com/zephyrproject-rtos/zcbor/blob/0.6.0/RELEASE_NOTES.md

Documentation
*************

Expand Down
150 changes: 90 additions & 60 deletions subsys/net/lib/lwm2m/lwm2m_senml_cbor.patch

Large diffs are not rendered by default.

90 changes: 61 additions & 29 deletions subsys/net/lib/lwm2m/lwm2m_senml_cbor_decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Generated using zcbor version 0.5.1
* Generated using zcbor version 0.6.0
* https://github.com/zephyrproject-rtos/zcbor
* Generated with a --default-max-qty of 99
*/
Expand All @@ -18,7 +18,9 @@
#include "lwm2m_senml_cbor_decode.h"

static bool decode_repeated_record_bn(zcbor_state_t *state, struct record_bn *result);
static bool decode_repeated_record_bt(zcbor_state_t *state, struct record_bt *result);
static bool decode_repeated_record_n(zcbor_state_t *state, struct record_n *result);
static bool decode_repeated_record_t(zcbor_state_t *state, struct record_t *result);
static bool decode_repeated_record_union(zcbor_state_t *state, struct record_union_ *result);
static bool decode_value(zcbor_state_t *state, struct value_ *result);
static bool decode_key_value_pair(zcbor_state_t *state, struct key_value_pair *result);
Expand All @@ -34,9 +36,24 @@ static bool decode_repeated_record_bn(zcbor_state_t *state, struct record_bn *re
bool tmp_result = ((((zcbor_int32_expect(state, (-2)))) &&
(zcbor_tstr_decode(state, (&(*result)._record_bn)))));

if (!tmp_result) {
if (!tmp_result)
zcbor_trace();

return tmp_result;
}

static bool decode_repeated_record_bt(zcbor_state_t *state, struct record_bt *result)
{
zcbor_print("%s\r\n", __func__);

bool tmp_result = ((((zcbor_int32_expect(state, (-3)))) &&
(zcbor_int64_decode(state, (&(*result)._record_bt))) &&
((((*result)._record_bt >= INT64_MIN) &&
((*result)._record_bt <= INT64_MAX)) ||
(zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))));

if (!tmp_result)
zcbor_trace();
}

return tmp_result;
}
Expand All @@ -48,9 +65,24 @@ static bool decode_repeated_record_n(zcbor_state_t *state, struct record_n *resu
bool tmp_result = ((((zcbor_uint32_expect(state, (0)))) &&
(zcbor_tstr_decode(state, (&(*result)._record_n)))));

if (!tmp_result) {
if (!tmp_result)
zcbor_trace();

return tmp_result;
}

static bool decode_repeated_record_t(zcbor_state_t *state, struct record_t *result)
{
zcbor_print("%s\r\n", __func__);

bool tmp_result = ((((zcbor_uint32_expect(state, (6)))) &&
(zcbor_int64_decode(state, (&(*result)._record_t))) &&
((((*result)._record_t >= INT64_MIN) &&
((*result)._record_t <= INT64_MAX)) ||
(zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))));

if (!tmp_result)
zcbor_trace();
}

return tmp_result;
}
Expand All @@ -66,24 +98,23 @@ static bool decode_repeated_record_union(zcbor_state_t *state, struct record_uni
((((*result)._union_vi >= INT64_MIN) &&
((*result)._union_vi <= INT64_MAX)) ||
(zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))) &&
(((*result)._record_union_choice = _union_vi) || 1)) ||
(((*result)._record_union_choice = _union_vi), true)) ||
((((zcbor_uint32_expect_union(state, (2)))) &&
(zcbor_float_decode(state, (&(*result)._union_vf)))) &&
(((*result)._record_union_choice = _union_vf) || 1)) ||
(((*result)._record_union_choice = _union_vf), true)) ||
((((zcbor_uint32_expect_union(state, (3)))) &&
(zcbor_tstr_decode(state, (&(*result)._union_vs)))) &&
(((*result)._record_union_choice = _union_vs) || 1)) ||
(((*result)._record_union_choice = _union_vs), true)) ||
((((zcbor_uint32_expect_union(state, (4)))) &&
(zcbor_bool_decode(state, (&(*result)._union_vb)))) &&
(((*result)._record_union_choice = _union_vb) || 1)) ||
(((*result)._record_union_choice = _union_vb), true)) ||
((((zcbor_uint32_expect_union(state, (8)))) &&
(zcbor_bstr_decode(state, (&(*result)._union_vd)))) &&
(((*result)._record_union_choice = _union_vd) || 1))),
(((*result)._record_union_choice = _union_vd), true))),
zcbor_union_end_code(state), int_res))));

if (!tmp_result) {
if (!tmp_result)
zcbor_trace();
}

return tmp_result;
}
Expand All @@ -96,23 +127,22 @@ static bool decode_value(zcbor_state_t *state, struct value_ *result)
bool tmp_result =
(((zcbor_union_start_code(state) &&
(int_res = ((((zcbor_tstr_decode(state, (&(*result)._value_tstr)))) &&
(((*result)._value_choice = _value_tstr) || 1)) ||
(((*result)._value_choice = _value_tstr), true)) ||
(((zcbor_bstr_decode(state, (&(*result)._value_bstr)))) &&
(((*result)._value_choice = _value_bstr) || 1)) ||
(((*result)._value_choice = _value_bstr), true)) ||
(((zcbor_int64_decode(state, (&(*result)._value_int))) &&
((((*result)._value_int >= INT64_MIN) &&
((*result)._value_int <= INT64_MAX)) ||
(zcbor_error(state, ZCBOR_ERR_WRONG_RANGE), false))) &&
(((*result)._value_choice = _value_int) || 1)) ||
(((*result)._value_choice = _value_int), true)) ||
(((zcbor_float_decode(state, (&(*result)._value_float)))) &&
(((*result)._value_choice = _value_float) || 1)) ||
(((*result)._value_choice = _value_float), true)) ||
(((zcbor_bool_decode(state, (&(*result)._value_bool)))) &&
(((*result)._value_choice = _value_bool) || 1))),
(((*result)._value_choice = _value_bool), true))),
zcbor_union_end_code(state), int_res))));

if (!tmp_result) {
if (!tmp_result)
zcbor_trace();
}

return tmp_result;
}
Expand All @@ -124,9 +154,8 @@ static bool decode_key_value_pair(zcbor_state_t *state, struct key_value_pair *r
bool tmp_result = ((((zcbor_int32_decode(state, (&(*result)._key_value_pair_key)))) &&
(decode_value(state, (&(*result)._key_value_pair)))));

if (!tmp_result) {
if (!tmp_result)
zcbor_trace();
}

return tmp_result;
}
Expand All @@ -138,9 +167,8 @@ static bool decode_repeated_record__key_value_pair(zcbor_state_t *state,

bool tmp_result = (((decode_key_value_pair(state, (&(*result)._record__key_value_pair)))));

if (!tmp_result) {
if (!tmp_result)
zcbor_trace();
}

return tmp_result;
}
Expand All @@ -154,23 +182,28 @@ static bool decode_record(zcbor_state_t *state, struct record *result)
((zcbor_present_decode(&((*result)._record_bn_present),
(zcbor_decoder_t *)decode_repeated_record_bn, state,
(&(*result)._record_bn)) &&
zcbor_present_decode(&((*result)._record_bt_present),
(zcbor_decoder_t *)decode_repeated_record_bt, state,
(&(*result)._record_bt)) &&
zcbor_present_decode(&((*result)._record_n_present),
(zcbor_decoder_t *)decode_repeated_record_n, state,
(&(*result)._record_n)) &&
zcbor_present_decode(&((*result)._record_t_present),
(zcbor_decoder_t *)decode_repeated_record_t, state,
(&(*result)._record_t)) &&
zcbor_present_decode(&((*result)._record_union_present),
(zcbor_decoder_t *)decode_repeated_record_union, state,
(&(*result)._record_union)) &&
zcbor_multi_decode(0, ARRAY_SIZE(result->_record__key_value_pair),
zcbor_multi_decode(0, ZCBOR_ARRAY_SIZE(result->_record__key_value_pair),
&(*result)._record__key_value_pair_count,
(zcbor_decoder_t *)decode_repeated_record__key_value_pair,
state, (&(*result)._record__key_value_pair),
sizeof(struct record__key_value_pair))) ||
(zcbor_list_map_end_force_decode(state), false)) &&
zcbor_map_end_decode(state))));

if (!tmp_result) {
if (!tmp_result)
zcbor_trace();
}

return tmp_result;
}
Expand All @@ -181,16 +214,15 @@ static bool decode_lwm2m_senml(zcbor_state_t *state, struct lwm2m_senml *result)

bool tmp_result = ((
(zcbor_list_start_decode(state) &&
((zcbor_multi_decode(1, ARRAY_SIZE(result->_lwm2m_senml__record),
((zcbor_multi_decode(1, ZCBOR_ARRAY_SIZE(result->_lwm2m_senml__record),
&(*result)._lwm2m_senml__record_count,
(zcbor_decoder_t *)decode_record, state,
(&(*result)._lwm2m_senml__record), sizeof(struct record))) ||
(zcbor_list_map_end_force_decode(state), false)) &&
zcbor_list_end_decode(state))));

if (!tmp_result) {
if (!tmp_result)
zcbor_trace();
}

return tmp_result;
}
Expand Down
2 changes: 1 addition & 1 deletion subsys/net/lib/lwm2m/lwm2m_senml_cbor_decode.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Generated using zcbor version 0.5.1
* Generated using zcbor version 0.6.0
* https://github.com/zephyrproject-rtos/zcbor
* Generated with a --default-max-qty of 99
*/
Expand Down
Loading