Apply clang formatting.

Executed with:
`find . -regextype posix-egrep -regex ".*\.([hc]|fmt|function)" | xargs -L1 clang-format-12 -i`

Signed-off-by: Mateusz Starzyk <mateusz.starzyk@mobica.com>
This commit is contained in:
Mateusz Starzyk
2021-08-03 14:09:02 +02:00
parent e8bd0f2ed0
commit c0eabdc636
422 changed files with 93754 additions and 97774 deletions

View File

@@ -23,147 +23,145 @@
#if defined(MBEDTLS_ERROR_C) || defined(MBEDTLS_ERROR_STRERROR_DUMMY)
#if defined(MBEDTLS_ERROR_C)
# if defined(MBEDTLS_ERROR_C)
#if defined(MBEDTLS_PLATFORM_C)
#include "mbedtls/platform.h"
#else
#define mbedtls_snprintf snprintf
#endif
# if defined(MBEDTLS_PLATFORM_C)
# include "mbedtls/platform.h"
# else
# define mbedtls_snprintf snprintf
# endif
#include <stdio.h>
#include <string.h>
# include <stdio.h>
# include <string.h>
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;
if( error_code < 0 )
if (error_code < 0)
error_code = -error_code;
/* Extract the high-level part from the error code. */
high_level_error_code = error_code & 0xFF80;
switch( high_level_error_code )
{
switch (high_level_error_code) {
/* Begin Auto-Generated Code. */
HIGH_LEVEL_CODE_CHECKS
/* End Auto-Generated Code. */
HIGH_LEVEL_CODE_CHECKS
/* End Auto-Generated Code. */
default:
break;
}
return NULL ;
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;
if( error_code < 0 )
if (error_code < 0)
error_code = -error_code;
/* Extract the low-level part from the error code. */
low_level_error_code = error_code & ~0xFF80;
switch( low_level_error_code )
{
switch (low_level_error_code) {
/* Begin Auto-Generated Code. */
LOW_LEVEL_CODE_CHECKS
/* End Auto-Generated Code. */
LOW_LEVEL_CODE_CHECKS
/* End Auto-Generated Code. */
default:
break;
}
return NULL ;
return NULL;
}
void mbedtls_strerror( int ret, char *buf, size_t buflen )
void mbedtls_strerror(int ret, char *buf, size_t buflen)
{
size_t len;
int use_ret;
const char * high_level_error_description = NULL;
const char * low_level_error_description = NULL;
const char *high_level_error_description = NULL;
const char *low_level_error_description = NULL;
if( buflen == 0 )
if (buflen == 0)
return;
memset( buf, 0x00, buflen );
memset(buf, 0x00, buflen);
if( ret < 0 )
if (ret < 0)
ret = -ret;
if( ret & 0xFF80 )
{
if (ret & 0xFF80) {
use_ret = ret & 0xFF80;
// Translate high level error code.
high_level_error_description = mbedtls_high_level_strerr( ret );
high_level_error_description = mbedtls_high_level_strerr(ret);
if( high_level_error_description == NULL )
mbedtls_snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", (unsigned int) use_ret );
if (high_level_error_description == NULL)
mbedtls_snprintf(buf, buflen, "UNKNOWN ERROR CODE (%04X)",
(unsigned int)use_ret);
else
mbedtls_snprintf( buf, buflen, "%s", high_level_error_description );
mbedtls_snprintf(buf, buflen, "%s", high_level_error_description);
#if defined(MBEDTLS_SSL_TLS_C)
# if defined(MBEDTLS_SSL_TLS_C)
// Early return in case of a fatal error - do not try to translate low
// level code.
if(use_ret == -(MBEDTLS_ERR_SSL_FATAL_ALERT_MESSAGE))
if (use_ret == -(MBEDTLS_ERR_SSL_FATAL_ALERT_MESSAGE))
return;
#endif /* MBEDTLS_SSL_TLS_C */
# endif /* MBEDTLS_SSL_TLS_C */
}
use_ret = ret & ~0xFF80;
if( use_ret == 0 )
if (use_ret == 0)
return;
// If high level code is present, make a concatenation between both
// error strings.
//
len = strlen( buf );
len = strlen(buf);
if( len > 0 )
{
if( buflen - len < 5 )
if (len > 0) {
if (buflen - len < 5)
return;
mbedtls_snprintf( buf + len, buflen - len, " : " );
mbedtls_snprintf(buf + len, buflen - len, " : ");
buf += len + 3;
buflen -= len + 3;
}
// Translate low level error code.
low_level_error_description = mbedtls_low_level_strerr( ret );
low_level_error_description = mbedtls_low_level_strerr(ret);
if( low_level_error_description == NULL )
mbedtls_snprintf( buf, buflen, "UNKNOWN ERROR CODE (%04X)", (unsigned int) use_ret );
if (low_level_error_description == NULL)
mbedtls_snprintf(buf, buflen, "UNKNOWN ERROR CODE (%04X)",
(unsigned int)use_ret);
else
mbedtls_snprintf( buf, buflen, "%s", low_level_error_description );
mbedtls_snprintf(buf, buflen, "%s", low_level_error_description);
}
#else /* MBEDTLS_ERROR_C */
# else /* MBEDTLS_ERROR_C */
/*
* Provide an non-function in case MBEDTLS_ERROR_C is not defined
*/
void mbedtls_strerror( int ret, char *buf, size_t buflen )
void mbedtls_strerror(int ret, char *buf, size_t buflen)
{
((void) ret);
((void)ret);
if( buflen > 0 )
if (buflen > 0)
buf[0] = '\0';
}
#endif /* MBEDTLS_ERROR_C */
# endif /* MBEDTLS_ERROR_C */
#if defined(MBEDTLS_TEST_HOOKS)
void (*mbedtls_test_hook_error_add)( int, int, const char *, int );
#endif
# if defined(MBEDTLS_TEST_HOOKS)
void (*mbedtls_test_hook_error_add)(int, int, const char *, int);
# endif
#endif /* MBEDTLS_ERROR_C || MBEDTLS_ERROR_STRERROR_DUMMY */

View File

@@ -22,10 +22,10 @@
#include "query_config.h"
#if defined(MBEDTLS_PLATFORM_C)
#include "mbedtls/platform.h"
# include "mbedtls/platform.h"
#else
#include <stdio.h>
#define mbedtls_printf printf
# include <stdio.h>
# define mbedtls_printf printf
#endif /* MBEDTLS_PLATFORM_C */
/*
@@ -95,9 +95,9 @@
* WARNING: This does not work for expanding function-like macros. However,
* Mbed TLS does not currently have configuration options used in this fashion.
*/
#define MACRO_EXPANSION_TO_STR(macro) MACRO_NAME_TO_STR(macro)
#define MACRO_NAME_TO_STR(macro) \
mbedtls_printf( "%s", strlen( #macro "" ) > 0 ? #macro "\n" : "" )
#define MACRO_EXPANSION_TO_STR(macro) MACRO_NAME_TO_STR(macro)
#define MACRO_NAME_TO_STR(macro) \
mbedtls_printf("%s", strlen(#macro "") > 0 ? #macro "\n" : "")
#if defined(_MSC_VER)
/*
@@ -108,16 +108,16 @@
* clean build and to ensure that tests treating warnings as errors do not
* fail.
*/
#pragma warning(push)
#pragma warning(disable:4003)
# pragma warning(push)
# pragma warning(disable : 4003)
#endif /* _MSC_VER */
int query_config( const char *config )
int query_config(const char *config)
{
CHECK_CONFIG /* If the symbol is not found, return an error */
return 1 ;
CHECK_CONFIG /* If the symbol is not found, return an error */
return 1;
}
#if defined(_MSC_VER)
#pragma warning(pop)
# pragma warning(pop)
#endif /* _MSC_VER */

View File

@@ -21,34 +21,33 @@
#if defined(MBEDTLS_VERSION_C)
#include "mbedtls/version.h"
# include "mbedtls/version.h"
#include <string.h>
# include <string.h>
static const char * const features[] = {
#if defined(MBEDTLS_VERSION_FEATURES)
FEATURE_DEFINES
#endif /* MBEDTLS_VERSION_FEATURES */
NULL
static const char *const features[] = {
# if defined(MBEDTLS_VERSION_FEATURES)
FEATURE_DEFINES
# endif /* MBEDTLS_VERSION_FEATURES */
NULL
};
int mbedtls_version_check_feature( const char *feature )
int mbedtls_version_check_feature(const char *feature)
{
const char * const *idx = features;
const char *const *idx = features;
if( *idx == NULL )
return -2 ;
if (*idx == NULL)
return -2;
if( feature == NULL )
return -1 ;
if (feature == NULL)
return -1;
while( *idx != NULL )
{
if( !strcmp( *idx, feature ) )
return 0 ;
while (*idx != NULL) {
if (!strcmp(*idx, feature))
return 0;
idx++;
}
return -1 ;
return -1;
}
#endif /* MBEDTLS_VERSION_C */