From a9938cd46aee465e7476ab3aac773b925fc00ed4 Mon Sep 17 00:00:00 2001 From: Martin Baute Date: Fri, 11 Mar 2016 07:22:05 +0100 Subject: [PATCH] Type mismatches give compiler warnings. Fixed. --- functions/stdio/_PDCLIB_print.c | 2 +- functions/stdio/_PDCLIB_scan.c | 2 +- functions/string/strdup.c | 6 +++--- functions/string/strndup.c | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/functions/stdio/_PDCLIB_print.c b/functions/stdio/_PDCLIB_print.c index e832782..f264a61 100644 --- a/functions/stdio/_PDCLIB_print.c +++ b/functions/stdio/_PDCLIB_print.c @@ -614,7 +614,7 @@ static int testprintf( char * buffer, const char * format, ... ) status.write = testcb; va_start( status.arg, format ); memset( buffer, '\0', 100 ); - if ( _PDCLIB_print( format, &status ) != strlen( format ) ) + if ( _PDCLIB_print( format, &status ) != (int)strlen( format ) ) { printf( "_PDCLIB_print() did not return end-of-specifier on '%s'.\n", format ); ++TEST_RESULTS; diff --git a/functions/stdio/_PDCLIB_scan.c b/functions/stdio/_PDCLIB_scan.c index 9940fc0..c3429ec 100644 --- a/functions/stdio/_PDCLIB_scan.c +++ b/functions/stdio/_PDCLIB_scan.c @@ -257,7 +257,7 @@ const char * _PDCLIB_scan( const char * spec, struct _PDCLIB_status_t * status ) { char * c = va_arg( status->arg, char * ); /* for %c, default width is one */ - if ( status->width == SIZE_MAX ) + if ( status->width == UINT_MAX ) { status->width = 1; } diff --git a/functions/string/strdup.c b/functions/string/strdup.c index 6ed0f83..d8792f3 100644 --- a/functions/string/strdup.c +++ b/functions/string/strdup.c @@ -32,13 +32,13 @@ int main( void ) const char *teststr2 = "An alternative test string with non-7-bit characters \xFE\x8C\n"; char *testres, *testres2; - TESTCASE(testres = strdup(teststr)); - TESTCASE(testres2 = strdup(teststr2)); + TESTCASE((testres = strdup(teststr)) != NULL); + TESTCASE((testres2 = strdup(teststr2)) != NULL); TESTCASE(strcmp(testres, teststr) == 0); TESTCASE(strcmp(testres2, teststr2) == 0); free(testres); free(testres2); - + return TEST_RESULTS; } diff --git a/functions/string/strndup.c b/functions/string/strndup.c index e50f419..b96a86e 100644 --- a/functions/string/strndup.c +++ b/functions/string/strndup.c @@ -37,16 +37,16 @@ int main( void ) const char *teststr2 = "\xFE\x8C\n"; char *testres, *testres2; - TESTCASE(testres = strndup(teststr, 5)); - TESTCASE(testres2 = strndup(teststr2, 1)); + TESTCASE((testres = strndup(teststr, 5)) != NULL); + TESTCASE((testres2 = strndup(teststr2, 1)) != NULL); TESTCASE(strcmp(testres, teststr) != 0); TESTCASE(strncmp(testres, teststr, 5) == 0); TESTCASE(strcmp(testres2, teststr2) != 0); TESTCASE(strncmp(testres2, teststr2, 1) == 0); free(testres); free(testres2); - TESTCASE(testres = strndup(teststr, 20)); - TESTCASE(testres2 = strndup(teststr2, 5)); + TESTCASE((testres = strndup(teststr, 20)) != NULL); + TESTCASE((testres2 = strndup(teststr2, 5)) != NULL); TESTCASE(strcmp(testres, teststr) == 0); TESTCASE(strcmp(testres2, teststr2) == 0); free(testres); -- 2.40.0