From dccb80b7e55281fb0fba1c88c69baddc5d72e0ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Wed, 3 Jun 2015 10:20:33 +0100 Subject: [PATCH] Fix compile errors with NO_STD_FUNCTIONS --- ChangeLog | 1 + include/polarssl/platform.h | 4 ++++ library/platform.c | 3 +-- tests/scripts/all.sh | 8 ++++++++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2582c9a46..aa02b5939 100644 --- a/ChangeLog +++ b/ChangeLog @@ -35,6 +35,7 @@ Features errors on use of deprecated functions. Bugfix + * Fix compile errors with PLATFORM_NO_STD_FUNCTIONS. * Fix compile error with PLATFORM_EXIT_ALT (thanks to Rafał Przywara). * Fix bug in entropy.c when THREADING_C is also enabled that caused entropy_free() to crash (thanks to Rafał Przywara). diff --git a/include/polarssl/platform.h b/include/polarssl/platform.h index 9095203e0..639b180e3 100644 --- a/include/polarssl/platform.h +++ b/include/polarssl/platform.h @@ -85,6 +85,8 @@ extern "C" { #define polarssl_free POLARSSL_PLATFORM_FREE_MACRO #define polarssl_malloc POLARSSL_PLATFORM_MALLOC_MACRO #else +/* For size_t */ +#include extern void * (*polarssl_malloc)( size_t len ); extern void (*polarssl_free)( void *ptr ); @@ -108,6 +110,8 @@ int platform_set_malloc_free( void * (*malloc_func)( size_t ), * The function pointers for fprintf */ #if defined(POLARSSL_PLATFORM_FPRINTF_ALT) +/* We need FILE * */ +#include extern int (*polarssl_fprintf)( FILE *stream, const char *format, ... ); /** diff --git a/library/platform.c b/library/platform.c index 96f2a9d96..a36dc62ab 100644 --- a/library/platform.c +++ b/library/platform.c @@ -72,7 +72,7 @@ static int platform_snprintf_uninit( char * s, size_t n, { ((void) s); ((void) n); - ((void) format) + ((void) format); return( 0 ); } @@ -148,7 +148,6 @@ int platform_set_fprintf( int (*fprintf_func)( FILE *, const char *, ... ) ) static void platform_exit_uninit( int status ) { ((void) status); - return( 0 ); } #define POLARSSL_PLATFORM_STD_EXIT platform_exit_uninit diff --git a/tests/scripts/all.sh b/tests/scripts/all.sh index c083924b7..41993d95a 100755 --- a/tests/scripts/all.sh +++ b/tests/scripts/all.sh @@ -146,6 +146,14 @@ scripts/config.pl unset POLARSSL_MEMORY_BUFFER_ALLOC_C scripts/config.pl unset POLARSSL_FS_IO CC=gcc CFLAGS='-Werror -O0' make +# catch compile bugs in _uninit functions +msg "build: full config with NO_STD_FUNCTION, make, gcc" # ~ 30s +cleanup +cp "$CONFIG_H" "$CONFIG_BAK" +scripts/config.pl full +scripts/config.pl set POLARSSL_PLATFORM_NO_STD_FUNCTIONS +CC=gcc CFLAGS='-Werror -O0' make + if uname -a | grep -F x86_64 >/dev/null; then msg "build: i386, make, gcc" # ~ 30s cleanup