Merge pull request #4306 from daverodgman/fix_mps_trace_macros
Capitalise MPS trace macros
This commit is contained in:
commit
6741fc9148
5 changed files with 33 additions and 33 deletions
|
@ -104,7 +104,7 @@
|
||||||
{ \
|
{ \
|
||||||
if( !(cond) ) \
|
if( !(cond) ) \
|
||||||
{ \
|
{ \
|
||||||
MBEDTLS_MPS_TRACE( mbedtls_mps_trace_error, string ); \
|
MBEDTLS_MPS_TRACE( MBEDTLS_MPS_TRACE_TYPE_ERROR, string ); \
|
||||||
MBEDTLS_MPS_TRACE_RETURN( MBEDTLS_ERR_MPS_OPERATION_UNEXPECTED ); \
|
MBEDTLS_MPS_TRACE_RETURN( MBEDTLS_ERR_MPS_OPERATION_UNEXPECTED ); \
|
||||||
} \
|
} \
|
||||||
} while( 0 )
|
} while( 0 )
|
||||||
|
@ -126,7 +126,7 @@
|
||||||
{ \
|
{ \
|
||||||
if( !(cond) ) \
|
if( !(cond) ) \
|
||||||
{ \
|
{ \
|
||||||
MBEDTLS_MPS_TRACE( mbedtls_mps_trace_error, string ); \
|
MBEDTLS_MPS_TRACE( MBEDTLS_MPS_TRACE_TYPE_ERROR, string ); \
|
||||||
MBEDTLS_MPS_TRACE_RETURN( MBEDTLS_ERR_MPS_INTERNAL_ERROR ); \
|
MBEDTLS_MPS_TRACE_RETURN( MBEDTLS_ERR_MPS_INTERNAL_ERROR ); \
|
||||||
} \
|
} \
|
||||||
} while( 0 )
|
} while( 0 )
|
||||||
|
|
|
@ -146,7 +146,7 @@ int mbedtls_mps_reader_init( mbedtls_mps_reader *rd,
|
||||||
mbedtls_mps_size_t acc_len )
|
mbedtls_mps_size_t acc_len )
|
||||||
{
|
{
|
||||||
MBEDTLS_MPS_TRACE_INIT( "mbedtls_mps_reader_init" );
|
MBEDTLS_MPS_TRACE_INIT( "mbedtls_mps_reader_init" );
|
||||||
MBEDTLS_MPS_TRACE( mbedtls_mps_trace_comment,
|
MBEDTLS_MPS_TRACE( MBEDTLS_MPS_TRACE_TYPE_COMMENT,
|
||||||
"* Accumulator size: %u bytes", (unsigned) acc_len );
|
"* Accumulator size: %u bytes", (unsigned) acc_len );
|
||||||
mps_reader_zero( rd );
|
mps_reader_zero( rd );
|
||||||
rd->acc = acc;
|
rd->acc = acc;
|
||||||
|
@ -167,7 +167,7 @@ int mbedtls_mps_reader_feed( mbedtls_mps_reader *rd,
|
||||||
{
|
{
|
||||||
mbedtls_mps_size_t copy_to_acc;
|
mbedtls_mps_size_t copy_to_acc;
|
||||||
MBEDTLS_MPS_TRACE_INIT( "mbedtls_mps_reader_feed" );
|
MBEDTLS_MPS_TRACE_INIT( "mbedtls_mps_reader_feed" );
|
||||||
MBEDTLS_MPS_TRACE( mbedtls_mps_trace_comment,
|
MBEDTLS_MPS_TRACE( MBEDTLS_MPS_TRACE_TYPE_COMMENT,
|
||||||
"* Fragment length: %u bytes", (unsigned) new_frag_len );
|
"* Fragment length: %u bytes", (unsigned) new_frag_len );
|
||||||
|
|
||||||
if( new_frag == NULL )
|
if( new_frag == NULL )
|
||||||
|
@ -192,7 +192,7 @@ int mbedtls_mps_reader_feed( mbedtls_mps_reader *rd,
|
||||||
/* Copy new contents to accumulator. */
|
/* Copy new contents to accumulator. */
|
||||||
memcpy( acc, new_frag, copy_to_acc );
|
memcpy( acc, new_frag, copy_to_acc );
|
||||||
|
|
||||||
MBEDTLS_MPS_TRACE( mbedtls_mps_trace_comment,
|
MBEDTLS_MPS_TRACE( MBEDTLS_MPS_TRACE_TYPE_COMMENT,
|
||||||
"Copy new data of size %u of %u into accumulator at offset %u",
|
"Copy new data of size %u of %u into accumulator at offset %u",
|
||||||
(unsigned) copy_to_acc, (unsigned) new_frag_len, (unsigned) acc_available );
|
(unsigned) copy_to_acc, (unsigned) new_frag_len, (unsigned) acc_available );
|
||||||
|
|
||||||
|
@ -209,7 +209,7 @@ int mbedtls_mps_reader_feed( mbedtls_mps_reader *rd,
|
||||||
|
|
||||||
/* We have filled the accumulator: Move to consuming mode. */
|
/* We have filled the accumulator: Move to consuming mode. */
|
||||||
|
|
||||||
MBEDTLS_MPS_TRACE( mbedtls_mps_trace_comment,
|
MBEDTLS_MPS_TRACE( MBEDTLS_MPS_TRACE_TYPE_COMMENT,
|
||||||
"Enough data available to serve user request" );
|
"Enough data available to serve user request" );
|
||||||
|
|
||||||
/* Remember overlap of accumulator and fragment. */
|
/* Remember overlap of accumulator and fragment. */
|
||||||
|
@ -238,7 +238,7 @@ int mbedtls_mps_reader_get( mbedtls_mps_reader *rd,
|
||||||
unsigned char *frag;
|
unsigned char *frag;
|
||||||
mbedtls_mps_size_t frag_len, frag_offset, end, frag_fetched, frag_remaining;
|
mbedtls_mps_size_t frag_len, frag_offset, end, frag_fetched, frag_remaining;
|
||||||
MBEDTLS_MPS_TRACE_INIT( "mbedtls_mps_reader_get" );
|
MBEDTLS_MPS_TRACE_INIT( "mbedtls_mps_reader_get" );
|
||||||
MBEDTLS_MPS_TRACE( mbedtls_mps_trace_comment,
|
MBEDTLS_MPS_TRACE( MBEDTLS_MPS_TRACE_TYPE_COMMENT,
|
||||||
"* Bytes requested: %u", (unsigned) desired );
|
"* Bytes requested: %u", (unsigned) desired );
|
||||||
|
|
||||||
MBEDTLS_MPS_STATE_VALIDATE_RAW( mps_reader_is_consuming( rd ),
|
MBEDTLS_MPS_STATE_VALIDATE_RAW( mps_reader_is_consuming( rd ),
|
||||||
|
@ -315,7 +315,7 @@ int mbedtls_mps_reader_get( mbedtls_mps_reader *rd,
|
||||||
|
|
||||||
unsigned char *acc;
|
unsigned char *acc;
|
||||||
|
|
||||||
MBEDTLS_MPS_TRACE( mbedtls_mps_trace_comment,
|
MBEDTLS_MPS_TRACE( MBEDTLS_MPS_TRACE_TYPE_COMMENT,
|
||||||
"Serve the request from the accumulator" );
|
"Serve the request from the accumulator" );
|
||||||
if( frag_offset - end < desired )
|
if( frag_offset - end < desired )
|
||||||
{
|
{
|
||||||
|
@ -353,7 +353,7 @@ int mbedtls_mps_reader_get( mbedtls_mps_reader *rd,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Attempt to serve the request from the current fragment */
|
/* Attempt to serve the request from the current fragment */
|
||||||
MBEDTLS_MPS_TRACE( mbedtls_mps_trace_comment,
|
MBEDTLS_MPS_TRACE( MBEDTLS_MPS_TRACE_TYPE_COMMENT,
|
||||||
"Serve the request from the current fragment." );
|
"Serve the request from the current fragment." );
|
||||||
|
|
||||||
frag_len = rd->frag_len;
|
frag_len = rd->frag_len;
|
||||||
|
@ -365,7 +365,7 @@ int mbedtls_mps_reader_get( mbedtls_mps_reader *rd,
|
||||||
/* Check if we can serve the read request from the fragment. */
|
/* Check if we can serve the read request from the fragment. */
|
||||||
if( frag_remaining < desired )
|
if( frag_remaining < desired )
|
||||||
{
|
{
|
||||||
MBEDTLS_MPS_TRACE( mbedtls_mps_trace_comment,
|
MBEDTLS_MPS_TRACE( MBEDTLS_MPS_TRACE_TYPE_COMMENT,
|
||||||
"There's not enough data in the current fragment "
|
"There's not enough data in the current fragment "
|
||||||
"to serve the request." );
|
"to serve the request." );
|
||||||
/* There's not enough data in the current fragment,
|
/* There's not enough data in the current fragment,
|
||||||
|
@ -375,7 +375,7 @@ int mbedtls_mps_reader_get( mbedtls_mps_reader *rd,
|
||||||
if( frag_remaining > 0 )
|
if( frag_remaining > 0 )
|
||||||
{
|
{
|
||||||
rd->pending = desired - frag_remaining;
|
rd->pending = desired - frag_remaining;
|
||||||
MBEDTLS_MPS_TRACE( mbedtls_mps_trace_comment,
|
MBEDTLS_MPS_TRACE( MBEDTLS_MPS_TRACE_TYPE_COMMENT,
|
||||||
"Remember to collect %u bytes before re-opening",
|
"Remember to collect %u bytes before re-opening",
|
||||||
(unsigned) rd->pending );
|
(unsigned) rd->pending );
|
||||||
}
|
}
|
||||||
|
@ -438,13 +438,13 @@ int mbedtls_mps_reader_reclaim( mbedtls_mps_reader *rd,
|
||||||
|
|
||||||
if( pending == 0 )
|
if( pending == 0 )
|
||||||
{
|
{
|
||||||
MBEDTLS_MPS_TRACE( mbedtls_mps_trace_comment,
|
MBEDTLS_MPS_TRACE( MBEDTLS_MPS_TRACE_TYPE_COMMENT,
|
||||||
"No unsatisfied read-request has been logged." );
|
"No unsatisfied read-request has been logged." );
|
||||||
|
|
||||||
/* Check if there's data left to be consumed. */
|
/* Check if there's data left to be consumed. */
|
||||||
if( commit < frag_offset || commit - frag_offset < frag_len )
|
if( commit < frag_offset || commit - frag_offset < frag_len )
|
||||||
{
|
{
|
||||||
MBEDTLS_MPS_TRACE( mbedtls_mps_trace_comment,
|
MBEDTLS_MPS_TRACE( MBEDTLS_MPS_TRACE_TYPE_COMMENT,
|
||||||
"There is data left to be consumed." );
|
"There is data left to be consumed." );
|
||||||
rd->end = commit;
|
rd->end = commit;
|
||||||
MBEDTLS_MPS_TRACE_RETURN( MBEDTLS_ERR_MPS_READER_DATA_LEFT );
|
MBEDTLS_MPS_TRACE_RETURN( MBEDTLS_ERR_MPS_READER_DATA_LEFT );
|
||||||
|
@ -453,7 +453,7 @@ int mbedtls_mps_reader_reclaim( mbedtls_mps_reader *rd,
|
||||||
rd->acc_available = 0;
|
rd->acc_available = 0;
|
||||||
rd->acc_share.acc_remaining = 0;
|
rd->acc_share.acc_remaining = 0;
|
||||||
|
|
||||||
MBEDTLS_MPS_TRACE( mbedtls_mps_trace_comment,
|
MBEDTLS_MPS_TRACE( MBEDTLS_MPS_TRACE_TYPE_COMMENT,
|
||||||
"Fragment has been fully processed and committed." );
|
"Fragment has been fully processed and committed." );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -468,13 +468,13 @@ int mbedtls_mps_reader_reclaim( mbedtls_mps_reader *rd,
|
||||||
mbedtls_mps_size_t backup_len;
|
mbedtls_mps_size_t backup_len;
|
||||||
mbedtls_mps_size_t acc_len_needed;
|
mbedtls_mps_size_t acc_len_needed;
|
||||||
|
|
||||||
MBEDTLS_MPS_TRACE( mbedtls_mps_trace_comment,
|
MBEDTLS_MPS_TRACE( MBEDTLS_MPS_TRACE_TYPE_COMMENT,
|
||||||
"There has been an unsatisfied read with %u bytes overhead.",
|
"There has been an unsatisfied read with %u bytes overhead.",
|
||||||
(unsigned) pending );
|
(unsigned) pending );
|
||||||
|
|
||||||
if( acc == NULL )
|
if( acc == NULL )
|
||||||
{
|
{
|
||||||
MBEDTLS_MPS_TRACE( mbedtls_mps_trace_comment,
|
MBEDTLS_MPS_TRACE( MBEDTLS_MPS_TRACE_TYPE_COMMENT,
|
||||||
"No accumulator present" );
|
"No accumulator present" );
|
||||||
MBEDTLS_MPS_TRACE_RETURN(
|
MBEDTLS_MPS_TRACE_RETURN(
|
||||||
MBEDTLS_ERR_MPS_READER_NEED_ACCUMULATOR );
|
MBEDTLS_ERR_MPS_READER_NEED_ACCUMULATOR );
|
||||||
|
@ -514,11 +514,11 @@ int mbedtls_mps_reader_reclaim( mbedtls_mps_reader *rd,
|
||||||
* since the last commit. */
|
* since the last commit. */
|
||||||
rd->end = commit;
|
rd->end = commit;
|
||||||
rd->pending = 0;
|
rd->pending = 0;
|
||||||
MBEDTLS_MPS_TRACE( mbedtls_mps_trace_error,
|
MBEDTLS_MPS_TRACE( MBEDTLS_MPS_TRACE_TYPE_ERROR,
|
||||||
"The accumulator is too small to handle the backup." );
|
"The accumulator is too small to handle the backup." );
|
||||||
MBEDTLS_MPS_TRACE( mbedtls_mps_trace_error,
|
MBEDTLS_MPS_TRACE( MBEDTLS_MPS_TRACE_TYPE_ERROR,
|
||||||
"* Size: %u", (unsigned) acc_len );
|
"* Size: %u", (unsigned) acc_len );
|
||||||
MBEDTLS_MPS_TRACE( mbedtls_mps_trace_error,
|
MBEDTLS_MPS_TRACE( MBEDTLS_MPS_TRACE_TYPE_ERROR,
|
||||||
"* Needed: %u (%u + %u)",
|
"* Needed: %u (%u + %u)",
|
||||||
(unsigned) acc_len_needed,
|
(unsigned) acc_len_needed,
|
||||||
(unsigned) backup_len, (unsigned) pending );
|
(unsigned) backup_len, (unsigned) pending );
|
||||||
|
@ -526,9 +526,9 @@ int mbedtls_mps_reader_reclaim( mbedtls_mps_reader *rd,
|
||||||
MBEDTLS_ERR_MPS_READER_ACCUMULATOR_TOO_SMALL );
|
MBEDTLS_ERR_MPS_READER_ACCUMULATOR_TOO_SMALL );
|
||||||
}
|
}
|
||||||
|
|
||||||
MBEDTLS_MPS_TRACE( mbedtls_mps_trace_comment,
|
MBEDTLS_MPS_TRACE( MBEDTLS_MPS_TRACE_TYPE_COMMENT,
|
||||||
"Fragment backup: %u", (unsigned) frag_backup_len );
|
"Fragment backup: %u", (unsigned) frag_backup_len );
|
||||||
MBEDTLS_MPS_TRACE( mbedtls_mps_trace_comment,
|
MBEDTLS_MPS_TRACE( MBEDTLS_MPS_TRACE_TYPE_COMMENT,
|
||||||
"Accumulator backup: %u", (unsigned) acc_backup_len );
|
"Accumulator backup: %u", (unsigned) acc_backup_len );
|
||||||
|
|
||||||
/* Move uncommitted parts from the accumulator to the front
|
/* Move uncommitted parts from the accumulator to the front
|
||||||
|
@ -554,7 +554,7 @@ int mbedtls_mps_reader_reclaim( mbedtls_mps_reader *rd,
|
||||||
rd->end = 0;
|
rd->end = 0;
|
||||||
rd->pending = 0;
|
rd->pending = 0;
|
||||||
|
|
||||||
MBEDTLS_MPS_TRACE( mbedtls_mps_trace_comment,
|
MBEDTLS_MPS_TRACE( MBEDTLS_MPS_TRACE_TYPE_COMMENT,
|
||||||
"Final state: aa %u, al %u, ar %u",
|
"Final state: aa %u, al %u, ar %u",
|
||||||
(unsigned) rd->acc_available, (unsigned) rd->acc_len,
|
(unsigned) rd->acc_available, (unsigned) rd->acc_len,
|
||||||
(unsigned) rd->acc_share.acc_remaining );
|
(unsigned) rd->acc_share.acc_remaining );
|
||||||
|
|
|
@ -102,19 +102,19 @@ void mbedtls_mps_trace_indent( int level, mbedtls_mps_trace_type ty )
|
||||||
|
|
||||||
switch( ty )
|
switch( ty )
|
||||||
{
|
{
|
||||||
case mbedtls_mps_trace_comment:
|
case MBEDTLS_MPS_TRACE_TYPE_COMMENT:
|
||||||
mbedtls_printf( "@ " );
|
mbedtls_printf( "@ " );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case mbedtls_mps_trace_call:
|
case MBEDTLS_MPS_TRACE_TYPE_CALL:
|
||||||
mbedtls_printf( "+--> " );
|
mbedtls_printf( "+--> " );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case mbedtls_mps_trace_error:
|
case MBEDTLS_MPS_TRACE_TYPE_ERROR:
|
||||||
mbedtls_printf( "E " );
|
mbedtls_printf( "E " );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case mbedtls_mps_trace_return:
|
case MBEDTLS_MPS_TRACE_TYPE_RETURN:
|
||||||
mbedtls_printf( "< " );
|
mbedtls_printf( "< " );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -60,10 +60,10 @@
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
mbedtls_mps_trace_comment,
|
MBEDTLS_MPS_TRACE_TYPE_COMMENT,
|
||||||
mbedtls_mps_trace_call,
|
MBEDTLS_MPS_TRACE_TYPE_CALL,
|
||||||
mbedtls_mps_trace_error,
|
MBEDTLS_MPS_TRACE_TYPE_ERROR,
|
||||||
mbedtls_mps_trace_return
|
MBEDTLS_MPS_TRACE_TYPE_RETURN
|
||||||
} mbedtls_mps_trace_type;
|
} mbedtls_mps_trace_type;
|
||||||
|
|
||||||
#define MBEDTLS_MPS_TRACE_BIT_LAYER_1 1
|
#define MBEDTLS_MPS_TRACE_BIT_LAYER_1 1
|
||||||
|
@ -141,7 +141,7 @@ void mbedtls_mps_trace_print_msg( int id, int line, const char *format, ... );
|
||||||
do { \
|
do { \
|
||||||
if( ! ( MBEDTLS_MPS_TRACE_MASK & ( 1u << mbedtls_mps_trace_id ) ) ) \
|
if( ! ( MBEDTLS_MPS_TRACE_MASK & ( 1u << mbedtls_mps_trace_id ) ) ) \
|
||||||
break; \
|
break; \
|
||||||
MBEDTLS_MPS_TRACE( mbedtls_mps_trace_call, __VA_ARGS__ ); \
|
MBEDTLS_MPS_TRACE( MBEDTLS_MPS_TRACE_TYPE_CALL, __VA_ARGS__ ); \
|
||||||
mbedtls_mps_trace_inc_depth(); \
|
mbedtls_mps_trace_inc_depth(); \
|
||||||
} while( 0 )
|
} while( 0 )
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ void mbedtls_mps_trace_print_msg( int id, int line, const char *format, ... );
|
||||||
do { \
|
do { \
|
||||||
if( ! ( MBEDTLS_MPS_TRACE_MASK & ( 1u << mbedtls_mps_trace_id ) ) ) \
|
if( ! ( MBEDTLS_MPS_TRACE_MASK & ( 1u << mbedtls_mps_trace_id ) ) ) \
|
||||||
break; \
|
break; \
|
||||||
MBEDTLS_MPS_TRACE( mbedtls_mps_trace_return, "%d (-%#04x)", \
|
MBEDTLS_MPS_TRACE( MBEDTLS_MPS_TRACE_TYPE_RETURN, "%d (-%#04x)", \
|
||||||
(int) (val), -((unsigned)(val)) ); \
|
(int) (val), -((unsigned)(val)) ); \
|
||||||
mbedtls_mps_trace_dec_depth(); \
|
mbedtls_mps_trace_dec_depth(); \
|
||||||
} while( 0 )
|
} while( 0 )
|
||||||
|
|
|
@ -26,7 +26,7 @@ use open qw(:std utf8);
|
||||||
@ARGV = grep { ! /compat-1\.3\.h/ } <include/mbedtls/*.h>;
|
@ARGV = grep { ! /compat-1\.3\.h/ } <include/mbedtls/*.h>;
|
||||||
push @ARGV, "3rdparty/everest/include/everest/everest.h";
|
push @ARGV, "3rdparty/everest/include/everest/everest.h";
|
||||||
push @ARGV, "3rdparty/everest/include/everest/x25519.h";
|
push @ARGV, "3rdparty/everest/include/everest/x25519.h";
|
||||||
|
push @ARGV, glob("library/*.h");
|
||||||
|
|
||||||
my @consts;
|
my @consts;
|
||||||
my $state = 'out';
|
my $state = 'out';
|
||||||
|
|
Loading…
Reference in a new issue