Fix warning from static analysis in floating-point test (#178)
This makes one of the parameters in the floating point test const as recommended by cppcheck for general code hygiene.
* Fix warning from static analysis
const-qualify *half to silence the warning
Update declaration of decode_half
* Fix warning from static analysis
diff --git a/test/half_to_double_from_rfc7049.c b/test/half_to_double_from_rfc7049.c
index d4fded6..9b7aeaa 100644
--- a/test/half_to_double_from_rfc7049.c
+++ b/test/half_to_double_from_rfc7049.c
@@ -36,7 +36,7 @@
#include <math.h>
#ifndef USEFULBUF_DISABLE_ALL_FLOAT
-double decode_half(unsigned char *halfp) {
+double decode_half(const unsigned char *halfp) {
int half = (halfp[0] << 8) + halfp[1];
int exp = (half >> 10) & 0x1f;
int mant = half & 0x3ff;
diff --git a/test/half_to_double_from_rfc7049.h b/test/half_to_double_from_rfc7049.h
index 6318f80..8e07dc2 100644
--- a/test/half_to_double_from_rfc7049.h
+++ b/test/half_to_double_from_rfc7049.h
@@ -15,7 +15,7 @@
#define half_to_double_from_rfc7049_h
#ifndef USEFULBUF_DISABLE_ALL_FLOAT
-double decode_half(unsigned char *halfp);
+double decode_half(const unsigned char *halfp);
#endif /* USEFULBUF_DISABLE_ALL_FLOAT */
#endif /* half_to_double_from_rfc7049_h */
diff --git a/test/qcbor_encode_tests.c b/test/qcbor_encode_tests.c
index 6e569ca..5c59fe1 100644
--- a/test/qcbor_encode_tests.c
+++ b/test/qcbor_encode_tests.c
@@ -74,7 +74,7 @@
size_t i;
for(i = 0; i < U1.len; i++) {
if(((uint8_t *)U1.ptr)[i] != ((uint8_t *)U2.ptr)[i]) {
- printf("Position: %d Actual: 0x%x Expected: 0x%x\n",
+ printf("Position: %u Actual: 0x%x Expected: 0x%x\n",
(uint32_t)i,
((uint8_t *)U1.ptr)[i],
((uint8_t *)U2.ptr)[i]);