From cebcf7506e7510e236ece55856ecbf89a5f5a309 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Fri, 4 Nov 2016 14:50:12 +0100 Subject: [PATCH] Redundant std::string to const char* conversion in exception constructors cleaned --- lib/EAPBase/src/Credentials.cpp | 8 ++++---- lib/EAPBase/src/Method.cpp | 2 +- lib/MSCHAPv2/src/Method.cpp | 6 +++--- lib/TTLS/src/Method.cpp | 2 +- lib/TTLS/src/Module.cpp | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/EAPBase/src/Credentials.cpp b/lib/EAPBase/src/Credentials.cpp index 2e8bd5c..ab5acbc 100644 --- a/lib/EAPBase/src/Credentials.cpp +++ b/lib/EAPBase/src/Credentials.cpp @@ -650,14 +650,14 @@ void eap::credentials_connection::load(_In_ IXMLDOMNode *pConfigRoot) if (match(*cfg_prov)) { // Matching provider found. Create matching blank credential set, then load. if (cfg_prov->m_methods.empty()) - throw invalid_argument(string_printf(__FUNCTION__ " %ls provider has no methods.", cfg_prov->get_id().c_str()).c_str()); + throw invalid_argument(string_printf(__FUNCTION__ " %ls provider has no methods.", cfg_prov->get_id().c_str())); const config_method_with_cred *cfg_method = dynamic_cast(cfg_prov->m_methods.front().get()); m_cred.reset(cfg_method->make_credentials()); m_cred->load(pXmlElClientSideCredential); break; } } else - throw invalid_argument(string_printf(__FUNCTION__ " Credentials do not match to any provider within this connection configuration (provider: %ls).", get_id().c_str()).c_str()); + throw invalid_argument(string_printf(__FUNCTION__ " Credentials do not match to any provider within this connection configuration (provider: %ls).", get_id().c_str())); } } @@ -693,14 +693,14 @@ void eap::credentials_connection::operator>>(_Inout_ cursor_in &cursor) if (match(*cfg_prov)) { // Matching provider found. Create matching blank credential set, then read. if (cfg_prov->m_methods.empty()) - throw invalid_argument(string_printf(__FUNCTION__ " %ls provider has no methods.", cfg_prov->get_id().c_str()).c_str()); + throw invalid_argument(string_printf(__FUNCTION__ " %ls provider has no methods.", cfg_prov->get_id().c_str())); const config_method_with_cred *cfg_method = dynamic_cast(cfg_prov->m_methods.front().get()); m_cred.reset(cfg_method->make_credentials()); cursor >> *m_cred; break; } } else - throw invalid_argument(string_printf(__FUNCTION__ " Credentials do not match to any provider within this connection configuration (provider: %ls).", get_id().c_str()).c_str()); + throw invalid_argument(string_printf(__FUNCTION__ " Credentials do not match to any provider within this connection configuration (provider: %ls).", get_id().c_str())); } } diff --git a/lib/EAPBase/src/Method.cpp b/lib/EAPBase/src/Method.cpp index aa6d06c..1466768 100644 --- a/lib/EAPBase/src/Method.cpp +++ b/lib/EAPBase/src/Method.cpp @@ -146,7 +146,7 @@ void eap::method_noneap::get_response_packet( size_t size_packet = m_packet_res.size(); if (size_packet > *pdwSendPacketSize) - throw invalid_argument(string_printf(__FUNCTION__ " This method does not support packet fragmentation, but the data size is too big to fit in one packet (packet: %u, maximum: %u).", size_packet, *pdwSendPacketSize).c_str()); + throw invalid_argument(string_printf(__FUNCTION__ " This method does not support packet fragmentation, but the data size is too big to fit in one packet (packet: %u, maximum: %u).", size_packet, *pdwSendPacketSize)); memcpy(pSendPacket, m_packet_res.data(), size_packet); *pdwSendPacketSize = (DWORD)size_packet; diff --git a/lib/MSCHAPv2/src/Method.cpp b/lib/MSCHAPv2/src/Method.cpp index 607a77c..abd7bdb 100644 --- a/lib/MSCHAPv2/src/Method.cpp +++ b/lib/MSCHAPv2/src/Method.cpp @@ -178,7 +178,7 @@ void eap::method_mschapv2::process_packet(_In_bytecount_(size_pck) const void *_ if (code == 26 && vendor == 311) { // MS-CHAP2-Success if (msg[0] != m_ident) - throw invalid_argument(string_printf(__FUNCTION__ " Wrong MSCHAPv2 ident (expected: %u, received: %u).", m_ident, msg[0]).c_str()); + throw invalid_argument(string_printf(__FUNCTION__ " Wrong MSCHAPv2 ident (expected: %u, received: %u).", m_ident, msg[0])); const char *str = reinterpret_cast(msg + 1); process_success(parse_response(str, (reinterpret_cast(msg_end) - str))); } else if (code == 2 && vendor == 311) { @@ -187,7 +187,7 @@ void eap::method_mschapv2::process_packet(_In_bytecount_(size_pck) const void *_ const char *str = reinterpret_cast(msg + 1); process_error(parse_response(str, (reinterpret_cast(msg_end) - str))); } else if (hdr->flags & diameter_avp_flag_mandatory) - throw win_runtime_error(ERROR_NOT_SUPPORTED, string_printf(__FUNCTION__ " Server sent mandatory Diameter AVP we do not support (code: %u, vendor: %u).", code, vendor).c_str()); + throw win_runtime_error(ERROR_NOT_SUPPORTED, string_printf(__FUNCTION__ " Server sent mandatory Diameter AVP we do not support (code: %u, vendor: %u).", code, vendor)); pck = msg_next; } @@ -246,7 +246,7 @@ void eap::method_mschapv2::process_error(_In_ const list &argv) bool is_last; dec.decode(resp, is_last, val.data() + 2, (size_t)-1); if (resp.size() != sizeof(m_challenge_server)) - throw invalid_argument(string_printf(__FUNCTION__ " Incorrect MSCHAPv2 challenge length (expected: %uB, received: %uB).", sizeof(m_challenge_server), resp.size()).c_str()); + throw invalid_argument(string_printf(__FUNCTION__ " Incorrect MSCHAPv2 challenge length (expected: %uB, received: %uB).", sizeof(m_challenge_server), resp.size())); memcpy(&m_challenge_server, resp.data(), sizeof(m_challenge_server)); } else if ((val[0] == 'M' || val[0] == 'm') && val[1] == '=') { MultiByteToWideChar(CP_UTF8, 0, val.data() + 2, -1, m_cfg.m_last_msg); diff --git a/lib/TTLS/src/Method.cpp b/lib/TTLS/src/Method.cpp index b532d1c..1861cb4 100644 --- a/lib/TTLS/src/Method.cpp +++ b/lib/TTLS/src/Method.cpp @@ -306,6 +306,6 @@ void eap::method_ttls::process_application_data(_In_bytecount_(size_msg) const v } default: - throw invalid_argument(string_printf(__FUNCTION__ " Inner method returned an unsupported action (action %u).", eap_output.action).c_str()); + throw invalid_argument(string_printf(__FUNCTION__ " Inner method returned an unsupported action (action %u).", eap_output.action)); } } diff --git a/lib/TTLS/src/Module.cpp b/lib/TTLS/src/Module.cpp index 3c74a17..cad13e1 100644 --- a/lib/TTLS/src/Module.cpp +++ b/lib/TTLS/src/Module.cpp @@ -209,12 +209,12 @@ EAP_SESSION_HANDLE eap::peer_ttls::begin_session( if (s->m_cred.match(*cfg_prov)) { // Matching provider found. if (cfg_prov->m_methods.empty()) - throw invalid_argument(string_printf(__FUNCTION__ " %ls provider has no methods.", cfg_prov->get_id().c_str()).c_str()); + throw invalid_argument(string_printf(__FUNCTION__ " %ls provider has no methods.", cfg_prov->get_id().c_str())); cfg_method = dynamic_cast(cfg_prov->m_methods.front().get()); break; } } else - throw invalid_argument(string_printf(__FUNCTION__ " Credentials do not match to any provider within this connection configuration (provider: %ls).", s->m_cred.get_id().c_str()).c_str()); + throw invalid_argument(string_printf(__FUNCTION__ " Credentials do not match to any provider within this connection configuration (provider: %ls).", s->m_cred.get_id().c_str())); } // We have configuration, we have credentials, create method.