comment all #endif's
diff --git a/README.md b/README.md
index da5f58b..3a92dcc 100644
--- a/README.md
+++ b/README.md
@@ -231,8 +231,8 @@
| | smallest | largest |
|---------------|----------|---------|
| encode only | 850 | 2100 |
- | decode only | 2350 | 13500 |
- | combined | 3200 | 15600 |
+ | decode only | 2150 | 13500 |
+ | combined | 3000 | 15600 |
From the table above, one can see that the amount of code pulled in
from the QCBOR library varies a lot, ranging from 1KB to 15KB. The
diff --git a/inc/qcbor/qcbor_decode.h b/inc/qcbor/qcbor_decode.h
index 81636f0..01b44dc 100644
--- a/inc/qcbor/qcbor_decode.h
+++ b/inc/qcbor/qcbor_decode.h
@@ -348,7 +348,7 @@
UsefulBufC bigNum;
} Mantissa;
} expAndMantissa;
-#endif
+#endif /* QCBOR_CONFIG_DISABLE_EXP_AND_MANTISSA */
uint64_t uTagV; // Used internally during decoding
} val;
diff --git a/src/qcbor_decode.c b/src/qcbor_decode.c
index 6e41c52..5fd2158 100644
--- a/src/qcbor_decode.c
+++ b/src/qcbor_decode.c
@@ -39,7 +39,7 @@
#include <math.h> // For isnan(), llround(), llroudf(), round(), roundf(),
// pow(), exp2()
#include <fenv.h> // feclearexcept(), fetestexcept()
-#endif
+#endif /* QCBOR_DISABLE_FLOAT_HW_USE */
/*
@@ -168,8 +168,8 @@
// Is indefinite
return false;
}
-#endif
-
+#endif /* QCBOR_DISABLE_INDEFINITE_LENGTH_ARRAYS */
+
// All checks passed; is a definte length map or array
return true;
}
@@ -776,9 +776,9 @@
// was 16 bits. It was widened to 64 bits to be passed in here.
pDecodedItem->val.dfnum = IEEE754_HalfToDouble((uint16_t)uNumber);
pDecodedItem->uDataType = QCBOR_TYPE_DOUBLE;
-#else
+#else /* QCBOR_DISABLE_PREFERRED_FLOAT */
nReturn = QCBOR_ERR_HALF_PRECISION_DISABLED;
-#endif
+#endif /* QCBOR_DISABLE_PREFERRED_FLOAT */
break;
case SINGLE_PREC_FLOAT: // 26
// Single precision is normally returned as a double
@@ -795,7 +795,7 @@
// In the normal case, use HW to convert float to double.
pDecodedItem->val.dfnum = (double)f;
pDecodedItem->uDataType = QCBOR_TYPE_DOUBLE;
-#else
+#else /* QCBOR_DISABLE_FLOAT_HW_USE */
// Use of float HW is disabled, return as a float.
pDecodedItem->val.fnum = f;
pDecodedItem->uDataType = QCBOR_TYPE_FLOAT;
@@ -804,7 +804,7 @@
// as a double, but it adds object code and most likely
// anyone disabling FLOAT HW use doesn't care about
// floats and wants to save object code.
-#endif
+#endif /* QCBOR_DISABLE_FLOAT_HW_USE */
}
break;
@@ -1010,10 +1010,10 @@
if(nAdditionalInfo == LEN_IS_INDEFINITE) {
#ifndef QCBOR_DISABLE_INDEFINITE_LENGTH_ARRAYS
pDecodedItem->val.uCount = QCBOR_COUNT_INDICATES_INDEFINITE_LENGTH;
-#else
+#else /* QCBOR_DISABLE_INDEFINITE_LENGTH_ARRAYS */
nReturn = QCBOR_ERR_INDEF_LEN_ARRAYS_DISABLED;
break;
-#endif
+#endif /* QCBOR_DISABLE_INDEFINITE_LENGTH_ARRAYS */
} else {
// type conversion OK because of check above
pDecodedItem->val.uCount = (uint16_t)uNumber;
@@ -1492,7 +1492,7 @@
}
/* It was a break in an indefinite length map / array */
-#endif
+#endif /* QCBOR_DISABLE_INDEFINITE_LENGTH_ARRAYS */
}
@@ -4548,7 +4548,7 @@
return QCBOR_ERR_UNEXPECTED_TYPE;
}
break;
-#endif
+#endif /* QCBOR_CONFIG_DISABLE_EXP_AND_MANTISSA */
default:
return QCBOR_ERR_UNEXPECTED_TYPE;
}
@@ -4654,9 +4654,9 @@
return QCBOR_ERR_UNEXPECTED_TYPE;
}
}
-#else
+#else /* QCBOR_DISABLE_FLOAT_HW_USE */
return QCBOR_ERR_HW_FLOAT_DISABLED;
-#endif
+#endif /* QCBOR_DISABLE_FLOAT_HW_USE */
break;
case QCBOR_TYPE_DOUBLE:
diff --git a/src/qcbor_encode.c b/src/qcbor_encode.c
index e04e21b..c0ca257 100644
--- a/src/qcbor_encode.c
+++ b/src/qcbor_encode.c
@@ -467,7 +467,7 @@
if(pBufferEnd - pByte > 9 || pBufferEnd - pByte < 1 || pByte < (uint8_t *)buffer.ptr) {
return NULLUsefulBufC;
}
-#endif
+#endif /* EXTRA_ENCODE_HEAD_CHECK */
/* Length will not go negative because the loops run for at most 8 decrements
* of pByte, only one other decrement is made, and the array is sized
@@ -702,9 +702,9 @@
const IEEE754_union uNum = IEEE754_DoubleToSmallest(dNum);
QCBOREncode_AddType7(me, uNum.uSize, uNum.uValue);
-#else
+#else /* QCBOR_DISABLE_PREFERRED_FLOAT */
QCBOREncode_AddDoubleNoPreferred(me, dNum);
-#endif
+#endif /* QCBOR_DISABLE_PREFERRED_FLOAT */
}
@@ -728,9 +728,9 @@
const IEEE754_union uNum = IEEE754_FloatToSmallest(fNum);
QCBOREncode_AddType7(me, uNum.uSize, uNum.uValue);
-#else
+#else /* QCBOR_DISABLE_PREFERRED_FLOAT */
QCBOREncode_AddFloatNoPreferred(me, fNum);
-#endif
+#endif /* QCBOR_DISABLE_PREFERRED_FLOAT */
}
@@ -900,9 +900,9 @@
return;
}
}
-#else
+#else /* QCBOR_DISABLE_ENCODE_USAGE_GUARDS */
(void) uMajorType;
-#endif
+#endif /* QCBOR_DISABLE_ENCODE_USAGE_GUARDS */
/* Append the break marker (0xff for both arrays and maps) */
AppendCBORHead(me, CBOR_MAJOR_NONE_TYPE_SIMPLE_BREAK, CBOR_SIMPLE_BREAK, 0);
@@ -926,7 +926,7 @@
uReturn = QCBOR_ERR_ARRAY_OR_MAP_STILL_OPEN;
goto Done;
}
-#endif
+#endif /* QCBOR_DISABLE_ENCODE_USAGE_GUARDS */
*pEncodedCBOR = UsefulOutBuf_OutUBuf(&(me->OutBuf));
diff --git a/test/float_tests.c b/test/float_tests.c
index 3f8ec1a..12f34fd 100644
--- a/test/float_tests.c
+++ b/test/float_tests.c
@@ -1182,4 +1182,4 @@
return 0;
}
-#endif
+#endif /* NAN_EXPERIMENT */
diff --git a/test/not_well_formed_cbor.h b/test/not_well_formed_cbor.h
index 9d18d65..48a3656 100644
--- a/test/not_well_formed_cbor.h
+++ b/test/not_well_formed_cbor.h
@@ -170,7 +170,7 @@
#ifndef QCBOR_DISABLE_INDEFINITE_LENGTH_ARRAYS
// A bare break after a zero length indefinite length map
{(uint8_t[]){0x9f, 0xff, 0xff}, 3},
-#endif
+#endif /* QCBOR_DISABLE_INDEFINITE_LENGTH_ARRAYS */
// Forbidden two-byte encodings of simple types
diff --git a/test/qcbor_decode_tests.c b/test/qcbor_decode_tests.c
index 1854845..5e5b0d2 100644
--- a/test/qcbor_decode_tests.c
+++ b/test/qcbor_decode_tests.c
@@ -60,7 +60,7 @@
fflush(stdout);
}
-#endif
+#endif /* PRINT_FUNCTIONS_FOR_DEBUGGING */
static const uint8_t spExpectedEncodedInts[] = {
@@ -2369,9 +2369,9 @@
if(QCBORDecode_GetNext(&DCtx, &Item) != QCBOR_ERR_HALF_PRECISION_DISABLED) {
return -18;
}
-#endif
+#endif /* QCBOR_DISABLE_PREFERRED_FLOAT */
-#else
+#else /* QCBOR_DISABLE_FLOAT_HW_USE */
if(QCBORDecode_GetNext(&DCtx, &Item) != QCBOR_ERR_FLOAT_DATE_DISABLED) {
return -19;
}
@@ -2398,9 +2398,9 @@
if(QCBORDecode_GetNext(&DCtx, &Item) != QCBOR_ERR_HALF_PRECISION_DISABLED) {
return -26;
}
-#endif
+#endif /* QCBOR_DISABLE_PREFERRED_FLOAT */
-#endif
+#endif /* QCBOR_DISABLE_FLOAT_HW_USE */
return 0;
}
@@ -2518,7 +2518,7 @@
if(uError != QCBOR_ERR_FLOAT_DATE_DISABLED) {
return 1112;
}
-#endif
+#endif /* QCBOR_DISABLE_FLOAT_HW_USE */
// Too-large integer
QCBORDecode_GetEpochDate(&DC, QCBOR_TAG_REQUIREMENT_TAG, &nEpochDateFail);
@@ -2918,7 +2918,7 @@
uError = QCBORDecode_GetNext(&DCtx, &Item);
uError = QCBORDecode_GetNext(&DCtx, &Item);
-#else
+#else /* QCBOR_CONFIG_DISABLE_EXP_AND_MANTISSA */
if(uError != QCBOR_SUCCESS ||
Item.uDataType != QCBOR_TYPE_DECIMAL_FRACTION ||
QCBORDecode_GetNthTag(&DCtx, &Item, 0) != CBOR_TAG_INVALID64 ||
@@ -2928,7 +2928,7 @@
QCBORDecode_GetNthTag(&DCtx, &Item, 4) != CBOR_TAG_INVALID64 ) {
return -5;
}
-#endif
+#endif /* QCBOR_CONFIG_DISABLE_EXP_AND_MANTISSA */
/*
More than 4 tags on an item 225(226(227(228(229([])))))
@@ -5006,7 +5006,7 @@
0x80, 0x02, 0xa0, 0x03, 0x80, 0x04, 0xa0, 0x05, 0x9f, 0xff,
0x06, 0x9f, 0x80, 0x9f, 0xff, 0xff};
-#endif
+#endif /* QCBOR_DISABLE_INDEFINITE_LENGTH_ARRAYS */
/*
@@ -5058,7 +5058,7 @@
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff
};
-#endif
+#endif /* QCBOR_DISABLE_INDEFINITE_LENGTH_ARRAYS */
int32_t EnterMapTest()
@@ -5299,7 +5299,7 @@
if(uErr != QCBOR_ERR_FLOAT_DATE_DISABLED) {
return 2027;
}
-#endif
+#endif /* QCBOR_DISABLE_FLOAT_HW_USE */
QCBORDecode_GetInt64InMapN(&DCtx, 0x05, &nInt);
uErr = QCBORDecode_GetAndResetError(&DCtx);
@@ -5634,7 +5634,7 @@
-4.0,
QCBOR_SUCCESS // Uses ieee754.h to conver, not HW
#endif /* QCBOR_DISABLE_FLOAT_HW_USE */
-#else
+#else /* QCBOR_DISABLE_PREFERRED_FLOAT */
// Half-precision disabled
-4,
QCBOR_ERR_HALF_PRECISION_DISABLED,
@@ -5642,7 +5642,7 @@
QCBOR_ERR_HALF_PRECISION_DISABLED,
-4.0,
QCBOR_ERR_HALF_PRECISION_DISABLED
-#endif
+#endif /* QCBOR_DISABLE_PREFERRED_FLOAT */
},
{
"Decimal fraction 3/10",
@@ -6825,11 +6825,11 @@
if(uDouble != -16777474) {
return 6;
}
-#else
+#else /* QCBOR_DISABLE_FLOAT_HW_USE */
if(QCBORDecode_GetAndResetError(&DCtx) != QCBOR_ERR_HW_FLOAT_DISABLED) {
return 7;
}
-#endif
+#endif /* QCBOR_DISABLE_FLOAT_HW_USE */
QCBORDecode_ExitMap(&DCtx);
diff --git a/test/run_tests.c b/test/run_tests.c
index 2936577..0146d93 100644
--- a/test/run_tests.c
+++ b/test/run_tests.c
@@ -67,7 +67,7 @@
TEST_ENTRY(IndefiniteLengthNestTest),
TEST_ENTRY(IndefiniteLengthArrayMapTest),
TEST_ENTRY(NestedMapTestIndefLen),
-#endif
+#endif /* QCBOR_DISABLE_INDEFINITE_LENGTH_ARRAYS */
TEST_ENTRY(ParseSimpleTest),
TEST_ENTRY(DecodeFailureTests),
TEST_ENTRY(EncodeRawTest),