golioth / golioth-zephyr-sdk

Golioth SDK For Zephyr
https://www.golioth.io
Apache License 2.0
68 stars 19 forks source link

net: golioth: fw: improve CBOR decoding error handling #154

Closed mniestroj closed 2 years ago

mniestroj commented 2 years ago

Call QCBORDecode_Finish() at the end of CBOR payload decoding, so that potential string allocators get destructed properly. Use that function to check for error codes instead of calling QCBORDecode_GetError().

Make sure to always call QCBORDecode_ExitMap() after QCBORDecode_EnterMap(), even though it is not strictly required by QCBOR implementation.

Make sure to always call QCBORDecode_ExitMap() after QCBORDecode_EnterMap(), even though it is not strictly required by QCBOR implementation.

Introduce a helper module, which will allow to convert from QCBOR error codes to POSIX error codes. This will be particularly useful in error handling paths in 'fw' and 'logging' modules.

Utilize introduced helper function to convert from QCBOR to POSIX error codes. This will give higher level application code a better knowledge about what went wrong underneath.

mniestroj commented 2 years ago

There is a false positive from checkpatch, because of QCBOR library coding style.