Fix enum conversion warnings for LLVM/XCode 11 (#44)
* Fix enum conversion warnings for LLVM/XCode 11
* Add int conversion warning back in to optional CFLAGS
* type conversion and integer overflow fix when decoding maps as arrays
* add test for map that is too large to handle as an array
Co-authored-by: Laurence Lundblade <lgl@securitytheory.com>
diff --git a/src/qcbor_encode.c b/src/qcbor_encode.c
index be72cd5..b17698d 100644
--- a/src/qcbor_encode.c
+++ b/src/qcbor_encode.c
@@ -72,22 +72,20 @@
pNesting->pCurrentNesting->uMajorType = CBOR_MAJOR_TYPE_ARRAY;
}
-inline static QCBORError Nesting_Increase(QCBORTrackNesting *pNesting,
+inline static uint8_t Nesting_Increase(QCBORTrackNesting *pNesting,
uint8_t uMajorType,
uint32_t uPos)
{
- QCBORError nReturn = QCBOR_SUCCESS;
-
if(pNesting->pCurrentNesting == &pNesting->pArrays[QCBOR_MAX_ARRAY_NESTING]) {
// Trying to open one too many
- nReturn = QCBOR_ERR_ARRAY_NESTING_TOO_DEEP;
+ return QCBOR_ERR_ARRAY_NESTING_TOO_DEEP;
} else {
pNesting->pCurrentNesting++;
pNesting->pCurrentNesting->uCount = 0;
pNesting->pCurrentNesting->uStart = uPos;
pNesting->pCurrentNesting->uMajorType = uMajorType;
+ return QCBOR_SUCCESS;
}
- return nReturn;
}
inline static void Nesting_Decrease(QCBORTrackNesting *pNesting)
@@ -95,13 +93,13 @@
pNesting->pCurrentNesting--;
}
-inline static QCBORError Nesting_Increment(QCBORTrackNesting *pNesting)
+inline static uint8_t Nesting_Increment(QCBORTrackNesting *pNesting)
{
if(1 >= QCBOR_MAX_ITEMS_IN_ARRAY - pNesting->pCurrentNesting->uCount) {
return QCBOR_ERR_ARRAY_TOO_LONG;
}
- pNesting->pCurrentNesting->uCount += 1;
+ pNesting->pCurrentNesting->uCount++;
return QCBOR_SUCCESS;
}