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/float_tests.c b/test/float_tests.c
index 10ac012..20057c3 100644
--- a/test/float_tests.c
+++ b/test/float_tests.c
@@ -77,7 +77,7 @@
};
-int HalfPrecisionDecodeBasicTests()
+int32_t HalfPrecisionDecodeBasicTests()
{
UsefulBufC HalfPrecision = UsefulBuf_FROM_BYTE_ARRAY_LITERAL(spExpectedHalf);
@@ -190,12 +190,12 @@
-int HalfPrecisionAgainstRFCCodeTest()
+int32_t HalfPrecisionAgainstRFCCodeTest()
{
for(uint32_t uHalfP = 0; uHalfP < 0xffff; uHalfP += 60) {
unsigned char x[2];
- x[1] = uHalfP & 0xff;
- x[0] = uHalfP >> 8;
+ x[1] = (uint8_t)(uHalfP & 0xff);
+ x[0] = (uint8_t)(uHalfP >> 8); // uHalfP is always less than 0xffff
double d = decode_half(x);
// Contruct the CBOR for the half-precision float by hand
@@ -203,7 +203,7 @@
UsefulOutBuf UOB;
UsefulOutBuf_Init(&UOB, __xx);
- const uint8_t uHalfPrecInitialByte = HALF_PREC_FLOAT + (CBOR_MAJOR_TYPE_SIMPLE << 5); // 0xf9
+ const uint8_t uHalfPrecInitialByte = (uint8_t)(HALF_PREC_FLOAT + (CBOR_MAJOR_TYPE_SIMPLE << 5)); // 0xf9
UsefulOutBuf_AppendByte(&UOB, uHalfPrecInitialByte); // The initial byte for a half-precision float
UsefulOutBuf_AppendUint16(&UOB, (uint16_t)uHalfP);
@@ -307,7 +307,7 @@
};
-int DoubleAsSmallestTest()
+int32_t DoubleAsSmallestTest()
{
UsefulBuf_MAKE_STACK_UB(EncodedHalfsMem, 420);