Merge pull request #3598 from makise-homura/mbedtls-2.16
Backport 2.16: Support building on e2k (Elbrus) architecture
diff --git a/ChangeLog.d/e2k-support.txt b/ChangeLog.d/e2k-support.txt
new file mode 100644
index 0000000..023b188
--- /dev/null
+++ b/ChangeLog.d/e2k-support.txt
@@ -0,0 +1,5 @@
+Features
+ * Support building on e2k (Elbrus) architecture: correctly enable
+ -Wformat-signedness, and fix the code that causes signed-one-bit-field
+ and sign-compare warnings. Contributed by makise-homura (Igor Molchanov)
+ <akemi_homura@kurisa.ch>.
diff --git a/library/ssl_tls.c b/library/ssl_tls.c
index 21682be..f875f62 100644
--- a/library/ssl_tls.c
+++ b/library/ssl_tls.c
@@ -2760,7 +2760,7 @@
if( ret < 0 )
return( ret );
- if ( (size_t)ret > len || ( INT_MAX > SIZE_MAX && ret > SIZE_MAX ) )
+ if ( (size_t)ret > len || ( INT_MAX > SIZE_MAX && ret > (int)SIZE_MAX ) )
{
MBEDTLS_SSL_DEBUG_MSG( 1,
( "f_recv returned %d bytes but only %lu were requested",
@@ -2814,7 +2814,7 @@
if( ret <= 0 )
return( ret );
- if( (size_t)ret > ssl->out_left || ( INT_MAX > SIZE_MAX && ret > SIZE_MAX ) )
+ if( (size_t)ret > ssl->out_left || ( INT_MAX > SIZE_MAX && ret > (int)SIZE_MAX ) )
{
MBEDTLS_SSL_DEBUG_MSG( 1,
( "f_send returned %d bytes but only %lu bytes were sent",
diff --git a/programs/pkey/dh_genprime.c b/programs/pkey/dh_genprime.c
index 1588822..fcfa5b9 100644
--- a/programs/pkey/dh_genprime.c
+++ b/programs/pkey/dh_genprime.c
@@ -116,7 +116,7 @@
{
usage:
mbedtls_printf( USAGE );
- mbedtls_exit( exit_code );
+ goto exit;
}
for( i = 1; i < argc; i++ )
diff --git a/tests/suites/helpers.function b/tests/suites/helpers.function
index f55ad19..d384e44 100644
--- a/tests/suites/helpers.function
+++ b/tests/suites/helpers.function
@@ -244,7 +244,7 @@
/* A compile-time constant with the value 0. If `const_expr` is not a
* compile-time constant with a nonzero value, cause a compile-time error. */
#define STATIC_ASSERT_EXPR( const_expr ) \
- ( 0 && sizeof( struct { int STATIC_ASSERT : 1 - 2 * ! ( const_expr ); } ) )
+ ( 0 && sizeof( struct { unsigned int STATIC_ASSERT : 1 - 2 * ! ( const_expr ); } ) )
/* Return the scalar value `value` (possibly promoted). This is a compile-time
* constant if `value` is. `condition` must be a compile-time constant.
* If `condition` is false, arrange to cause a compile-time error. */