Check that MBEDTLS_ERROR_C is defined before using mbedtls_strerror().

If MBEDTLS_ERROR_C is not defined, that strerror function does not
exist, or is just dummy definition if MBEDTLS_ERROR_STRERROR_DUMMY is
defined.
pull/8311/head
Seppo Takalo 2018-10-17 11:45:31 +03:00
parent 7f39bb4453
commit 5d1cd2552b
1 changed files with 5 additions and 0 deletions

View File

@ -272,10 +272,15 @@ nsapi_size_or_error_t TLSSocketWrapper::recvfrom(SocketAddress *address, void *d
}
void TLSSocketWrapper::print_mbedtls_error(const char *name, int err) {
#ifdef MBEDTLS_ERROR_C
char *buf = new char[128];
mbedtls_strerror(err, buf, 128);
tr_err("%s() failed: -0x%04x (%d): %s", name, -err, err, buf);
delete[] buf;
#else
(void)name;
(void)err;
#endif
}