mirror of
https://github.com/ARMmbed/mbedtls.git
synced 2025-05-09 08:31:33 +08:00
simplify code
Signed-off-by: valord577 <valord577@gmail.com>
This commit is contained in:
parent
176e92711c
commit
5bfcd1c63b
@ -68,7 +68,6 @@ void mbedtls_debug_print_msg(const mbedtls_ssl_context *ssl, int level,
|
|||||||
va_list argp;
|
va_list argp;
|
||||||
char str[DEBUG_BUF_SIZE];
|
char str[DEBUG_BUF_SIZE];
|
||||||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||||
int eol = -1;
|
|
||||||
|
|
||||||
#if defined(static_assert)
|
#if defined(static_assert)
|
||||||
static_assert(DEBUG_BUF_SIZE >= 2)
|
static_assert(DEBUG_BUF_SIZE >= 2)
|
||||||
@ -86,23 +85,16 @@ void mbedtls_debug_print_msg(const mbedtls_ssl_context *ssl, int level,
|
|||||||
va_end(argp);
|
va_end(argp);
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
eol = 0;
|
ret = 0;
|
||||||
} else {
|
} else {
|
||||||
eol = ret;
|
|
||||||
if (ret >= DEBUG_BUF_SIZE - 1) {
|
if (ret >= DEBUG_BUF_SIZE - 1) {
|
||||||
eol = DEBUG_BUF_SIZE - 2;
|
ret = DEBUG_BUF_SIZE - 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
str[ret] = '\n';
|
||||||
|
str[ret + 1] = '\0';
|
||||||
|
|
||||||
/*
|
debug_send_line(ssl, level, file, line, str);
|
||||||
* Send if str contains '\n'.
|
|
||||||
*/
|
|
||||||
if (eol >= 0) {
|
|
||||||
str[eol] = '\n';
|
|
||||||
str[eol + 1] = '\0';
|
|
||||||
|
|
||||||
debug_send_line(ssl, level, file, line, str);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void mbedtls_debug_print_ret(const mbedtls_ssl_context *ssl, int level,
|
void mbedtls_debug_print_ret(const mbedtls_ssl_context *ssl, int level,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user