T398: Source cleanup for tool chain integration
This is a code cleanup to improve portability.
Specific issues addressed:
- Added type casts to (void *) here and there
- Changed non-standard \e escapes to \033
- Added cmake function to handle preinclude
- Changed a few Image$$ references to make use of the REGION_DECLARE
macro
- Reordered code slightly to avoid the need for a "void *rangeptr"
variable
- Changed compile time check typedef "err_msg" to avoid declaring
zero sized array, which is not standards compliant. It will now
either be -1 (error) or 1 (ok), not -1 and 0
- Reordered the *nfsptr_t typedef to make the cmse_nonsecure_call
standards compliant
- Added null tests to both secure and non_secure suites to avoid
defining zero length array. Also use this to find end of list
- Only define __stdout for ARMCLANG builds and conditionalize ns printf
output for ARMCLANG/GCC/IAR
- Cleaned up some enum type mismatches
- Changed non standard EINVAL error return to -1. The value was only
checked against 0 anyway
- Added type cast for conversion from float to int
Have tested with IAR, which starts and runs the idle thread. Changes
related to this is not included in this commit.
Author: Thomas Tornblom <thomas.tornblom@iar.com>
Signed-off-by: Thomas Tornblom <thomas.tornblom@iar.com>
Note: Sign off authority needs to adhere to the [DCO](./dco.txt)
rules.
Change-Id: I3e5229c0777623b128474af0311020ccacc1b797
diff --git a/lib/ext/qcbor/src/qcbor_decode.c b/lib/ext/qcbor/src/qcbor_decode.c
index 8e485ab..fa89b09 100644
--- a/lib/ext/qcbor/src/qcbor_decode.c
+++ b/lib/ext/qcbor/src/qcbor_decode.c
@@ -660,7 +660,7 @@
/*
The epoch formatted date. Turns lots of different forms of encoding date into uniform one
*/
-static int DecodeDateEpoch(QCBORItem *pDecodedItem)
+static QCBORError DecodeDateEpoch(QCBORItem *pDecodedItem)
{
// Stack usage: 1
QCBORError nReturn = QCBOR_SUCCESS;
@@ -688,7 +688,7 @@
nReturn = QCBOR_ERR_DATE_OVERFLOW;
goto Done;
}
- pDecodedItem->val.epochDate.nSeconds = d; // Float to integer conversion happening here.
+ pDecodedItem->val.epochDate.nSeconds = (int64_t) d; // Float to integer conversion happening here.
pDecodedItem->val.epochDate.fSecondsFraction = d - pDecodedItem->val.epochDate.nSeconds;
}
break;
@@ -1199,7 +1199,7 @@
*/
QCBORError QCBORDecode_Finish(QCBORDecodeContext *me)
{
- int nReturn = QCBOR_SUCCESS;
+ QCBORError nReturn = QCBOR_SUCCESS;
// Error out if all the maps/arrays are not closed out
if(DecodeNesting_IsNested(&(me->nesting))) {
diff --git a/lib/ext/qcbor/src/qcbor_encode.c b/lib/ext/qcbor/src/qcbor_encode.c
index c652f79..1155cda 100644
--- a/lib/ext/qcbor/src/qcbor_encode.c
+++ b/lib/ext/qcbor/src/qcbor_encode.c
@@ -576,7 +576,7 @@
*/
QCBORError QCBOREncode_Finish(QCBOREncodeContext *me, UsefulBufC *pEncodedCBOR)
{
- QCBORError uReturn = me->uError;
+ QCBORError uReturn = (QCBORError) me->uError;
if(uReturn != QCBOR_SUCCESS) {
goto Done;
diff --git a/lib/ext/qcbor/test/float_tests.c b/lib/ext/qcbor/test/float_tests.c
index eaf75aa..4f12ca6 100644
--- a/lib/ext/qcbor/test/float_tests.c
+++ b/lib/ext/qcbor/test/float_tests.c
@@ -73,7 +73,7 @@
UsefulBufC HalfPrecision = UsefulBuf_FROM_BYTE_ARRAY_LITERAL(spExpectedHalf);
QCBORDecodeContext DC;
- QCBORDecode_Init(&DC, HalfPrecision, 0);
+ QCBORDecode_Init(&DC, HalfPrecision, QCBOR_DECODE_MODE_NORMAL);
QCBORItem Item;
@@ -194,7 +194,7 @@
// Now parse the hand-constructed CBOR. This will invoke the conversion to a float
QCBORDecodeContext DC;
- QCBORDecode_Init(&DC, UsefulOutBuf_OutUBuf(&UOB), 0);
+ QCBORDecode_Init(&DC, UsefulOutBuf_OutUBuf(&UOB), QCBOR_DECODE_MODE_NORMAL);
QCBORItem Item;
diff --git a/lib/ext/qcbor/util/qcbor_util.c b/lib/ext/qcbor/util/qcbor_util.c
index bcace0a..22c8eae 100644
--- a/lib/ext/qcbor/util/qcbor_util.c
+++ b/lib/ext/qcbor/util/qcbor_util.c
@@ -232,7 +232,7 @@
goto Done;
}
- QCBORDecode_Init(&decode_context, payload, 0);
+ QCBORDecode_Init(&decode_context, payload, QCBOR_DECODE_MODE_NORMAL);
return_value = qcbor_util_get_item_in_map(&decode_context,
label,
diff --git a/lib/t_cose/src/t_cose_sign1_verify.c b/lib/t_cose/src/t_cose_sign1_verify.c
index 29b6c10..27cb419 100644
--- a/lib/t_cose/src/t_cose_sign1_verify.c
+++ b/lib/t_cose/src/t_cose_sign1_verify.c
@@ -92,7 +92,7 @@
QCBORDecodeContext decode_context;
QCBORItem item;
- QCBORDecode_Init(&decode_context, protected_headers, 0);
+ QCBORDecode_Init(&decode_context, protected_headers, QCBOR_DECODE_MODE_NORMAL);
if(qcbor_util_get_item_in_map(&decode_context,
COSE_HEADER_PARAM_ALG,