Refine use of integer variables to quiet static analyzers and reduce object code size a little
Note that the no bugs of consequence were found by the static analyzer. The analyzer used was codesafe.cn
diff --git a/test/qcbor_encode_tests.c b/test/qcbor_encode_tests.c
index 9a7aecf..e922503 100644
--- a/test/qcbor_encode_tests.c
+++ b/test/qcbor_encode_tests.c
@@ -142,7 +142,7 @@
/*
Some very minimal tests.
*/
-int BasicEncodeTest()
+int32_t BasicEncodeTest()
{
// Very simple CBOR, a map with one boolean that is true in it
QCBOREncodeContext EC;
@@ -511,7 +511,7 @@
--XXXXboundary text--";
-int AllAddMethodsTest()
+int32_t AllAddMethodsTest()
{
// TODO: this test should be broken down into several so it is more
// managable. Tags and labels could be more sensible
@@ -791,7 +791,7 @@
to expected values generated from http://cbor.me.
*/
-int IntegerValuesTest1()
+int32_t IntegerValuesTest1()
{
QCBOREncodeContext ECtx;
int nReturn = 0;
@@ -876,7 +876,7 @@
static const uint8_t spExpectedEncodedSimple[] = {
0x85, 0xf5, 0xf4, 0xf6, 0xf7, 0xa1, 0x65, 0x55, 0x4e, 0x44, 0x65, 0x66, 0xf7};
-int SimpleValuesTest1()
+int32_t SimpleValuesTest1()
{
QCBOREncodeContext ECtx;
int nReturn = 0;
@@ -923,7 +923,7 @@
static const uint8_t spExpectedEncodedSimpleIndefiniteLength[] = {
0x9f, 0xf5, 0xf4, 0xf6, 0xf7, 0xbf, 0x65, 0x55, 0x4e, 0x44, 0x65, 0x66, 0xf7, 0xff, 0xff};
-int SimpleValuesIndefiniteLengthTest1()
+int32_t SimpleValuesIndefiniteLengthTest1()
{
QCBOREncodeContext ECtx;
int nReturn = 0;
@@ -1118,7 +1118,7 @@
0x31
};
-int EncodeLengthThirtyoneTest()
+int32_t EncodeLengthThirtyoneTest()
{
QCBOREncodeContext ECtx;
int nReturn = 0;
@@ -1198,7 +1198,7 @@
0x32, 0x5a, 0x62, 0x53, 0x44, 0xc1, 0x19, 0x03, 0xe7
};
-int EncodeDateTest()
+int32_t EncodeDateTest()
{
QCBOREncodeContext ECtx;
int nReturn = 0;
@@ -1235,7 +1235,7 @@
}
-int ArrayNestingTest1()
+int32_t ArrayNestingTest1()
{
QCBOREncodeContext ECtx;
int i;
@@ -1258,7 +1258,7 @@
-int ArrayNestingTest2()
+int32_t ArrayNestingTest2()
{
QCBOREncodeContext ECtx;
int i;
@@ -1282,7 +1282,7 @@
-int ArrayNestingTest3()
+int32_t ArrayNestingTest3()
{
QCBOREncodeContext ECtx;
int i;
@@ -1399,7 +1399,7 @@
0xff, 0xff};
-int EncodeRawTest()
+int32_t EncodeRawTest()
{
QCBOREncodeContext ECtx;
@@ -1425,7 +1425,7 @@
/*
This returns a pointer to spBigBuf
*/
-static int CreateMap(uint8_t **pEncoded, size_t *pEncodedLen)
+static int32_t CreateMap(uint8_t **pEncoded, size_t *pEncodedLen)
{
QCBOREncodeContext ECtx;
int nReturn = -1;
@@ -1522,7 +1522,7 @@
0x73 } ;
-int MapEncodeTest()
+int32_t MapEncodeTest()
{
uint8_t *pEncodedMaps;
size_t nEncodedMapLen;
@@ -1563,7 +1563,7 @@
*/
static UsefulBufC
-FormatRTICResults(int nRResult,
+FormatRTICResults(uint64_t uRResult,
uint64_t time,
const char *szType,
const char *szAlexString,
@@ -1586,7 +1586,7 @@
// The result: 0 if scan happened and found nothing; 1 if it happened and
// found something wrong; 2 if it didn't happen
- QCBOREncode_AddSimpleToMap(&ECtx, "integrity", nRResult);
+ QCBOREncode_AddSimpleToMap(&ECtx, "integrity", uRResult);
// Add the diagnostic code
QCBOREncode_AddSZStringToMap(&ECtx, "type", szType);
@@ -1678,7 +1678,7 @@
0xaa, 0xbb, 0x01, 0x01};
-int RTICResultsTest()
+int32_t RTICResultsTest()
{
const UsefulBufC Encoded = FormatRTICResults(CBOR_SIMPLEV_FALSE, 1477263730,
"recent", "0xA1eC5001",
@@ -1777,7 +1777,7 @@
-int BstrWrapErrorTest()
+int32_t BstrWrapErrorTest()
{
// ---- Test closing a bstrwrap when it is an array that is open ---------
QCBOREncodeContext EC;
@@ -1942,7 +1942,7 @@
}
// Part of bstr_wrap_nest_test
-static int DecodeNextNested2(UsefulBufC Wrapped)
+static int32_t DecodeNextNested2(UsefulBufC Wrapped)
{
int nReturn;
QCBORDecodeContext DC;
@@ -2008,7 +2008,7 @@
}
-int BstrWrapNestTest()
+int32_t BstrWrapNestTest()
{
QCBOREncodeContext EC;
QCBOREncode_Init(&EC, UsefulBuf_FROM_BYTE_ARRAY(spBigBuf));
@@ -2020,24 +2020,24 @@
for(int i = 0; i < BSTR_TEST_DEPTH-2; i++) {
QCBOREncode_BstrWrap(&EC);
- QCBOREncode_AddUInt64(&EC, i);
+ QCBOREncode_AddInt64(&EC, i);
}
for(int i = 0; i < BSTR_TEST_DEPTH-2; i++) {
QCBOREncode_CloseBstrWrap(&EC, NULL);
- QCBOREncode_AddUInt64(&EC, i);
+ QCBOREncode_AddInt64(&EC, i);
}
for(int i = 0; i < (BSTR_TEST_DEPTH-2)/3; i++) {
QCBOREncode_OpenMap(&EC);
QCBOREncode_BstrWrapInMapN(&EC, i+0x20);
QCBOREncode_OpenArray(&EC);
- QCBOREncode_AddUInt64(&EC, i+0x10);
+ QCBOREncode_AddInt64(&EC, i+0x10);
}
for(int i = 0; i < (BSTR_TEST_DEPTH-2)/3; i++) {
QCBOREncode_CloseArray(&EC);
- QCBOREncode_AddUInt64(&EC, i+0x30);
+ QCBOREncode_AddInt64(&EC, i+0x30);
QCBOREncode_CloseBstrWrap(&EC, NULL);
QCBOREncode_AddSZStringToMapN(&EC, i+0x40, "hello");
QCBOREncode_CloseMap(&EC);
@@ -2164,7 +2164,7 @@
be nice as it would make the test really good. That would require
bring in ECDSA crypto to this test.
*/
-int CoseSign1TBSTest()
+int32_t CoseSign1TBSTest()
{
// All of this is from RFC 8152 C.2.1
const char *szKid = "11";
@@ -2230,7 +2230,7 @@
}
-int EncodeErrorTests()
+int32_t EncodeErrorTests()
{
QCBOREncodeContext EC;
@@ -2486,7 +2486,7 @@
};
-int ExponentAndMantissaEncodeTests()
+int32_t ExponentAndMantissaEncodeTests()
{
QCBOREncodeContext EC;
UsefulBufC EncodedExponentAndMantissa;