1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-08-08 17:42:09 +03:00

Merge pull request #2595 from k-stachowiak/unified-exit-in-examples

Unify the example programs' termination
This commit is contained in:
Gilles Peskine
2020-05-12 10:46:47 +02:00
committed by GitHub
49 changed files with 122 additions and 114 deletions

View File

@@ -48,7 +48,7 @@
int main( void )
{
mbedtls_printf("MBEDTLS_MD_C and/or MBEDTLS_FS_IO not defined.\n");
return( 0 );
mbedtls_exit( 0 );
}
#else
@@ -203,7 +203,7 @@ int main( int argc, char *argv[] )
fflush( stdout ); getchar();
#endif
return( exit_code );
mbedtls_exit( exit_code );
}
/*
@@ -213,12 +213,12 @@ int main( int argc, char *argv[] )
if( md_info == NULL )
{
mbedtls_fprintf( stderr, "Message Digest '%s' not found\n", argv[1] );
return( exit_code );
mbedtls_exit( exit_code );
}
if( mbedtls_md_setup( &md_ctx, md_info, 0 ) )
{
mbedtls_fprintf( stderr, "Failed to initialize context.\n" );
return( exit_code );
mbedtls_exit( exit_code );
}
ret = 0;
@@ -237,6 +237,6 @@ int main( int argc, char *argv[] )
exit:
mbedtls_md_free( &md_ctx );
return( exit_code );
mbedtls_exit( exit_code );
}
#endif /* MBEDTLS_MD_C && MBEDTLS_FS_IO */

View File

@@ -44,7 +44,7 @@
int main( void )
{
mbedtls_printf("MBEDTLS_MD5_C not defined.\n");
return( 0 );
mbedtls_exit( 0 );
}
#else
@@ -58,7 +58,7 @@ int main( void )
mbedtls_printf( "\n MD5('%s') = ", str );
if( ( ret = mbedtls_md5_ret( (unsigned char *) str, 13, digest ) ) != 0 )
return( MBEDTLS_EXIT_FAILURE );
mbedtls_exit( MBEDTLS_EXIT_FAILURE );
for( i = 0; i < 16; i++ )
mbedtls_printf( "%02x", digest[i] );
@@ -70,6 +70,6 @@ int main( void )
fflush( stdout ); getchar();
#endif
return( MBEDTLS_EXIT_SUCCESS );
mbedtls_exit( MBEDTLS_EXIT_SUCCESS );
}
#endif /* MBEDTLS_MD5_C */