Fix ifdef fanout after last merge from master (#239)
Co-authored-by: Laurence Lundblade <lgl@securitytheory.com>
diff --git a/inc/qcbor/qcbor_encode.h b/inc/qcbor/qcbor_encode.h
index c72f4d9..95e0a95 100644
--- a/inc/qcbor/qcbor_encode.h
+++ b/inc/qcbor/qcbor_encode.h
@@ -838,6 +838,8 @@
*
* By default, this will error out on an attempt to encode a NaN with
* a payload. See QCBOREncode_Allow() and @ref QCBOR_ENCODE_ALLOW_NAN_PAYLOAD.
+ * If preferred serialization is disabled at compliation, this check for
+ * for NaN payloads is disabled.
*/
static void
QCBOREncode_AddDouble(QCBOREncodeContext *pCtx, double dNum);
diff --git a/src/qcbor_encode.c b/src/qcbor_encode.c
index d196149..e54f03e 100644
--- a/src/qcbor_encode.c
+++ b/src/qcbor_encode.c
@@ -1330,6 +1330,7 @@
}
+#ifndef QCBOR_DISABLE_INDEFINITE_LENGTH_ARRAYS
/*
* Public functions for closing sorted maps. See qcbor/qcbor_encode.h
*/
@@ -1343,6 +1344,7 @@
QCBOREncode_Private_CloseMapOrArrayIndefiniteLength(pMe, CBOR_MAJOR_NONE_TYPE_MAP_INDEFINITE_LEN);
}
+#endif /* ! QCBOR_DISABLE_INDEFINITE_LENGTH_ARRAYS */
/*
diff --git a/test/qcbor_encode_tests.c b/test/qcbor_encode_tests.c
index 1c0902b..7645475 100644
--- a/test/qcbor_encode_tests.c
+++ b/test/qcbor_encode_tests.c
@@ -736,7 +736,6 @@
#else
uExpectedErr = QCBOR_SUCCESS;
#endif
-
/* Test the QCBOR_ERR_NOT_ALLOWED error codes */
QCBOREncode_Init(&ECtx, UsefulBuf_FROM_BYTE_ARRAY(spBigBuf));
QCBOREncode_AddNegativeUInt64(&ECtx, 1);
@@ -745,6 +744,13 @@
goto Done;
}
+
+#if !defined(QCBOR_DISABLE_ENCODE_USAGE_GUARDS) && !defined(QCBOR_DISABLE_PREFERRED_FLOAT)
+ uExpectedErr = QCBOR_ERR_NOT_ALLOWED;
+#else
+ uExpectedErr = QCBOR_SUCCESS;
+#endif
+
#ifndef USEFULBUF_DISABLE_ALL_FLOAT
QCBOREncode_Init(&ECtx, UsefulBuf_FROM_BYTE_ARRAY(spBigBuf));
/* 0x7ff8000000000001ULL is a NaN with a payload. */
@@ -3478,7 +3484,7 @@
if(uErr) {
return 91;
}
-
+#ifndef QCBOR_DISABLE_INDEFINITE_LENGTH_ARRAYS
static const uint8_t spIndefItems[] = {
0xA4, 0x62, 0x62, 0x62, 0x02, 0x64, 0x61, 0x61,
0x61, 0x61, 0x01, 0x7F, 0x61, 0x61, 0x61, 0x61,
@@ -3520,7 +3526,7 @@
&CompareDiagnostics)) {
return 102;
}
-
+#endif
/* --- Duplicate label test --- */
QCBOREncode_Init(&EC, TestBuf);
@@ -3613,6 +3619,7 @@
uExpectedErr = QCBOR_SUCCESS;
#endif
+#ifndef QCBOR_DISABLE_INDEFINITE_LENGTH_ARRAYS
/* Next, make sure methods that encode non-CDE error out */
QCBOREncode_Init(&EC, UsefulBuf_FROM_BYTE_ARRAY(spBigBuf));
QCBOREncode_SerializationCDE(&EC);
@@ -3621,6 +3628,7 @@
if(QCBOREncode_GetErrorState(&EC) != uExpectedErr) {
return 100;
}
+#endif /* ! QCBOR_DISABLE_INDEFINITE_LENGTH_ARRAYS */
return 0;
}
@@ -3667,6 +3675,7 @@
/* Next, make sure methods that encode of non-CDE error out */
+#ifndef QCBOR_DISABLE_INDEFINITE_LENGTH_ARRAYS
/* Indefinite-length map */
QCBOREncode_Init(&EC, UsefulBuf_FROM_BYTE_ARRAY(spBigBuf));
QCBOREncode_SerializationdCBOR(&EC);
@@ -3684,6 +3693,7 @@
if(QCBOREncode_GetErrorState(&EC) != uExpectedErr) {
return 101;
}
+#endif /* ! QCBOR_DISABLE_INDEFINITE_LENGTH_ARRAYS */
/* The "undef" special value */
QCBOREncode_Init(&EC, UsefulBuf_FROM_BYTE_ARRAY(spBigBuf));