mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-05-09 19:02:10 +00:00
Fix ret code in gen_entropy.c
This commit is contained in:
parent
1b04390e4f
commit
43e65fbbca
|
@ -29,9 +29,12 @@
|
||||||
#include "mbedtls/platform.h"
|
#include "mbedtls/platform.h"
|
||||||
#else
|
#else
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#define mbedtls_fprintf fprintf
|
#include <stdlib.h>
|
||||||
#define mbedtls_printf printf
|
#define mbedtls_fprintf fprintf
|
||||||
#endif
|
#define mbedtls_printf printf
|
||||||
|
#define MBEDTLS_EXTI_SUCCESS EXIT_SUCCESS
|
||||||
|
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
|
||||||
|
#endif /* MBEDTLS_PLATFORM_C */
|
||||||
|
|
||||||
#if defined(MBEDTLS_ENTROPY_C) && defined(MBEDTLS_FS_IO)
|
#if defined(MBEDTLS_ENTROPY_C) && defined(MBEDTLS_FS_IO)
|
||||||
#include "mbedtls/entropy.h"
|
#include "mbedtls/entropy.h"
|
||||||
|
@ -49,20 +52,21 @@ int main( void )
|
||||||
int main( int argc, char *argv[] )
|
int main( int argc, char *argv[] )
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
int i, k, ret;
|
int i, k, ret = 1;
|
||||||
|
int exit_code = MBEDTLS_EXIT_FAILURE;
|
||||||
mbedtls_entropy_context entropy;
|
mbedtls_entropy_context entropy;
|
||||||
unsigned char buf[MBEDTLS_ENTROPY_BLOCK_SIZE];
|
unsigned char buf[MBEDTLS_ENTROPY_BLOCK_SIZE];
|
||||||
|
|
||||||
if( argc < 2 )
|
if( argc < 2 )
|
||||||
{
|
{
|
||||||
mbedtls_fprintf( stderr, "usage: %s <output filename>\n", argv[0] );
|
mbedtls_fprintf( stderr, "usage: %s <output filename>\n", argv[0] );
|
||||||
return( 1 );
|
return( exit_code );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( ( f = fopen( argv[1], "wb+" ) ) == NULL )
|
if( ( f = fopen( argv[1], "wb+" ) ) == NULL )
|
||||||
{
|
{
|
||||||
mbedtls_printf( "failed to open '%s' for writing.\n", argv[1] );
|
mbedtls_printf( "failed to open '%s' for writing.\n", argv[1] );
|
||||||
return( 1 );
|
return( exit_code );
|
||||||
}
|
}
|
||||||
|
|
||||||
mbedtls_entropy_init( &entropy );
|
mbedtls_entropy_init( &entropy );
|
||||||
|
@ -72,7 +76,8 @@ int main( int argc, char *argv[] )
|
||||||
ret = mbedtls_entropy_func( &entropy, buf, sizeof( buf ) );
|
ret = mbedtls_entropy_func( &entropy, buf, sizeof( buf ) );
|
||||||
if( ret != 0 )
|
if( ret != 0 )
|
||||||
{
|
{
|
||||||
mbedtls_printf("failed!\n");
|
mbedtls_printf( " failed\n ! mbedtls_entropy_func returned -%04X\n",
|
||||||
|
ret );
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +88,7 @@ int main( int argc, char *argv[] )
|
||||||
fflush( stdout );
|
fflush( stdout );
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = 0;
|
exit_code = MBEDTLS_EXIT_SUCCESS;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
mbedtls_printf( "\n" );
|
mbedtls_printf( "\n" );
|
||||||
|
@ -91,6 +96,6 @@ cleanup:
|
||||||
fclose( f );
|
fclose( f );
|
||||||
mbedtls_entropy_free( &entropy );
|
mbedtls_entropy_free( &entropy );
|
||||||
|
|
||||||
return( ret );
|
return( exit_code );
|
||||||
}
|
}
|
||||||
#endif /* MBEDTLS_ENTROPY_C */
|
#endif /* MBEDTLS_ENTROPY_C */
|
||||||
|
|
Loading…
Reference in a new issue