Fix misc issues with unused parameters and check-names.sh
Fix unused parameter warnings when MBEDTLS_TEST_HOOKS is not enabled. A few issues were caught by check-names.sh namely: - mbedtls_error_add was not capitalised. - mbedtls_test_hook_error_add was being defined multiple times as the definition was in a header. Signed-off-by: Chris Jones <christopher.jones@arm.com>
This commit is contained in:
parent
7439209bcc
commit
b7d02e0f15
4 changed files with 23 additions and 16 deletions
|
@ -120,14 +120,14 @@ extern "C" {
|
||||||
* Wrapper function for mbedtls_err_add_ext(). See that function for
|
* Wrapper function for mbedtls_err_add_ext(). See that function for
|
||||||
* more details.
|
* more details.
|
||||||
*/
|
*/
|
||||||
#define mbedtls_error_add( high, low ) \
|
#define MBEDTLS_ERROR_ADD( high, low ) \
|
||||||
mbedtls_error_add_ext( high, low, __FILE__, __LINE__ )
|
mbedtls_error_add_ext( high, low, __FILE__, __LINE__ )
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Testing hook called before adding/combining two error codes together.
|
* \brief Testing hook called before adding/combining two error codes together.
|
||||||
* Only used when invasive testing is enabled via MBEDTLS_TEST_HOOKS.
|
* Only used when invasive testing is enabled via MBEDTLS_TEST_HOOKS.
|
||||||
*/
|
*/
|
||||||
void (*mbedtls_test_hook_error_add)( int, int, const char *, int );
|
extern void (*mbedtls_test_hook_error_add)( int, int, const char *, int );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Combines a high-level and low-level error code together.
|
* \brief Combines a high-level and low-level error code together.
|
||||||
|
@ -150,6 +150,9 @@ static inline int mbedtls_error_add_ext( int high, int low,
|
||||||
if( *mbedtls_test_hook_error_add != NULL )
|
if( *mbedtls_test_hook_error_add != NULL )
|
||||||
( *mbedtls_test_hook_error_add )( high, low, file, line );
|
( *mbedtls_test_hook_error_add )( high, low, file, line );
|
||||||
#endif
|
#endif
|
||||||
|
(void)file;
|
||||||
|
(void)line;
|
||||||
|
|
||||||
return( high + low );
|
return( high + low );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -893,6 +893,8 @@ const char * mbedtls_low_level_strerr( int error_code )
|
||||||
return( NULL );
|
return( NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void (*mbedtls_test_hook_error_add)( int, int, const char *, int );
|
||||||
|
|
||||||
void mbedtls_strerror( int ret, char *buf, size_t buflen )
|
void mbedtls_strerror( int ret, char *buf, size_t buflen )
|
||||||
{
|
{
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
|
@ -102,7 +102,7 @@ int mbedtls_rsa_import( mbedtls_rsa_context *ctx,
|
||||||
( D != NULL && ( ret = mbedtls_mpi_copy( &ctx->D, D ) ) != 0 ) ||
|
( D != NULL && ( ret = mbedtls_mpi_copy( &ctx->D, D ) ) != 0 ) ||
|
||||||
( E != NULL && ( ret = mbedtls_mpi_copy( &ctx->E, E ) ) != 0 ) )
|
( E != NULL && ( ret = mbedtls_mpi_copy( &ctx->E, E ) ) != 0 ) )
|
||||||
{
|
{
|
||||||
return( mbedtls_error_add( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, ret ) );
|
return( MBEDTLS_ERROR_ADD( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, ret ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( N != NULL )
|
if( N != NULL )
|
||||||
|
@ -142,7 +142,7 @@ int mbedtls_rsa_import_raw( mbedtls_rsa_context *ctx,
|
||||||
cleanup:
|
cleanup:
|
||||||
|
|
||||||
if( ret != 0 )
|
if( ret != 0 )
|
||||||
return( mbedtls_error_add( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, ret ) );
|
return( MBEDTLS_ERROR_ADD( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, ret ) );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
@ -293,7 +293,7 @@ int mbedtls_rsa_complete( mbedtls_rsa_context *ctx )
|
||||||
if( ( ret = mbedtls_mpi_mul_mpi( &ctx->N, &ctx->P,
|
if( ( ret = mbedtls_mpi_mul_mpi( &ctx->N, &ctx->P,
|
||||||
&ctx->Q ) ) != 0 )
|
&ctx->Q ) ) != 0 )
|
||||||
{
|
{
|
||||||
return( mbedtls_error_add( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, ret ) );
|
return( MBEDTLS_ERROR_ADD( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, ret ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->len = mbedtls_mpi_size( &ctx->N );
|
ctx->len = mbedtls_mpi_size( &ctx->N );
|
||||||
|
@ -308,7 +308,7 @@ int mbedtls_rsa_complete( mbedtls_rsa_context *ctx )
|
||||||
ret = mbedtls_rsa_deduce_primes( &ctx->N, &ctx->E, &ctx->D,
|
ret = mbedtls_rsa_deduce_primes( &ctx->N, &ctx->E, &ctx->D,
|
||||||
&ctx->P, &ctx->Q );
|
&ctx->P, &ctx->Q );
|
||||||
if( ret != 0 )
|
if( ret != 0 )
|
||||||
return( mbedtls_error_add( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, ret ) );
|
return( MBEDTLS_ERROR_ADD( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, ret ) );
|
||||||
|
|
||||||
}
|
}
|
||||||
else if( d_missing )
|
else if( d_missing )
|
||||||
|
@ -318,7 +318,7 @@ int mbedtls_rsa_complete( mbedtls_rsa_context *ctx )
|
||||||
&ctx->E,
|
&ctx->E,
|
||||||
&ctx->D ) ) != 0 )
|
&ctx->D ) ) != 0 )
|
||||||
{
|
{
|
||||||
return( mbedtls_error_add( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, ret ) );
|
return( MBEDTLS_ERROR_ADD( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, ret ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,7 +333,7 @@ int mbedtls_rsa_complete( mbedtls_rsa_context *ctx )
|
||||||
ret = mbedtls_rsa_deduce_crt( &ctx->P, &ctx->Q, &ctx->D,
|
ret = mbedtls_rsa_deduce_crt( &ctx->P, &ctx->Q, &ctx->D,
|
||||||
&ctx->DP, &ctx->DQ, &ctx->QP );
|
&ctx->DP, &ctx->DQ, &ctx->QP );
|
||||||
if( ret != 0 )
|
if( ret != 0 )
|
||||||
return( mbedtls_error_add( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, ret ) );
|
return( MBEDTLS_ERROR_ADD( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, ret ) );
|
||||||
}
|
}
|
||||||
#endif /* MBEDTLS_RSA_NO_CRT */
|
#endif /* MBEDTLS_RSA_NO_CRT */
|
||||||
|
|
||||||
|
@ -461,13 +461,13 @@ int mbedtls_rsa_export_crt( const mbedtls_rsa_context *ctx,
|
||||||
( DQ != NULL && ( ret = mbedtls_mpi_copy( DQ, &ctx->DQ ) ) != 0 ) ||
|
( DQ != NULL && ( ret = mbedtls_mpi_copy( DQ, &ctx->DQ ) ) != 0 ) ||
|
||||||
( QP != NULL && ( ret = mbedtls_mpi_copy( QP, &ctx->QP ) ) != 0 ) )
|
( QP != NULL && ( ret = mbedtls_mpi_copy( QP, &ctx->QP ) ) != 0 ) )
|
||||||
{
|
{
|
||||||
return( mbedtls_error_add( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, ret ) );
|
return( MBEDTLS_ERROR_ADD( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, ret ) );
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if( ( ret = mbedtls_rsa_deduce_crt( &ctx->P, &ctx->Q, &ctx->D,
|
if( ( ret = mbedtls_rsa_deduce_crt( &ctx->P, &ctx->Q, &ctx->D,
|
||||||
DP, DQ, QP ) ) != 0 )
|
DP, DQ, QP ) ) != 0 )
|
||||||
{
|
{
|
||||||
return( mbedtls_error_add( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, ret ) );
|
return( MBEDTLS_ERROR_ADD( MBEDTLS_ERR_RSA_BAD_INPUT_DATA, ret ) );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -637,7 +637,7 @@ cleanup:
|
||||||
mbedtls_rsa_free( ctx );
|
mbedtls_rsa_free( ctx );
|
||||||
|
|
||||||
if( ( -ret & ~0x7f ) == 0 )
|
if( ( -ret & ~0x7f ) == 0 )
|
||||||
ret = mbedtls_error_add( MBEDTLS_ERR_RSA_KEY_GEN_FAILED, ret );
|
ret = MBEDTLS_ERROR_ADD( MBEDTLS_ERR_RSA_KEY_GEN_FAILED, ret );
|
||||||
return( ret );
|
return( ret );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -770,7 +770,7 @@ cleanup:
|
||||||
mbedtls_mpi_free( &T );
|
mbedtls_mpi_free( &T );
|
||||||
|
|
||||||
if( ret != 0 )
|
if( ret != 0 )
|
||||||
return( mbedtls_error_add( MBEDTLS_ERR_RSA_PUBLIC_FAILED, ret ) );
|
return( MBEDTLS_ERROR_ADD( MBEDTLS_ERR_RSA_PUBLIC_FAILED, ret ) );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
@ -1086,7 +1086,7 @@ cleanup:
|
||||||
mbedtls_mpi_free( &I );
|
mbedtls_mpi_free( &I );
|
||||||
|
|
||||||
if( ret != 0 && ret >= -0x007f )
|
if( ret != 0 && ret >= -0x007f )
|
||||||
return( mbedtls_error_add( MBEDTLS_ERR_RSA_PRIVATE_FAILED, ret ) );
|
return( MBEDTLS_ERROR_ADD( MBEDTLS_ERR_RSA_PRIVATE_FAILED, ret ) );
|
||||||
|
|
||||||
return( ret );
|
return( ret );
|
||||||
}
|
}
|
||||||
|
@ -1199,7 +1199,7 @@ int mbedtls_rsa_rsaes_oaep_encrypt( mbedtls_rsa_context *ctx,
|
||||||
|
|
||||||
/* Generate a random octet string seed */
|
/* Generate a random octet string seed */
|
||||||
if( ( ret = f_rng( p_rng, p, hlen ) ) != 0 )
|
if( ( ret = f_rng( p_rng, p, hlen ) ) != 0 )
|
||||||
return( mbedtls_error_add( MBEDTLS_ERR_RSA_RNG_FAILED, ret ) );
|
return( MBEDTLS_ERROR_ADD( MBEDTLS_ERR_RSA_RNG_FAILED, ret ) );
|
||||||
|
|
||||||
p += hlen;
|
p += hlen;
|
||||||
|
|
||||||
|
@ -1288,7 +1288,7 @@ int mbedtls_rsa_rsaes_pkcs1_v15_encrypt( mbedtls_rsa_context *ctx,
|
||||||
|
|
||||||
/* Check if RNG failed to generate data */
|
/* Check if RNG failed to generate data */
|
||||||
if( rng_dl == 0 || ret != 0 )
|
if( rng_dl == 0 || ret != 0 )
|
||||||
return( mbedtls_error_add( MBEDTLS_ERR_RSA_RNG_FAILED, ret ) );
|
return( MBEDTLS_ERROR_ADD( MBEDTLS_ERR_RSA_RNG_FAILED, ret ) );
|
||||||
|
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
|
@ -1882,7 +1882,7 @@ static int rsa_rsassa_pss_sign( mbedtls_rsa_context *ctx,
|
||||||
/* Generate salt of length slen in place in the encoded message */
|
/* Generate salt of length slen in place in the encoded message */
|
||||||
salt = p;
|
salt = p;
|
||||||
if( ( ret = f_rng( p_rng, salt, slen ) ) != 0 )
|
if( ( ret = f_rng( p_rng, salt, slen ) ) != 0 )
|
||||||
return( mbedtls_error_add( MBEDTLS_ERR_RSA_RNG_FAILED, ret ) );
|
return( MBEDTLS_ERROR_ADD( MBEDTLS_ERR_RSA_RNG_FAILED, ret ) );
|
||||||
|
|
||||||
p += slen;
|
p += slen;
|
||||||
|
|
||||||
|
|
|
@ -82,6 +82,8 @@ LOW_LEVEL_CODE_CHECKS
|
||||||
return( NULL );
|
return( NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void (*mbedtls_test_hook_error_add)( int, int, const char *, int );
|
||||||
|
|
||||||
void mbedtls_strerror( int ret, char *buf, size_t buflen )
|
void mbedtls_strerror( int ret, char *buf, size_t buflen )
|
||||||
{
|
{
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
Loading…
Reference in a new issue