Review corrections 6
-Explicitly discard unnecessary return values of
mbedtls_platform_put_uintXX_be by adding void casting.
diff --git a/library/sha256.c b/library/sha256.c
index d0bf542..98965f7 100644
--- a/library/sha256.c
+++ b/library/sha256.c
@@ -357,8 +357,8 @@
| ( ctx->total[1] << 3 );
low = ( ctx->total[0] << 3 );
- mbedtls_platform_put_uint32_be( ctx->buffer + 56, high );
- mbedtls_platform_put_uint32_be( ctx->buffer + 60, low );
+ (void)mbedtls_platform_put_uint32_be( ctx->buffer + 56, high );
+ (void)mbedtls_platform_put_uint32_be( ctx->buffer + 60, low );
if( ( ret = mbedtls_internal_sha256_process( ctx, ctx->buffer ) ) != 0 )
return( ret );
@@ -369,13 +369,14 @@
for( s_pos = 0, o_pos = 0; s_pos < 7; s_pos++, o_pos += 4 )
{
- mbedtls_platform_put_uint32_be( &output[o_pos], ctx->state[s_pos] );
+ (void)mbedtls_platform_put_uint32_be( &output[o_pos],
+ ctx->state[s_pos] );
}
#if !defined(MBEDTLS_SHA256_NO_SHA224)
if( ctx->is224 == 0 )
#endif
- mbedtls_platform_put_uint32_be( &output[28], ctx->state[7] );
+ (void)mbedtls_platform_put_uint32_be( &output[28], ctx->state[7] );
return( 0 );
}
diff --git a/library/ssl_cli.c b/library/ssl_cli.c
index 425d357..e3aabb7 100644
--- a/library/ssl_cli.c
+++ b/library/ssl_cli.c
@@ -670,9 +670,9 @@
*olen = p - buf;
/* List length = olen - 2 (ext_type) - 2 (ext_len) - 2 (list_len) */
- mbedtls_platform_put_uint16_be( &buf[4], ( *olen - 6 ) );
+ (void)mbedtls_platform_put_uint16_be( &buf[4], ( *olen - 6 ) );
/* Extension length = olen - 2 (ext_type) - 2 (ext_len) */
- mbedtls_platform_put_uint16_be( &buf[2], ( *olen - 4 ) );
+ (void)mbedtls_platform_put_uint16_be( &buf[2], ( *olen - 4 ) );
}
#endif /* MBEDTLS_SSL_ALPN */
@@ -2421,7 +2421,7 @@
defined(MBEDTLS_SSL_PROTO_TLS1_2)
if( len_bytes == 2 )
{
- mbedtls_platform_put_uint16_be( out, *olen );
+ (void)mbedtls_platform_put_uint16_be( out, *olen );
*olen += 2;
}
#endif
@@ -3987,7 +3987,7 @@
return( ret );
}
- mbedtls_platform_put_uint16_be( &ssl->out_msg[4 + offset], n );
+ (void)mbedtls_platform_put_uint16_be( &ssl->out_msg[4 + offset], n );
ssl->out_msglen = 6 + n + offset;
ssl->out_msgtype = MBEDTLS_SSL_MSG_HANDSHAKE;
diff --git a/library/ssl_srv.c b/library/ssl_srv.c
index 902f2fd..3afc565 100644
--- a/library/ssl_srv.c
+++ b/library/ssl_srv.c
@@ -2641,11 +2641,11 @@
* 6 . 6 protocol name length
* 7 . 7+n protocol name
*/
- mbedtls_platform_put_uint16_be( &buf[0], MBEDTLS_TLS_EXT_ALPN );
+ (void)mbedtls_platform_put_uint16_be( &buf[0], MBEDTLS_TLS_EXT_ALPN );
*olen = 7 + strlen( ssl->alpn_chosen );
- mbedtls_platform_put_uint16_be( &buf[2], ( *olen - 4 ) );
- mbedtls_platform_put_uint16_be( &buf[4], ( *olen - 6 ) );
+ (void)mbedtls_platform_put_uint16_be( &buf[2], ( *olen - 4 ) );
+ (void)mbedtls_platform_put_uint16_be( &buf[4], ( *olen - 6 ) );
buf[6] = (unsigned char)( ( ( *olen - 7 ) ) & 0xFF );
@@ -3100,7 +3100,7 @@
}
MBEDTLS_SSL_END_FOR_EACH_SIG_HASH_TLS
- mbedtls_platform_put_uint16_be( p, sa_len );
+ (void)mbedtls_platform_put_uint16_be( p, sa_len );
sa_len += 2;
p += sa_len;
}
@@ -3162,7 +3162,8 @@
ssl->out_msglen = p - buf;
ssl->out_msgtype = MBEDTLS_SSL_MSG_HANDSHAKE;
ssl->out_msg[0] = MBEDTLS_SSL_HS_CERTIFICATE_REQUEST;
- mbedtls_platform_put_uint16_be( &ssl->out_msg[4 + ct_len + sa_len], total_dn_size );
+ (void)mbedtls_platform_put_uint16_be( &ssl->out_msg[4 + ct_len + sa_len],
+ total_dn_size );
ret = mbedtls_ssl_write_handshake_msg( ssl );
@@ -3716,7 +3717,8 @@
#if defined(MBEDTLS_KEY_EXCHANGE__WITH_SERVER_SIGNATURE__ENABLED)
if( signature_len != 0 )
{
- mbedtls_platform_put_uint16_be( &ssl->out_msg[ssl->out_msglen], signature_len );
+ (void)mbedtls_platform_put_uint16_be( &ssl->out_msg[ssl->out_msglen],
+ signature_len );
ssl->out_msglen += 2;
MBEDTLS_SSL_DEBUG_BUF( 3, "my signature",
@@ -4658,9 +4660,9 @@
MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_ticket_write", ret );
tlen = 0;
}
- mbedtls_platform_put_uint32_be( &ssl->out_msg[4], lifetime );
+ (void)mbedtls_platform_put_uint32_be( &ssl->out_msg[4], lifetime );
- mbedtls_platform_put_uint16_be( &ssl->out_msg[8], tlen );
+ (void)mbedtls_platform_put_uint16_be( &ssl->out_msg[8], tlen );
ssl->out_msglen = 10 + tlen;
/*
diff --git a/library/ssl_ticket.c b/library/ssl_ticket.c
index 69e14cf..285e736 100644
--- a/library/ssl_ticket.c
+++ b/library/ssl_ticket.c
@@ -222,7 +222,7 @@
goto cleanup;
}
- mbedtls_platform_put_uint16_be( state_len_bytes, clear_len );
+ (void)mbedtls_platform_put_uint16_be( state_len_bytes, clear_len );
/* Encrypt and authenticate */
tag = state + clear_len;
diff --git a/library/ssl_tls.c b/library/ssl_tls.c
index c9d4064..cf6ef12 100644
--- a/library/ssl_tls.c
+++ b/library/ssl_tls.c
@@ -2236,7 +2236,7 @@
memcpy( header, ctr, 8 );
header[8] = (unsigned char) type;
- mbedtls_platform_put_uint16_be( &header[9], len );
+ (void)mbedtls_platform_put_uint16_be( &header[9], len );
memset( padding, 0x36, padlen );
mbedtls_md_starts( md_ctx );
@@ -2388,13 +2388,14 @@
{
memcpy( add_data + 11, rec->cid, rec->cid_len );
add_data[11 + rec->cid_len + 0] = rec->cid_len;
- mbedtls_platform_put_uint16_be( &add_data[11 + rec->cid_len + 1], rec->data_len );
+ (void)mbedtls_platform_put_uint16_be( &add_data[11 + rec->cid_len + 1],
+ rec->data_len );
*add_data_len = 13 + 1 + rec->cid_len;
}
else
#endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID */
{
- mbedtls_platform_put_uint16_be( &add_data[11], rec->data_len );
+ (void)mbedtls_platform_put_uint16_be( &add_data[11], rec->data_len );
*add_data_len = 13;
}
}
@@ -4142,8 +4143,9 @@
* Handshake headers: type(1) len(3) seq(2) f_off(3) f_len(3) */
memcpy( ssl->out_msg, cur->p, 6 );
- mbedtls_platform_put_uint24_be( &ssl->out_msg[6], frag_off );
- mbedtls_platform_put_uint24_be( &ssl->out_msg[9], cur_hs_frag_len );
+ (void)mbedtls_platform_put_uint24_be( &ssl->out_msg[6], frag_off );
+ (void)mbedtls_platform_put_uint24_be( &ssl->out_msg[9],
+ cur_hs_frag_len );
MBEDTLS_SSL_DEBUG_BUF( 3, "handshake header", ssl->out_msg, 12 );
@@ -4340,7 +4342,7 @@
*/
if( ssl->out_msgtype == MBEDTLS_SSL_MSG_HANDSHAKE )
{
- mbedtls_platform_put_uint24_be( &ssl->out_msg[1], hs_len );
+ (void)mbedtls_platform_put_uint24_be( &ssl->out_msg[1], hs_len );
/*
* DTLS has additional fields in the Handshake layer,
@@ -4368,7 +4370,8 @@
/* Write message_seq and update it, except for HelloRequest */
if( hs_type != MBEDTLS_SSL_HS_HELLO_REQUEST )
{
- mbedtls_platform_put_uint16_be( &ssl->out_msg[4], ssl->handshake->out_msg_seq );
+ (void)mbedtls_platform_put_uint16_be( &ssl->out_msg[4],
+ ssl->handshake->out_msg_seq );
++( ssl->handshake->out_msg_seq );
}
else
@@ -4479,7 +4482,7 @@
ssl->conf->transport, ssl->out_hdr + 1 );
memcpy( ssl->out_ctr, ssl->cur_out_ctr, 8 );
- mbedtls_platform_put_uint16_be( ssl->out_len, len );
+ (void)mbedtls_platform_put_uint16_be( ssl->out_len, len );
if( ssl->transform_out != NULL )
{
@@ -4522,7 +4525,7 @@
memcpy( ssl->out_cid, rec.cid, rec.cid_len );
#endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID */
ssl->out_msglen = len = rec.data_len;
- mbedtls_platform_put_uint16_be( ssl->out_len, rec.data_len );
+ (void)mbedtls_platform_put_uint16_be( ssl->out_len, rec.data_len );
}
protected_record_size = len + mbedtls_ssl_out_hdr_len( ssl );
@@ -5081,12 +5084,12 @@
/* Go back and fill length fields */
obuf[27] = (unsigned char)( *olen - 28 );
- mbedtls_platform_put_uint24_be( &obuf[14], ( *olen - 25 ) );
+ (void)mbedtls_platform_put_uint24_be( &obuf[14], ( *olen - 25 ) );
obuf[22] = obuf[14];
obuf[23] = obuf[15];
obuf[24] = obuf[16];
- mbedtls_platform_put_uint16_be( &obuf[11], ( *olen - 13 ) );
+ (void)mbedtls_platform_put_uint16_be( &obuf[11], ( *olen - 13 ) );
return( MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED );
}
@@ -6474,7 +6477,7 @@
ssl->in_hdr[0] = rec.type;
ssl->in_msg = rec.buf + rec.data_offset;
ssl->in_msglen = rec.data_len;
- mbedtls_platform_put_uint16_be( ssl->in_len, rec.data_len );
+ (void)mbedtls_platform_put_uint16_be( ssl->in_len, rec.data_len );
return( 0 );
}
@@ -6806,13 +6809,13 @@
return( MBEDTLS_ERR_SSL_CERTIFICATE_TOO_LARGE );
}
- mbedtls_platform_put_uint24_be( &ssl->out_msg[i], n );
+ (void)mbedtls_platform_put_uint24_be( &ssl->out_msg[i], n );
i += 3; memcpy( ssl->out_msg + i, crt->raw.p, n );
i += n; crt = crt->next;
}
- mbedtls_platform_put_uint24_be( &ssl->out_msg[4], ( i - 7 ) );
+ (void)mbedtls_platform_put_uint24_be( &ssl->out_msg[4], ( i - 7 ) );
ssl->out_msglen = i;
ssl->out_msgtype = MBEDTLS_SSL_MSG_HANDSHAKE;