From c9522fb740200ccef6230cec452c48efb31e5394 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Thu, 11 May 2023 22:05:17 +0200 Subject: Removed all Printf-family functions from StringUtils. Replaced them with fmt::format calls, including changes to the format strings. Also changed the format strings to use FMT_STRING, so that the format is checked compile-time against the arguments. Also fixed code-style violations already present in the code. --- src/mbedTLS++/BlockingSslClientSocket.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/mbedTLS++/BlockingSslClientSocket.cpp') diff --git a/src/mbedTLS++/BlockingSslClientSocket.cpp b/src/mbedTLS++/BlockingSslClientSocket.cpp index bc9d07157..6e6410879 100644 --- a/src/mbedTLS++/BlockingSslClientSocket.cpp +++ b/src/mbedTLS++/BlockingSslClientSocket.cpp @@ -137,7 +137,7 @@ bool cBlockingSslClientSocket::Connect(const AString & a_ServerName, UInt16 a_Po if (ret != 0) { - Printf(m_LastErrorText, "SSL initialization failed: -0x%x", -ret); + m_LastErrorText = fmt::format(FMT_STRING("SSL initialization failed: -0x{:x}"), -ret); return false; } @@ -150,7 +150,7 @@ bool cBlockingSslClientSocket::Connect(const AString & a_ServerName, UInt16 a_Po ret = m_Ssl.Handshake(); if (ret != 0) { - Printf(m_LastErrorText, "SSL handshake failed: -0x%x", -ret); + m_LastErrorText = fmt::format(FMT_STRING("SSL handshake failed: -0x{:x}"), -ret); return false; } @@ -169,8 +169,8 @@ void cBlockingSslClientSocket::SetExpectedPeerName(AString a_ExpectedPeerName) if (!m_ExpectedPeerName.empty()) { LOGWARNING( - "SSL: Trying to set multiple expected peer names, only the last one will be used. Name: %s", - a_ExpectedPeerName.c_str() + "SSL: Trying to set multiple expected peer names, only the last one will be used. %s overwriting the previous %s", + a_ExpectedPeerName, m_ExpectedPeerName ); } @@ -216,7 +216,7 @@ bool cBlockingSslClientSocket::Send(const void * a_Data, size_t a_NumBytes) { ASSERT(res != MBEDTLS_ERR_SSL_WANT_READ); // This should never happen with callback-based SSL ASSERT(res != MBEDTLS_ERR_SSL_WANT_WRITE); // This should never happen with callback-based SSL - Printf(m_LastErrorText, "Data cannot be written to SSL context: -0x%x", -res); + m_LastErrorText = fmt::format(FMT_STRING("Data cannot be written to SSL context: -0x{:x}"), -res); return false; } else @@ -241,7 +241,7 @@ int cBlockingSslClientSocket::Receive(void * a_Data, size_t a_MaxBytes) int res = m_Ssl.ReadPlain(a_Data, a_MaxBytes); if (res < 0) { - Printf(m_LastErrorText, "Data cannot be read form SSL context: -0x%x", -res); + m_LastErrorText = fmt::format(FMT_STRING("Data cannot be read from SSL context: -0x{:x}"), -res); } return res; } @@ -250,7 +250,7 @@ int cBlockingSslClientSocket::Receive(void * a_Data, size_t a_MaxBytes) -void cBlockingSslClientSocket::Disconnect(void) +void cBlockingSslClientSocket::Disconnect() { // Ignore if not connected if (!m_IsConnected) -- cgit v1.2.3