From 77d2de223c296f1b17036aa1eb70f06f29640882 Mon Sep 17 00:00:00 2001 From: Andres Amaya Garcia Date: Sun, 29 Apr 2018 22:35:36 +0100 Subject: [PATCH] Fix ret code in generic_sum.c --- programs/hash/generic_sum.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/programs/hash/generic_sum.c b/programs/hash/generic_sum.c index d1e81d491..3fb215b22 100644 --- a/programs/hash/generic_sum.c +++ b/programs/hash/generic_sum.c @@ -29,9 +29,12 @@ #include "mbedtls/platform.h" #else #include -#define mbedtls_fprintf fprintf -#define mbedtls_printf printf -#endif +#include +#define mbedtls_fprintf fprintf +#define mbedtls_printf printf +#define MBEDTLS_EXTI_SUCCESS EXIT_SUCCESS +#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE +#endif /* MBEDTLS_PLATFORM_C */ #if defined(MBEDTLS_MD_C) && defined(MBEDTLS_FS_IO) #include "mbedtls/md.h" @@ -169,7 +172,8 @@ static int generic_check( const mbedtls_md_info_t *md_info, char *filename ) int main( int argc, char *argv[] ) { - int ret, i; + int ret = 1, i; + int exit_code = MBEDTLS_EXIT_FAILURE; const mbedtls_md_info_t *md_info; mbedtls_md_context_t md_ctx; @@ -196,7 +200,7 @@ int main( int argc, char *argv[] ) fflush( stdout ); getchar(); #endif - return( 1 ); + return( exit_code ); } /* @@ -206,12 +210,12 @@ int main( int argc, char *argv[] ) if( md_info == NULL ) { mbedtls_fprintf( stderr, "Message Digest '%s' not found\n", argv[1] ); - return( 1 ); + return( exit_code ); } if( mbedtls_md_setup( &md_ctx, md_info, 0 ) ) { mbedtls_fprintf( stderr, "Failed to initialize context.\n" ); - return( 1 ); + return( exit_code ); } ret = 0; @@ -224,9 +228,12 @@ int main( int argc, char *argv[] ) for( i = 2; i < argc; i++ ) ret |= generic_print( md_info, argv[i] ); + if ( ret == 0 ) + exit_code = MBEDTLS_EXIT_SUCCESS; + exit: mbedtls_md_free( &md_ctx ); - return( ret ); + return( exit_code ); } #endif /* MBEDTLS_MD_C && MBEDTLS_FS_IO */