mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-12-23 17:55:37 +00:00
Return from the test and utility examples via exit()
All the core examples have been modified not to return from main by the means of the return statement, but rather via exit() function, which was done to make the examples more bare metal friendly. This commit, for the sake of consistency, introduces the modifications to the test and utility examples. These, while less likely to be used in the low level environments, won't suffer from such a change.
This commit is contained in:
parent
5e1b195d1f
commit
776521aee8
|
@ -43,7 +43,7 @@
|
||||||
int main( void )
|
int main( void )
|
||||||
{
|
{
|
||||||
mbedtls_printf("MBEDTLS_TIMING_C not defined.\n");
|
mbedtls_printf("MBEDTLS_TIMING_C not defined.\n");
|
||||||
return( 0 );
|
mbedtls_exit( 0 );
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
@ -999,7 +999,7 @@ int main( int argc, char *argv[] )
|
||||||
fflush( stdout ); getchar();
|
fflush( stdout ); getchar();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return( 0 );
|
mbedtls_exit( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* MBEDTLS_TIMING_C */
|
#endif /* MBEDTLS_TIMING_C */
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
#define mbedtls_printf printf
|
#define mbedtls_printf printf
|
||||||
#define mbedtls_calloc calloc
|
#define mbedtls_calloc calloc
|
||||||
#define mbedtls_free free
|
#define mbedtls_free free
|
||||||
|
#define mbedtls_exit exit
|
||||||
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
|
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
|
||||||
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
|
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
|
||||||
#endif /* MBEDTLS_PLATFORM_C */
|
#endif /* MBEDTLS_PLATFORM_C */
|
||||||
|
@ -50,7 +51,7 @@
|
||||||
int main( void )
|
int main( void )
|
||||||
{
|
{
|
||||||
mbedtls_printf( "MBEDTLS_NET_C not defined.\n" );
|
mbedtls_printf( "MBEDTLS_NET_C not defined.\n" );
|
||||||
return( 0 );
|
mbedtls_exit( 0 );
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
@ -964,7 +965,7 @@ exit:
|
||||||
fflush( stdout ); getchar();
|
fflush( stdout ); getchar();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return( exit_code );
|
mbedtls_exit( exit_code );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* MBEDTLS_NET_C */
|
#endif /* MBEDTLS_NET_C */
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
#else
|
#else
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#define mbedtls_printf printf
|
#define mbedtls_printf printf
|
||||||
|
#define mbedtls_exit exit
|
||||||
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
|
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
|
||||||
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
|
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
|
||||||
#endif
|
#endif
|
||||||
|
@ -72,14 +73,14 @@ int main( int argc, char** argv )
|
||||||
{
|
{
|
||||||
mbedtls_printf( "This program takes exactly 1 agument\n" );
|
mbedtls_printf( "This program takes exactly 1 agument\n" );
|
||||||
usage();
|
usage();
|
||||||
return( exit_code );
|
mbedtls_exit( exit_code );
|
||||||
}
|
}
|
||||||
|
|
||||||
fp = fopen( argv[1], "r" );
|
fp = fopen( argv[1], "r" );
|
||||||
if( fp == NULL )
|
if( fp == NULL )
|
||||||
{
|
{
|
||||||
mbedtls_printf( "Could not open file '%s'\n", argv[1] );
|
mbedtls_printf( "Could not open file '%s'\n", argv[1] );
|
||||||
return( exit_code );
|
mbedtls_exit( exit_code );
|
||||||
}
|
}
|
||||||
|
|
||||||
while( ( c = fgetc( fp ) ) != EOF && p < end - 1 )
|
while( ( c = fgetc( fp ) ) != EOF && p < end - 1 )
|
||||||
|
@ -97,5 +98,5 @@ int main( int argc, char** argv )
|
||||||
fclose( fp );
|
fclose( fp );
|
||||||
mbedtls_platform_zeroize( buf, sizeof( buf ) );
|
mbedtls_platform_zeroize( buf, sizeof( buf ) );
|
||||||
|
|
||||||
return( exit_code );
|
mbedtls_exit( exit_code );
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@
|
||||||
int main( void )
|
int main( void )
|
||||||
{
|
{
|
||||||
mbedtls_printf("MBEDTLS_BASE64_C and/or MBEDTLS_FS_IO not defined.\n");
|
mbedtls_printf("MBEDTLS_BASE64_C and/or MBEDTLS_FS_IO not defined.\n");
|
||||||
return( 0 );
|
mbedtls_exit( 0 );
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
@ -290,6 +290,6 @@ exit:
|
||||||
fflush( stdout ); getchar();
|
fflush( stdout ); getchar();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return( exit_code );
|
mbedtls_exit( exit_code );
|
||||||
}
|
}
|
||||||
#endif /* MBEDTLS_BASE64_C && MBEDTLS_FS_IO */
|
#endif /* MBEDTLS_BASE64_C && MBEDTLS_FS_IO */
|
||||||
|
|
|
@ -29,7 +29,9 @@
|
||||||
#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
|
||||||
|
#define mbedtls_exit exit
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MBEDTLS_ERROR_C) || defined(MBEDTLS_ERROR_STRERROR_DUMMY)
|
#if defined(MBEDTLS_ERROR_C) || defined(MBEDTLS_ERROR_STRERROR_DUMMY)
|
||||||
|
@ -48,7 +50,7 @@
|
||||||
int main( void )
|
int main( void )
|
||||||
{
|
{
|
||||||
mbedtls_printf("MBEDTLS_ERROR_C and/or MBEDTLS_ERROR_STRERROR_DUMMY not defined.\n");
|
mbedtls_printf("MBEDTLS_ERROR_C and/or MBEDTLS_ERROR_STRERROR_DUMMY not defined.\n");
|
||||||
return( 0 );
|
mbedtls_exit( 0 );
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
int main( int argc, char *argv[] )
|
int main( int argc, char *argv[] )
|
||||||
|
@ -59,7 +61,7 @@ int main( int argc, char *argv[] )
|
||||||
if( argc != 2 )
|
if( argc != 2 )
|
||||||
{
|
{
|
||||||
mbedtls_printf( USAGE );
|
mbedtls_printf( USAGE );
|
||||||
return( 0 );
|
mbedtls_exit( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
val = strtol( argv[1], &end, 10 );
|
val = strtol( argv[1], &end, 10 );
|
||||||
|
@ -87,6 +89,6 @@ int main( int argc, char *argv[] )
|
||||||
fflush( stdout ); getchar();
|
fflush( stdout ); getchar();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return( val );
|
mbedtls_exit( val );
|
||||||
}
|
}
|
||||||
#endif /* MBEDTLS_ERROR_C */
|
#endif /* MBEDTLS_ERROR_C */
|
||||||
|
|
Loading…
Reference in a new issue