Quiet warnings for stricter compilers configurations (#84)
Fix warnings from -Wcast-qual and -Wstrict-prototypes.
A few other warning fixes and documentation improvements are added.
Also fixes Makefile so the before-release build script can invoke both gcc and clang. That script is here: laurencelundblade/qdv@536f083
This is an alternative to #79. It does not fix warnings for -Wbad-function-cast
because those fixes cause warnings with other compilers (MacOS clang). This doesn't enable GitHub automated build checks. The plan is to do that separately.
diff --git a/test/UsefulBuf_Tests.c b/test/UsefulBuf_Tests.c
index 880be02..264fbca 100644
--- a/test/UsefulBuf_Tests.c
+++ b/test/UsefulBuf_Tests.c
@@ -41,7 +41,7 @@
There is nothing adversarial in this test
*/
-const char * UOBTest_NonAdversarial()
+const char * UOBTest_NonAdversarial(void)
{
const char *szReturn = NULL;
@@ -160,7 +160,7 @@
*/
-const char *UOBTest_BoundaryConditionsTest()
+const char *UOBTest_BoundaryConditionsTest(void)
{
UsefulBuf_MAKE_STACK_UB(outbuf,2);
@@ -248,7 +248,7 @@
// Test function to get size and magic number check
-const char *TestBasicSanity()
+const char *TestBasicSanity(void)
{
UsefulBuf_MAKE_STACK_UB(outbuf,10);
@@ -293,7 +293,7 @@
-const char *UBMacroConversionsTest()
+const char *UBMacroConversionsTest(void)
{
char *szFoo = "foo";
@@ -310,16 +310,17 @@
if(Boo.len != 3 || strncmp(Boo.ptr, "Boo", 3))
return "UsefulBuf_FROM_BYTE_ARRAY_LITERAL failed";
- UsefulBuf B = (UsefulBuf){(void *)Too.ptr, Too.len};
+ char *String = "string"; // Intentionally not const
+ UsefulBuf B = (UsefulBuf){(void *)String, strlen(String)};
UsefulBufC BC = UsefulBuf_Const(B);
- if(BC.len != Too.len || BC.ptr != Too.ptr)
+ if(BC.len != strlen(String) || BC.ptr != String)
return "UsefulBufConst failed";
return NULL;
}
-const char *UBUtilTests()
+const char *UBUtilTests(void)
{
UsefulBuf UB = NULLUsefulBuf;
@@ -628,7 +629,7 @@
}
-const char * UIBTest_IntegerFormat()
+const char * UIBTest_IntegerFormat(void)
{
UsefulOutBuf_MakeOnStack(UOB, 100);
@@ -736,7 +737,7 @@
}
-const char *UBUTest_CopyUtil()
+const char *UBUTest_CopyUtil(void)
{
if(UsefulBufUtil_CopyFloatToUint32(65536.0F) != 0x47800000) {
return "CopyFloatToUint32 failed";
diff --git a/test/qcbor_decode_tests.c b/test/qcbor_decode_tests.c
index 567f654..689d275 100644
--- a/test/qcbor_decode_tests.c
+++ b/test/qcbor_decode_tests.c
@@ -5043,7 +5043,7 @@
/* Repeatedly enter and exit maps and arrays, go off the end of maps
and arrays and such. */
-static int32_t DecodeNestedIterate()
+static int32_t DecodeNestedIterate(void)
{
QCBORDecodeContext DCtx;
int32_t nReturn;
diff --git a/test/qcbor_encode_tests.c b/test/qcbor_encode_tests.c
index f9d8507..c3e7315 100644
--- a/test/qcbor_encode_tests.c
+++ b/test/qcbor_encode_tests.c
@@ -116,10 +116,10 @@
struct UBCompareDiagnostic *pDiag) {
size_t i;
for(i = 0; i < Actual.len; i++) {
- if(((uint8_t *)Actual.ptr)[i] != ((uint8_t *)Expected.ptr)[i]) {
+ if(((const uint8_t *)Actual.ptr)[i] != ((const uint8_t *)Expected.ptr)[i]) {
if(pDiag) {
- pDiag->uActual = ((uint8_t *)Actual.ptr)[i];
- pDiag->uExpected = ((uint8_t *)Expected.ptr)[i];
+ pDiag->uActual = ((const uint8_t *)Actual.ptr)[i];
+ pDiag->uExpected = ((const uint8_t *)Expected.ptr)[i];
pDiag->uOffset = i;
}
// Cast to int is OK as this is only a diagnostic and the sizes