Merge pull request #3219 from aggarg/err_optimization

Remove error_description variable from strerr functions
This commit is contained in:
Gilles Peskine 2020-05-04 09:37:13 +02:00 committed by GitHub
commit 9515d76171
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 258 additions and 516 deletions

File diff suppressed because it is too large Load diff

View file

@ -45,7 +45,6 @@ HEADER_INCLUDED
const char * mbedtls_high_level_strerr( int error_code ) const char * mbedtls_high_level_strerr( int error_code )
{ {
int high_level_error_code; int high_level_error_code;
const char *error_description = NULL;
if( error_code < 0 ) if( error_code < 0 )
error_code = -error_code; error_code = -error_code;
@ -63,13 +62,12 @@ HIGH_LEVEL_CODE_CHECKS
break; break;
} }
return error_description; return( NULL );
} }
const char * mbedtls_low_level_strerr( int error_code ) const char * mbedtls_low_level_strerr( int error_code )
{ {
int low_level_error_code; int low_level_error_code;
const char *error_description = NULL;
if( error_code < 0 ) if( error_code < 0 )
error_code = -error_code; error_code = -error_code;
@ -87,7 +85,7 @@ LOW_LEVEL_CODE_CHECKS
break; break;
} }
return error_description; return( NULL );
} }
void mbedtls_strerror( int ret, char *buf, size_t buflen ) void mbedtls_strerror( int ret, char *buf, size_t buflen )

View file

@ -161,8 +161,7 @@ foreach my $line (@matches)
} }
${$code_check} .= "${white_space}case -($error_name):\n". ${$code_check} .= "${white_space}case -($error_name):\n".
"${white_space} error_description = \"$module_name - $description\";\n". "${white_space} return( \"$module_name - $description\" );\n"
"${white_space} break;\n"
}; };
if ($ll_old_define ne "") if ($ll_old_define ne "")