Fix ret code in key_app.c

This commit is contained in:
Andres Amaya Garcia 2018-04-29 20:02:18 +01:00 committed by Simon Butcher
parent 7c55e79f54
commit f57bccf839

View File

@ -29,8 +29,11 @@
#include "mbedtls/platform.h" #include "mbedtls/platform.h"
#else #else
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#define mbedtls_printf printf #define mbedtls_printf printf
#endif #define MBEDTLS_EXTI_SUCCESS EXIT_SUCCESS
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
#endif /* MBEDTLS_PLATFORM_C */
#if defined(MBEDTLS_BIGNUM_C) && \ #if defined(MBEDTLS_BIGNUM_C) && \
defined(MBEDTLS_PK_PARSE_C) && defined(MBEDTLS_FS_IO) defined(MBEDTLS_PK_PARSE_C) && defined(MBEDTLS_FS_IO)
@ -83,7 +86,8 @@ struct options
int main( int argc, char *argv[] ) int main( int argc, char *argv[] )
{ {
int ret = 0; int ret = 1;
int exit_code = MBEDTLS_EXIT_FAILURE;
char buf[1024]; char buf[1024];
int i; int i;
char *p, *q; char *p, *q;
@ -283,10 +287,12 @@ int main( int argc, char *argv[] )
else else
goto usage; goto usage;
exit_code = MBEDTLS_EXIT_SUCCESS;
exit: exit:
#if defined(MBEDTLS_ERROR_C) #if defined(MBEDTLS_ERROR_C)
if( ret != 0 ) if( exit_code != MBEDTLS_EXIT_SUCCESS )
{ {
mbedtls_strerror( ret, buf, sizeof(buf) ); mbedtls_strerror( ret, buf, sizeof(buf) );
mbedtls_printf( " ! Last error was: %s\n", buf ); mbedtls_printf( " ! Last error was: %s\n", buf );
@ -303,6 +309,6 @@ exit:
fflush( stdout ); getchar(); fflush( stdout ); getchar();
#endif #endif
return( ret ); return( exit_code );
} }
#endif /* MBEDTLS_BIGNUM_C && MBEDTLS_PK_PARSE_C && MBEDTLS_FS_IO */ #endif /* MBEDTLS_BIGNUM_C && MBEDTLS_PK_PARSE_C && MBEDTLS_FS_IO */