diff --git a/library/alignment.h b/library/alignment.h index dedfdc9e7..e7f11da40 100644 --- a/library/alignment.h +++ b/library/alignment.h @@ -33,10 +33,10 @@ * \param p pointer to 4 bytes of data * \return Data at the given address */ -inline uint32_t mbedtls_get_unaligned_uint32( void const *p ) +inline uint32_t mbedtls_get_unaligned_uint32( const void *p ) { uint32_t r; - memcpy( &r, p, 4 ); + memcpy( &r, p, sizeof( r ) ); return r; } @@ -49,7 +49,7 @@ inline uint32_t mbedtls_get_unaligned_uint32( void const *p ) */ inline void mbedtls_put_unaligned_uint32( void *p, uint32_t x ) { - memcpy( p, &x, 4 ); + memcpy( p, &x, sizeof( x ) ); } /** Byte Reading Macros diff --git a/library/common.h b/library/common.h index c17506416..2cc44fb71 100644 --- a/library/common.h +++ b/library/common.h @@ -86,7 +86,7 @@ extern void (*mbedtls_test_hook_test_fail)( const char * test, int line, const c * \param b Pointer to input (buffer of at least \p n bytes) * \param n Number of bytes to process. */ -inline void mbedtls_xor( unsigned char *r, unsigned char const *a, unsigned char const *b, size_t n ) +inline void mbedtls_xor( unsigned char *r, const unsigned char *a, const unsigned char *b, size_t n ) { size_t i; for ( i = 0; ( i + 4 ) <= n; i += 4 ) diff --git a/tests/suites/test_suite_common.function b/tests/suites/test_suite_common.function index c8a7a52ab..4444a52ce 100644 --- a/tests/suites/test_suite_common.function +++ b/tests/suites/test_suite_common.function @@ -82,9 +82,9 @@ void mbedtls_xor( int len ) ASSERT_COMPARE( r1 + r_off, n, r2 + r_off, n ); } exit: - if ( a != NULL ) mbedtls_free( a ); - if ( a != NULL ) mbedtls_free( b ); - if ( r1 != NULL ) mbedtls_free( r1 ); - if ( r2 != NULL ) mbedtls_free( r2 ); + mbedtls_free( a ); + mbedtls_free( b ); + mbedtls_free( r1 ); + mbedtls_free( r2 ); } /* END_CASE */