Remove a few redundant memset after calloc.

Using the following semantic patch provided by Mansour Moufid:

@@
expression x;
@@
  x = mbedtls_calloc(...)
  ...
- memset(x, 0, ...);
This commit is contained in:
Manuel Pégourié-Gonnard 2015-05-27 16:49:37 +02:00
parent b2a18a2a98
commit 1b8de57827
8 changed files with 1 additions and 17 deletions

View File

@ -66,6 +66,7 @@ API Changes
* Signature of mpi_mul_mpi() changed to make the last argument unsigned * Signature of mpi_mul_mpi() changed to make the last argument unsigned
* calloc() is now used instead of malloc() everywhere. API of platform * calloc() is now used instead of malloc() everywhere. API of platform
layer and the memory_buffer_alloc module changed accordingly. layer and the memory_buffer_alloc module changed accordingly.
(Thanks to Mansour Moufid for helping with the replacement.)
* Change SSL_DISABLE_RENEGOTIATION config.h flag to SSL_RENEGOTIATION * Change SSL_DISABLE_RENEGOTIATION config.h flag to SSL_RENEGOTIATION
(support for renegotiation now needs explicit enabling in config.h). (support for renegotiation now needs explicit enabling in config.h).
* net_connect() and net_bind() have a new 'proto' argument to choose * net_connect() and net_bind() have a new 'proto' argument to choose

View File

@ -275,8 +275,6 @@ int mbedtls_asn1_get_sequence_of( unsigned char **p,
if( cur->next == NULL ) if( cur->next == NULL )
return( MBEDTLS_ERR_ASN1_MALLOC_FAILED ); return( MBEDTLS_ERR_ASN1_MALLOC_FAILED );
memset( cur->next, 0, sizeof( mbedtls_asn1_sequence ) );
cur = cur->next; cur = cur->next;
} }
} }

View File

@ -316,8 +316,6 @@ mbedtls_asn1_named_data *mbedtls_asn1_store_named_data( mbedtls_asn1_named_data
if( ( cur = mbedtls_calloc( 1, sizeof(mbedtls_asn1_named_data) ) ) == NULL ) if( ( cur = mbedtls_calloc( 1, sizeof(mbedtls_asn1_named_data) ) ) == NULL )
return( NULL ); return( NULL );
memset( cur, 0, sizeof(mbedtls_asn1_named_data) );
cur->oid.len = oid_len; cur->oid.len = oid_len;
cur->oid.p = mbedtls_calloc( 1, oid_len ); cur->oid.p = mbedtls_calloc( 1, oid_len );
if( cur->oid.p == NULL ) if( cur->oid.p == NULL )

View File

@ -229,8 +229,6 @@ int mbedtls_ssl_cache_set( void *data, const mbedtls_ssl_session *session )
goto exit; goto exit;
} }
memset( cur, 0, sizeof(mbedtls_ssl_cache_entry) );
if( prv == NULL ) if( prv == NULL )
cache->chain = cur; cache->chain = cur;
else else

View File

@ -2931,8 +2931,6 @@ static int ssl_reassemble_dtls_handshake( mbedtls_ssl_context *ssl )
return( MBEDTLS_ERR_SSL_MALLOC_FAILED ); return( MBEDTLS_ERR_SSL_MALLOC_FAILED );
} }
memset( ssl->handshake->hs_msg, 0, alloc_len );
/* Prepare final header: copy msg_type, length and message_seq, /* Prepare final header: copy msg_type, length and message_seq,
* then add standardised fragment_offset and fragment_length */ * then add standardised fragment_offset and fragment_length */
memcpy( ssl->handshake->hs_msg, ssl->in_msg, 6 ); memcpy( ssl->handshake->hs_msg, ssl->in_msg, 6 );
@ -5011,9 +5009,6 @@ int mbedtls_ssl_setup( mbedtls_ssl_context *ssl,
return( MBEDTLS_ERR_SSL_MALLOC_FAILED ); return( MBEDTLS_ERR_SSL_MALLOC_FAILED );
} }
memset( ssl-> in_buf, 0, len );
memset( ssl->out_buf, 0, len );
#if defined(MBEDTLS_SSL_PROTO_DTLS) #if defined(MBEDTLS_SSL_PROTO_DTLS)
if( conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM ) if( conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM )
{ {

View File

@ -457,8 +457,6 @@ int mbedtls_x509_get_name( unsigned char **p, const unsigned char *end,
if( cur->next == NULL ) if( cur->next == NULL )
return( MBEDTLS_ERR_X509_MALLOC_FAILED ); return( MBEDTLS_ERR_X509_MALLOC_FAILED );
memset( cur->next, 0, sizeof( mbedtls_x509_name ) );
cur = cur->next; cur = cur->next;
} }
@ -473,8 +471,6 @@ int mbedtls_x509_get_name( unsigned char **p, const unsigned char *end,
if( cur->next == NULL ) if( cur->next == NULL )
return( MBEDTLS_ERR_X509_MALLOC_FAILED ); return( MBEDTLS_ERR_X509_MALLOC_FAILED );
memset( cur->next, 0, sizeof( mbedtls_x509_name ) );
cur = cur->next; cur = cur->next;
} }
} }

View File

@ -243,7 +243,6 @@ static int x509_get_entries( unsigned char **p,
if( cur_entry->next == NULL ) if( cur_entry->next == NULL )
return( MBEDTLS_ERR_X509_MALLOC_FAILED ); return( MBEDTLS_ERR_X509_MALLOC_FAILED );
memset( cur_entry->next, 0, sizeof( mbedtls_x509_crl_entry ) );
cur_entry = cur_entry->next; cur_entry = cur_entry->next;
} }
} }

View File

@ -365,7 +365,6 @@ static int x509_get_subject_alt_name( unsigned char **p,
return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS + return( MBEDTLS_ERR_X509_INVALID_EXTENSIONS +
MBEDTLS_ERR_ASN1_MALLOC_FAILED ); MBEDTLS_ERR_ASN1_MALLOC_FAILED );
memset( cur->next, 0, sizeof( mbedtls_asn1_sequence ) );
cur = cur->next; cur = cur->next;
} }