From c53ed21d5589f2afb2b815cc2b71f79d2609a4b0 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Mon, 3 Oct 2016 14:49:17 +0200 Subject: [PATCH] Code clean-up --- EventMonitor/ETWLog.cpp | 8 ++--- EventMonitor/ETWLog.h | 2 +- lib/EAPBase/include/EAP.h | 64 ++++++++++++++++----------------- lib/EAPBase/include/Module.h | 4 +-- lib/EAPBase/src/Config.cpp | 19 +++++----- lib/EAPBase/src/Credentials.cpp | 4 +-- lib/EAPBase_UI/include/EAP_UI.h | 6 ++-- lib/EAPBase_UI/src/EAP_UI.cpp | 2 +- lib/MSCHAPv2/src/Method.cpp | 4 +-- lib/TLS/src/Config.cpp | 8 ++--- lib/TLS/src/Method.cpp | 14 ++++---- lib/TLS_UI/src/TLS_UI.cpp | 4 +-- lib/TTLS/src/Config.cpp | 2 +- lib/TTLS/src/Module.cpp | 4 +-- lib/TTLS_UI/src/Module.cpp | 2 +- lib/WinStd | 2 +- lib/wxExtend | 2 +- 17 files changed, 75 insertions(+), 76 deletions(-) diff --git a/EventMonitor/ETWLog.cpp b/EventMonitor/ETWLog.cpp index 230dc26..bf1aca2 100644 --- a/EventMonitor/ETWLog.cpp +++ b/EventMonitor/ETWLog.cpp @@ -92,7 +92,7 @@ wxEventTraceProcessorThread::wxEventTraceProcessorThread(wxEvtHandler *parent, c wxEventTraceProcessorThread::~wxEventTraceProcessorThread() { - for (vector::iterator trace = m_traces.begin(), trace_end = m_traces.end(); trace != trace_end; ++trace) { + for (auto trace = m_traces.begin(), trace_end = m_traces.end(); trace != trace_end; ++trace) { TRACEHANDLE &h = *trace; if (h) { // Close trace. @@ -104,7 +104,7 @@ wxEventTraceProcessorThread::~wxEventTraceProcessorThread() void wxEventTraceProcessorThread::Abort() { - for (vector::iterator trace = m_traces.begin(), trace_end = m_traces.end(); trace != trace_end; ++trace) { + for (auto trace = m_traces.begin(), trace_end = m_traces.end(); trace != trace_end; ++trace) { TRACEHANDLE &h = *trace; if (h) { // Close trace. @@ -415,7 +415,7 @@ void wxETWListCtrl::RebuildItems() // Rebuild the index. m_rec_idx.clear(); - set::const_iterator selection_end = selection.end(), focus_end = focus.end(); + auto selection_end = selection.cend(), focus_end = focus.cend(); vector selection_out, focus_out; long center_out = -1; for (size_t i = 0, n = m_rec_db.size(); i < n; i++) { @@ -709,7 +709,7 @@ void wxPersistentETWListCtrl::Save() const SaveValue(wxT("ScrollAuto"), wnd->m_scroll_auto); wxString data_str; - for (wxETWListCtrl::guidset::const_iterator src = wnd->m_sources.cbegin(), src_end = wnd->m_sources.cend(); src != src_end; ++src) + for (auto src = wnd->m_sources.cbegin(), src_end = wnd->m_sources.cend(); src != src_end; ++src) data_str += tstring_guid(*src); SaveValue(wxT("Sources"), data_str); diff --git a/EventMonitor/ETWLog.h b/EventMonitor/ETWLog.h index ffd9101..829f862 100644 --- a/EventMonitor/ETWLog.h +++ b/EventMonitor/ETWLog.h @@ -161,7 +161,7 @@ public: inline void EnableSource(const GUID &guid, bool enable = true) { - guidset::iterator s = m_sources.find(guid); + auto s = m_sources.find(guid); if (enable) { if (s == m_sources.end()) { m_sources.insert(guid); diff --git a/lib/EAPBase/include/EAP.h b/lib/EAPBase/include/EAP.h index 23dd1a5..6bdc15a 100644 --- a/lib/EAPBase/include/EAP.h +++ b/lib/EAPBase/include/EAP.h @@ -720,7 +720,7 @@ namespace eap inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const bool &val) { - eap::cursor_out::ptr_type ptr_end = cursor.ptr + 1; + auto ptr_end = cursor.ptr + 1; assert(ptr_end <= cursor.ptr_end); *cursor.ptr = val ? 1 : 0; cursor.ptr = ptr_end; @@ -736,7 +736,7 @@ inline size_t pksizeof(_In_ const bool &val) inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ bool &val) { - eap::cursor_in::ptr_type ptr_end = cursor.ptr + 1; + auto ptr_end = cursor.ptr + 1; assert(ptr_end <= cursor.ptr_end); val = *cursor.ptr ? true : false; cursor.ptr = ptr_end; @@ -745,7 +745,7 @@ inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ bool &val) inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const unsigned char &val) { - eap::cursor_out::ptr_type ptr_end = cursor.ptr + 1; + auto ptr_end = cursor.ptr + 1; assert(ptr_end <= cursor.ptr_end); *cursor.ptr = val; cursor.ptr = ptr_end; @@ -761,7 +761,7 @@ inline size_t pksizeof(_In_ const unsigned char &val) inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ unsigned char &val) { - eap::cursor_in::ptr_type ptr_end = cursor.ptr + 1; + auto ptr_end = cursor.ptr + 1; assert(ptr_end <= cursor.ptr_end); val = *cursor.ptr; cursor.ptr = ptr_end; @@ -770,7 +770,7 @@ inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ unsigned char &val) inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const unsigned int &val) { - eap::cursor_out::ptr_type ptr_end = cursor.ptr + sizeof(unsigned int); + auto ptr_end = cursor.ptr + sizeof(unsigned int); assert(ptr_end <= cursor.ptr_end); *reinterpret_cast(cursor.ptr) = val; cursor.ptr = ptr_end; @@ -786,7 +786,7 @@ inline size_t pksizeof(_In_ const unsigned int &val) inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ unsigned int &val) { - eap::cursor_in::ptr_type ptr_end = cursor.ptr + sizeof(unsigned int); + auto ptr_end = cursor.ptr + sizeof(unsigned int); assert(ptr_end <= cursor.ptr_end); val = *reinterpret_cast(cursor.ptr); cursor.ptr = ptr_end; @@ -796,7 +796,7 @@ inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ unsigned int &val) #ifdef _WIN64 inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const size_t &val) { - eap::cursor_out::ptr_type ptr_end = cursor.ptr + sizeof(size_t); + auto ptr_end = cursor.ptr + sizeof(size_t); assert(ptr_end <= cursor.ptr_end); *(size_t*)cursor.ptr = val; cursor.ptr = ptr_end; @@ -812,7 +812,7 @@ inline size_t pksizeof(_In_ const size_t &val) inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ size_t &val) { - eap::cursor_in::ptr_type ptr_end = cursor.ptr + sizeof(size_t); + auto ptr_end = cursor.ptr + sizeof(size_t); assert(ptr_end <= cursor.ptr_end); val = *(size_t*)cursor.ptr; cursor.ptr = ptr_end; @@ -823,10 +823,10 @@ inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ size_t &val) template inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const std::basic_string<_Elem, _Traits, _Ax> &val) { - std::basic_string<_Elem, _Traits, _Ax>::size_type count = val.length(); + size_t count = val.length(); assert(strlen(val.c_str()) == count); // String should not contain zero terminators. size_t size = sizeof(_Elem)*(count + 1); - eap::cursor_out::ptr_type ptr_end = cursor.ptr + size; + auto ptr_end = cursor.ptr + size; assert(ptr_end <= cursor.ptr_end); memcpy(cursor.ptr, (const _Elem*)val.c_str(), size); cursor.ptr = ptr_end; @@ -844,7 +844,7 @@ template inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ std::basic_string<_Elem, _Traits, _Ax> &val) { size_t count_max = cursor.ptr_end - cursor.ptr; - std::basic_string<_Elem, _Traits, _Ax>::size_type count = strnlen((const _Elem*&)cursor.ptr, count_max); + size_t count = strnlen((const _Elem*&)cursor.ptr, count_max); assert(count < count_max); // String should be zero terminated. val.assign((const _Elem*&)cursor.ptr, count); cursor.ptr += sizeof(_Elem)*(count + 1); @@ -879,13 +879,13 @@ inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ std::basic_string inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const std::vector<_Ty, _Ax> &val) { - std::vector<_Ty, _Ax>::size_type count = val.size(); + auto count = val.size(); cursor << count; // Since we do not know wheter vector elements are primitives or objects, iterate instead of memcpy. // For performance critical vectors of flat opaque data types write specialized template instantiation. - for (std::vector<_Ty, _Ax>::size_type i = 0; i < count; i++) - cursor << val[i]; + for (auto i = val.cbegin(), i_end = val.cend(); i != i_end; ++i) + cursor << *i; } @@ -894,10 +894,10 @@ inline size_t pksizeof(const std::vector<_Ty, _Ax> &val) { // Since we do not know wheter vector elements are primitives or objects, iterate instead of sizeof(). // For performance critical vectors of flat opaque data types write specialized template instantiation. - std::vector<_Ty, _Ax>::size_type count = val.size(); + auto count = val.size(); size_t size = pksizeof(count); - for (std::vector<_Ty, _Ax>::size_type i = 0; i < count; i++) - size += pksizeof(val[i]); + for (auto i = val.cbegin(), i_end = val.cend(); i != i_end; ++i) + size += pksizeof(*i); return size; } @@ -905,14 +905,14 @@ inline size_t pksizeof(const std::vector<_Ty, _Ax> &val) template inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ std::vector<_Ty, _Ax> &val) { - std::vector<_Ty, _Ax>::size_type count; + std::vector<_Ty, _Ax>::size_type i, count; cursor >> count; // Since we do not know wheter vector elements are primitives or objects, iterate instead of assign(). // For performance critical vectors of flat opaque data types write specialized template instantiation. val.clear(); val.reserve(count); - for (std::vector<_Ty, _Ax>::size_type i = 0; i < count; i++) { + for (i = 0; i < count; i++) { _Ty el; cursor >> el; val.push_back(el); @@ -923,12 +923,12 @@ inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ std::vector<_Ty, _A template inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const std::list<_Ty, _Ax> &val) { - std::list<_Ty, _Ax>::size_type count = val.size(); + auto count = val.size(); cursor << count; // Since we do not know wheter list elements are primitives or objects, iterate instead of memcpy. // For performance critical vectors of flat opaque data types write specialized template instantiation. - for (std::list<_Ty, _Ax>::const_iterator i = val.cbegin(), i_end = val.cend(); i != i_end; ++i) + for (auto i = val.cbegin(), i_end = val.cend(); i != i_end; ++i) cursor << *i; } @@ -938,9 +938,9 @@ inline size_t pksizeof(const std::list<_Ty, _Ax> &val) { // Since we do not know wheter list elements are primitives or objects, iterate instead of sizeof(). // For performance critical vectors of flat opaque data types write specialized template instantiation. - std::list<_Ty, _Ax>::size_type count = val.size(); + auto count = val.size(); size_t size = pksizeof(count); - for (std::list<_Ty, _Ax>::const_iterator i = val.cbegin(), i_end = val.cend(); i != i_end; ++i) + for (auto i = val.cbegin(), i_end = val.cend(); i != i_end; ++i) size += pksizeof(*i); return size; } @@ -949,13 +949,11 @@ inline size_t pksizeof(const std::list<_Ty, _Ax> &val) template inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ std::list<_Ty, _Ax> &val) { - std::list<_Ty, _Ax>::size_type count; + std::list<_Ty, _Ax>::size_type i, count; cursor >> count; - // Since we do not know wheter list elements are primitives or objects, iterate instead of assign(). - // For performance critical vectors of flat opaque data types write specialized template instantiation. val.clear(); - for (std::list<_Ty, _Ax>::size_type i = 0; i < count; i++) { + for (i = 0; i < count; i++) { _Ty el; cursor >> el; val.push_back(el); @@ -990,7 +988,7 @@ inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const winstd::cert_ if (val) { cursor << (unsigned int)val->dwCertEncodingType; cursor << (unsigned int)val->cbCertEncoded ; - eap::cursor_out::ptr_type ptr_end = cursor.ptr + val->cbCertEncoded; + auto ptr_end = cursor.ptr + val->cbCertEncoded; assert(ptr_end <= cursor.ptr_end); memcpy(cursor.ptr, val->pbCertEncoded, val->cbCertEncoded); cursor.ptr = ptr_end; @@ -1022,7 +1020,7 @@ inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ winstd::cert_contex cursor >> (unsigned int&)dwCertEncodedSize; if (dwCertEncodedSize) { - eap::cursor_in::ptr_type ptr_end = cursor.ptr + dwCertEncodedSize; + auto ptr_end = cursor.ptr + dwCertEncodedSize; assert(ptr_end <= cursor.ptr_end); val.create(dwCertEncodingType, (BYTE*)cursor.ptr, dwCertEncodedSize); cursor.ptr = ptr_end; @@ -1052,7 +1050,7 @@ inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ winstd::eap_type_t template inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const eap::sanitizing_blob_f &val) { - eap::cursor_out::ptr_type ptr_end = cursor.ptr + sizeof(eap::sanitizing_blob_f); + auto ptr_end = cursor.ptr + sizeof(eap::sanitizing_blob_f); assert(ptr_end <= cursor.ptr_end); memcpy(cursor.ptr, val.data, sizeof(eap::sanitizing_blob_f)); cursor.ptr = ptr_end; @@ -1070,7 +1068,7 @@ inline size_t pksizeof(_In_ const eap::sanitizing_blob_f &val) template inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ eap::sanitizing_blob_f &val) { - eap::cursor_in::ptr_type ptr_end = cursor.ptr + sizeof(eap::sanitizing_blob_f); + auto ptr_end = cursor.ptr + sizeof(eap::sanitizing_blob_f); assert(ptr_end <= cursor.ptr_end); memcpy(val.data, cursor.ptr, sizeof(eap::sanitizing_blob_f)); cursor.ptr = ptr_end; @@ -1079,7 +1077,7 @@ inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ eap::sanitizing_blo inline void operator<<(_Inout_ eap::cursor_out &cursor, _In_ const GUID &val) { - eap::cursor_out::ptr_type ptr_end = cursor.ptr + sizeof(GUID); + auto ptr_end = cursor.ptr + sizeof(GUID); assert(ptr_end <= cursor.ptr_end); memcpy(cursor.ptr, &val, sizeof(GUID)); cursor.ptr = ptr_end; @@ -1095,7 +1093,7 @@ inline size_t pksizeof(_In_ const GUID &val) inline void operator>>(_Inout_ eap::cursor_in &cursor, _Out_ GUID &val) { - eap::cursor_in::ptr_type ptr_end = cursor.ptr + sizeof(GUID); + auto ptr_end = cursor.ptr + sizeof(GUID); assert(ptr_end <= cursor.ptr_end); memcpy(&val, cursor.ptr, sizeof(GUID)); cursor.ptr = ptr_end; diff --git a/lib/EAPBase/include/Module.h b/lib/EAPBase/include/Module.h index 28ca9b4..d9dcfdf 100644 --- a/lib/EAPBase/include/Module.h +++ b/lib/EAPBase/include/Module.h @@ -162,7 +162,7 @@ namespace eap desc.reserve(count + 2); desc.push_back(winstd::event_data( name )); desc.push_back(winstd::event_data((unsigned int)count)); - for (std::list, _Ax_list>::const_iterator v = value.cbegin(), v_end = value.cend(); v != v_end; ++v) + for (auto v = value.cbegin(), v_end = value.cend(); v != v_end; ++v) desc.push_back(winstd::event_data(*v)); m_ep.write(&EAPMETHOD_TRACE_EVT_CFG_VALUE_ANSI_STRING_ARRAY, (ULONG)desc.size(), desc.data()); @@ -180,7 +180,7 @@ namespace eap desc.reserve(count + 2); desc.push_back(winstd::event_data( name )); desc.push_back(winstd::event_data((unsigned int)count)); - for (std::list, _Ax_list>::const_iterator v = value.cbegin(), v_end = value.cend(); v != v_end; ++v) + for (auto v = value.cbegin(), v_end = value.cend(); v != v_end; ++v) desc.push_back(winstd::event_data(*v)); m_ep.write(&EAPMETHOD_TRACE_EVT_CFG_VALUE_UNICODE_STRING_ARRAY, (ULONG)desc.size(), desc.data()); diff --git a/lib/EAPBase/src/Config.cpp b/lib/EAPBase/src/Config.cpp index f2e2928..5aeb4d6 100644 --- a/lib/EAPBase/src/Config.cpp +++ b/lib/EAPBase/src/Config.cpp @@ -375,7 +375,7 @@ eap::config_provider::config_provider(_In_ const config_provider &other) : config (other ) { m_methods.reserve(other.m_methods.size()); - for (vector >::const_iterator method = other.m_methods.cbegin(), method_end = other.m_methods.cend(); method != method_end; ++method) + for (auto method = other.m_methods.cbegin(), method_end = other.m_methods.cend(); method != method_end; ++method) m_methods.push_back(std::move(unique_ptr(*method ? dynamic_cast(method->get()->clone()) : nullptr))); } @@ -414,7 +414,7 @@ eap::config_provider& eap::config_provider::operator=(_In_ const config_provider m_methods.clear(); m_methods.reserve(other.m_methods.size()); - for (vector >::const_iterator method = other.m_methods.cbegin(), method_end = other.m_methods.cend(); method != method_end; ++method) + for (auto method = other.m_methods.cbegin(), method_end = other.m_methods.cend(); method != method_end; ++method) m_methods.push_back(std::move(unique_ptr(*method ? dynamic_cast(method->get()->clone()) : nullptr))); } @@ -519,7 +519,7 @@ void eap::config_provider::save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode *pC if (FAILED(hr = eapxml::create_element(pDoc, pConfigRoot, bstr(L"eap-metadata:AuthenticationMethods"), bstr(L"AuthenticationMethods"), namespace_eapmetadata, pXmlElAuthenticationMethods))) throw com_runtime_error(hr, __FUNCTION__ " Error creating element."); - for (vector >::const_iterator method = m_methods.cbegin(), method_end = m_methods.cend(); method != method_end; ++method) { + for (auto method = m_methods.cbegin(), method_end = m_methods.cend(); method != method_end; ++method) { // com_obj pXmlElAuthenticationMethod; if (FAILED(hr = eapxml::create_element(pDoc, bstr(L"AuthenticationMethod"), namespace_eapmetadata, pXmlElAuthenticationMethod))) @@ -685,11 +685,12 @@ void eap::config_provider::operator>>(_Inout_ cursor_in &cursor) cursor >> m_lbl_alt_identity ; cursor >> m_lbl_alt_password ; - list::size_type count; - bool is_nonnull; + list::size_type i, count; cursor >> count; m_methods.clear(); - for (list::size_type i = 0; i < count; i++) { + m_methods.reserve(count); + for (i = 0; i < count; i++) { + bool is_nonnull; cursor >> is_nonnull; if (is_nonnull) { unique_ptr el(m_module.make_config_method()); @@ -763,7 +764,7 @@ void eap::config_connection::save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode * if (FAILED(hr = eapxml::create_element(pDoc, pConfigRoot, bstr(L"eap-metadata:EAPIdentityProviderList"), bstr(L"EAPIdentityProviderList"), namespace_eapmetadata, pXmlElIdentityProviderList))) throw com_runtime_error(hr, __FUNCTION__ " Error creating element."); - for (provider_list::const_iterator provider = m_providers.cbegin(), provider_end = m_providers.cend(); provider != provider_end; ++provider) { + for (auto provider = m_providers.cbegin(), provider_end = m_providers.cend(); provider != provider_end; ++provider) { // com_obj pXmlElIdentityProvider; if (FAILED(hr = eapxml::create_element(pDoc, bstr(L"EAPIdentityProvider"), namespace_eapmetadata, pXmlElIdentityProvider))) @@ -825,10 +826,10 @@ void eap::config_connection::operator>>(_Inout_ cursor_in &cursor) { config::operator>>(cursor); - provider_list::size_type count; + provider_list::size_type i, count; cursor >> count; m_providers.clear(); - for (provider_list::size_type i = 0; i < count; i++) { + for (i = 0; i < count; i++) { config_provider el(m_module); cursor >> el; m_providers.push_back(std::move(el)); diff --git a/lib/EAPBase/src/Credentials.cpp b/lib/EAPBase/src/Credentials.cpp index 7195ff4..0f36497 100644 --- a/lib/EAPBase/src/Credentials.cpp +++ b/lib/EAPBase/src/Credentials.cpp @@ -657,7 +657,7 @@ void eap::credentials_connection::load(_In_ IXMLDOMNode *pConfigRoot) m_module.log_config((xpath + L" ID").c_str(), m_id.c_str()); // Look-up the provider. - for (config_connection::provider_list::const_iterator cfg_prov = m_cfg.m_providers.cbegin(), cfg_prov_end = m_cfg.m_providers.cend(); ; ++cfg_prov) { + for (auto cfg_prov = m_cfg.m_providers.cbegin(), cfg_prov_end = m_cfg.m_providers.cend(); ; ++cfg_prov) { if (cfg_prov != cfg_prov_end) { if (match(*cfg_prov)) { // Matching provider found. Create matching blank credential set, then load. @@ -700,7 +700,7 @@ void eap::credentials_connection::operator>>(_Inout_ cursor_in &cursor) cursor >> m_id ; // Look-up the provider. - for (config_connection::provider_list::const_iterator cfg_prov = m_cfg.m_providers.cbegin(), cfg_prov_end = m_cfg.m_providers.cend(); ; ++cfg_prov) { + for (auto cfg_prov = m_cfg.m_providers.cbegin(), cfg_prov_end = m_cfg.m_providers.cend(); ; ++cfg_prov) { if (cfg_prov != cfg_prov_end) { if (match(*cfg_prov)) { // Matching provider found. Create matching blank credential set, then read. diff --git a/lib/EAPBase_UI/include/EAP_UI.h b/lib/EAPBase_UI/include/EAP_UI.h index 8f424ae..2831a3b 100644 --- a/lib/EAPBase_UI/include/EAP_UI.h +++ b/lib/EAPBase_UI/include/EAP_UI.h @@ -203,10 +203,10 @@ public: std::unique_ptr cfg_dummy(cfg.m_module.make_config_method()); m_banner->m_title->SetLabel(wxString::Format("%s %s", wxT(PRODUCT_NAME_STR), cfg_dummy->get_method_str())); - for (eap::config_connection::provider_list::iterator provider = m_cfg.m_providers.begin(), provider_end = m_cfg.m_providers.end(); provider != provider_end; ++provider) { + for (auto provider = m_cfg.m_providers.begin(), provider_end = m_cfg.m_providers.end(); provider != provider_end; ++provider) { bool is_single = provider->m_methods.size() == 1; std::vector >::size_type count = 0; - std::vector >::iterator method = provider->m_methods.begin(), method_end = provider->m_methods.end(); + auto method = provider->m_methods.begin(), method_end = provider->m_methods.end(); for (; method != method_end; ++method, count++) { m_providers->AddPage( new _wxT( @@ -299,7 +299,7 @@ protected: if (wxMessageBox(tstring_printf(_("Are you sure you want to permanently remove %ls provider from configuration?"), wxEAPGetProviderName(cfg_provider.m_name).c_str()), _("Warning"), wxYES_NO, this) == wxYES) { // Delete provider. - eap::config_connection::provider_list::iterator it(m_cfg.m_providers.begin()); + auto it = m_cfg.m_providers.begin(); for (int i = 0; i < idx; i++, ++it); m_cfg.m_providers.erase(it); m_providers->DeletePage(idx); diff --git a/lib/EAPBase_UI/src/EAP_UI.cpp b/lib/EAPBase_UI/src/EAP_UI.cpp index c88a458..717e3a7 100644 --- a/lib/EAPBase_UI/src/EAP_UI.cpp +++ b/lib/EAPBase_UI/src/EAP_UI.cpp @@ -528,7 +528,7 @@ void eap::monitor_ui::release_slaves(_In_bytecount_(size) const void *data, _In_ { assert(!size || data); - for (list::const_iterator slave = m_slaves.begin(), slave_end = m_slaves.end(); slave != slave_end; ++slave) { + for (auto slave = m_slaves.cbegin(), slave_end = m_slaves.cend(); slave != slave_end; ++slave) { // Get slave's PID. DWORD pid_slave; GetWindowThreadProcessId(*slave, &pid_slave); diff --git a/lib/MSCHAPv2/src/Method.cpp b/lib/MSCHAPv2/src/Method.cpp index 2e3d0ec..7bb229e 100644 --- a/lib/MSCHAPv2/src/Method.cpp +++ b/lib/MSCHAPv2/src/Method.cpp @@ -198,7 +198,7 @@ void eap::method_mschapv2::process_success(_In_ const list &argv) { m_success = false; - for (list::const_iterator arg = argv.cbegin(), arg_end = argv.cend(); arg != arg_end; ++arg) { + for (auto arg = argv.cbegin(), arg_end = argv.cend(); arg != arg_end; ++arg) { const string &val = *arg; if ((val[0] == 'S' || val[0] == 's') && val[1] == '=') { // "S=" @@ -227,7 +227,7 @@ void eap::method_mschapv2::process_success(_In_ const list &argv) void eap::method_mschapv2::process_error(_In_ const list &argv) { - for (list::const_iterator arg = argv.cbegin(), arg_end = argv.cend(); arg != arg_end; ++arg) { + for (auto arg = argv.cbegin(), arg_end = argv.cend(); arg != arg_end; ++arg) { const string &val = *arg; if ((val[0] == 'E' || val[0] == 'e') && val[1] == '=') { DWORD dwResult = strtoul(val.data() + 2, NULL, 10); diff --git a/lib/TLS/src/Config.cpp b/lib/TLS/src/Config.cpp index d4007fe..a57812d 100644 --- a/lib/TLS/src/Config.cpp +++ b/lib/TLS/src/Config.cpp @@ -148,7 +148,7 @@ void eap::config_method_tls::save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode * if (FAILED(hr = eapxml::create_element(pDoc, pConfigRoot, bstr(L"eap-metadata:ServerSideCredential"), bstr(L"ServerSideCredential"), namespace_eapmetadata, pXmlElServerSideCredential))) throw com_runtime_error(hr, __FUNCTION__ " Error creating element."); - for (list::const_iterator i = m_trusted_root_ca.begin(), i_end = m_trusted_root_ca.end(); i != i_end; ++i) { + for (auto i = m_trusted_root_ca.cbegin(), i_end = m_trusted_root_ca.cend(); i != i_end; ++i) { // com_obj pXmlElCA; if (FAILED(hr = eapxml::create_element(pDoc, bstr(L"CA"), namespace_eapmetadata, pXmlElCA))) @@ -168,7 +168,7 @@ void eap::config_method_tls::save(_In_ IXMLDOMDocument *pDoc, _In_ IXMLDOMNode * } // - for (list::const_iterator i = m_server_names.begin(), i_end = m_server_names.end(); i != i_end; ++i) { + for (auto i = m_server_names.cbegin(), i_end = m_server_names.cend(); i != i_end; ++i) { if (FAILED(hr = eapxml::put_element_value(pDoc, pXmlElServerSideCredential, bstr(L"ServerName"), namespace_eapmetadata, bstr(*i)))) throw com_runtime_error(hr, __FUNCTION__ " Error creating element."); } @@ -221,7 +221,7 @@ void eap::config_method_tls::load(_In_ IXMLDOMNode *pConfigRoot) // Log loaded CA certificates. list cert_names; - for (std::list::const_iterator cert = m_trusted_root_ca.cbegin(), cert_end = m_trusted_root_ca.cend(); cert != cert_end; ++cert) + for (auto cert = m_trusted_root_ca.cbegin(), cert_end = m_trusted_root_ca.cend(); cert != cert_end; ++cert) cert_names.push_back(std::move(get_cert_title(*cert))); m_module.log_config((xpathServerSideCredential + L"/CA").c_str(), cert_names); } @@ -311,7 +311,7 @@ bool eap::config_method_tls::add_trusted_ca(_In_ DWORD dwCertEncodingType, _In_ return false; } - for (list::const_iterator i = m_trusted_root_ca.cbegin(), i_end = m_trusted_root_ca.cend();; ++i) { + for (auto i = m_trusted_root_ca.cbegin(), i_end = m_trusted_root_ca.cend();; ++i) { if (i != i_end) { if (*i == cert) { // This certificate is already on the list. diff --git a/lib/TLS/src/Method.cpp b/lib/TLS/src/Method.cpp index 5dcd2e1..a2feb1c 100644 --- a/lib/TLS/src/Method.cpp +++ b/lib/TLS/src/Method.cpp @@ -199,7 +199,7 @@ void eap::method_tls::begin_session( #else // Build (expected) server name(s) for Schannel. m_sc_target_name.clear(); - for (list::const_iterator name = m_cfg.m_server_names.cbegin(), name_end = m_cfg.m_server_names.cend(); name != name_end; ++name) { + for (auto name = m_cfg.m_server_names.cbegin(), name_end = m_cfg.m_server_names.cend(); name != name_end; ++name) { if (name != m_cfg.m_server_names.cbegin()) m_sc_target_name += _T(';'); #ifdef _UNICODE @@ -1294,7 +1294,7 @@ void eap::method_tls::verify_server_trust() const throw sec_runtime_error(status, __FUNCTION__ " Error retrieving server certificate from Schannel."); #endif - for (list::const_iterator c = m_cfg.m_trusted_root_ca.cbegin(), c_end = m_cfg.m_trusted_root_ca.cend(); c != c_end; ++c) { + for (auto c = m_cfg.m_trusted_root_ca.cbegin(), c_end = m_cfg.m_trusted_root_ca.cend(); c != c_end; ++c) { if (cert->cbCertEncoded == (*c)->cbCertEncoded && memcmp(cert->pbCertEncoded, (*c)->pbCertEncoded, cert->cbCertEncoded) == 0) { @@ -1343,7 +1343,7 @@ void eap::method_tls::verify_server_trust() const } has_san = true; - for (list::const_iterator s = m_cfg.m_server_names.cbegin(), s_end = m_cfg.m_server_names.cend(); !found && s != s_end; ++s) { + for (auto s = m_cfg.m_server_names.cbegin(), s_end = m_cfg.m_server_names.cend(); !found && s != s_end; ++s) { for (DWORD idx_entry = 0; !found && idx_entry < san_info->cAltEntry; idx_entry++) { if (san_info->rgAltEntry[idx_entry].dwAltNameChoice == CERT_ALT_NAME_DNS_NAME && _wcsicmp(s->c_str(), san_info->rgAltEntry[idx_entry].pwszDNSName) == 0) @@ -1361,7 +1361,7 @@ void eap::method_tls::verify_server_trust() const if (!CertGetNameStringW(cert, CERT_NAME_DNS_TYPE, CERT_NAME_STR_ENABLE_PUNYCODE_FLAG, NULL, subj)) throw win_runtime_error(__FUNCTION__ " Error retrieving server's certificate subject name."); - for (list::const_iterator s = m_cfg.m_server_names.cbegin(), s_end = m_cfg.m_server_names.cend(); !found && s != s_end; ++s) { + for (auto s = m_cfg.m_server_names.cbegin(), s_end = m_cfg.m_server_names.cend(); !found && s != s_end; ++s) { if (_wcsicmp(s->c_str(), subj.c_str()) == 0) { m_module.log_event(&EAPMETHOD_TLS_SERVER_NAME_TRUSTED1, event_data(subj), event_data::blank); found = true; @@ -1381,12 +1381,12 @@ void eap::method_tls::verify_server_trust() const cert_store store; if (!store.create(CERT_STORE_PROV_MEMORY, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, NULL, 0, NULL)) throw win_runtime_error(__FUNCTION__ " Error creating temporary certificate store."); - for (list::const_iterator c = m_cfg.m_trusted_root_ca.cbegin(), c_end = m_cfg.m_trusted_root_ca.cend(); c != c_end; ++c) + for (auto c = m_cfg.m_trusted_root_ca.cbegin(), c_end = m_cfg.m_trusted_root_ca.cend(); c != c_end; ++c) CertAddCertificateContextToStore(store, *c, CERT_STORE_ADD_REPLACE_EXISTING, NULL); // Add all intermediate certificates from the server's certificate chain. #if EAP_TLS < EAP_TLS_SCHANNEL - for (list::const_iterator c = m_server_cert_chain.cbegin(), c_end = m_server_cert_chain.cend(); ++c != c_end;) { + for (auto c = m_server_cert_chain.cbegin(), c_end = m_server_cert_chain.cend(); ++c != c_end;) { const cert_context &_c = *c; if (_c->pCertInfo->Issuer.cbData == _c->pCertInfo->Subject.cbData && memcmp(_c->pCertInfo->Issuer.pbData, _c->pCertInfo->Subject.pbData, _c->pCertInfo->Issuer.cbData) == 0) @@ -1453,7 +1453,7 @@ void eap::method_tls::verify_server_trust() const throw sec_runtime_error(SEC_E_CERT_UNKNOWN, __FUNCTION__ " Can not verify empty certificate chain."); PCCERT_CONTEXT cert_root = context->rgpChain[0]->rgpElement[context->rgpChain[0]->cElement-1]->pCertContext; - for (list::const_iterator c = m_cfg.m_trusted_root_ca.cbegin(), c_end = m_cfg.m_trusted_root_ca.cend();; ++c) { + for (auto c = m_cfg.m_trusted_root_ca.cbegin(), c_end = m_cfg.m_trusted_root_ca.cend();; ++c) { if (c != c_end) { if (cert_root->cbCertEncoded == (*c)->cbCertEncoded && memcmp(cert_root->pbCertEncoded, (*c)->pbCertEncoded, cert_root->cbCertEncoded) == 0) diff --git a/lib/TLS_UI/src/TLS_UI.cpp b/lib/TLS_UI/src/TLS_UI.cpp index a9e1bd0..24b6395 100644 --- a/lib/TLS_UI/src/TLS_UI.cpp +++ b/lib/TLS_UI/src/TLS_UI.cpp @@ -246,7 +246,7 @@ bool wxFQDNListValidator::TransferToWindow() if (m_val) { wxString str; - for (std::list::const_iterator name = m_val->cbegin(), name_end = m_val->cend(); name != name_end; ++name) { + for (auto name = m_val->cbegin(), name_end = m_val->cend(); name != name_end; ++name) { if (!str.IsEmpty()) str += wxT("; "); str += *name; } @@ -421,7 +421,7 @@ wxTLSServerTrustPanel::wxTLSServerTrustPanel(const eap::config_provider &prov, e bool wxTLSServerTrustPanel::TransferDataToWindow() { // Populate trusted CA list. - for (std::list::const_iterator cert = m_cfg.m_trusted_root_ca.cbegin(), cert_end = m_cfg.m_trusted_root_ca.cend(); cert != cert_end; ++cert) + for (auto cert = m_cfg.m_trusted_root_ca.cbegin(), cert_end = m_cfg.m_trusted_root_ca.cend(); cert != cert_end; ++cert) m_root_ca->Append(wxString(eap::get_cert_title(*cert)), new wxCertificateClientData(cert->duplicate())); // Set server acceptable names. The edit control will get populated by validator. diff --git a/lib/TTLS/src/Config.cpp b/lib/TTLS/src/Config.cpp index 6df8fe5..6ff015a 100644 --- a/lib/TTLS/src/Config.cpp +++ b/lib/TTLS/src/Config.cpp @@ -292,7 +292,7 @@ wstring eap::config_method_ttls::get_public_identity(const credentials_ttls &cre } else if (m_anonymous_identity.compare(L"@") == 0) { // Strip username part from identity (RFC 4822). wstring identity(std::move(cred.get_identity())); - wstring::size_type offset = identity.find(L'@'); + auto offset = identity.find(L'@'); if (offset != wstring::npos) identity.erase(0, offset); return identity; } else { diff --git a/lib/TTLS/src/Module.cpp b/lib/TTLS/src/Module.cpp index 5ccbc28..5eb4690 100644 --- a/lib/TTLS/src/Module.cpp +++ b/lib/TTLS/src/Module.cpp @@ -204,7 +204,7 @@ EAP_SESSION_HANDLE eap::peer_ttls::begin_session( config_method_ttls *cfg_method; - for (config_connection::provider_list::iterator cfg_prov = s->m_cfg.m_providers.begin(), cfg_prov_end = s->m_cfg.m_providers.end();; ++cfg_prov) { + for (auto cfg_prov = s->m_cfg.m_providers.begin(), cfg_prov_end = s->m_cfg.m_providers.end();; ++cfg_prov) { if (cfg_prov != cfg_prov_end) { if (s->m_cred.match(*cfg_prov)) { // Matching provider found. @@ -366,7 +366,7 @@ const eap::config_method_ttls* eap::peer_ttls::combine_credentials( user_impersonator impersonating(hTokenImpersonateUser); - for (config_connection::provider_list::const_iterator cfg_prov = cfg.m_providers.cbegin(), cfg_prov_end = cfg.m_providers.cend(); cfg_prov != cfg_prov_end; ++cfg_prov) { + for (auto cfg_prov = cfg.m_providers.cbegin(), cfg_prov_end = cfg.m_providers.cend(); cfg_prov != cfg_prov_end; ++cfg_prov) { wstring target_name(std::move(cfg_prov->get_id())); // Get method configuration. diff --git a/lib/TTLS_UI/src/Module.cpp b/lib/TTLS_UI/src/Module.cpp index b481867..e2db628 100644 --- a/lib/TTLS_UI/src/Module.cpp +++ b/lib/TTLS_UI/src/Module.cpp @@ -184,7 +184,7 @@ void eap::peer_ttls_ui::invoke_identity_ui( // Create credentials dialog and populate it with providers. bool combined = false; wxEAPCredentialsConnectionDialog dlg(&parent); - for (config_connection::provider_list::iterator cfg_prov = cfg.m_providers.begin(), cfg_prov_end = cfg.m_providers.end(); cfg_prov != cfg_prov_end; ++cfg_prov) { + for (auto cfg_prov = cfg.m_providers.begin(), cfg_prov_end = cfg.m_providers.end(); cfg_prov != cfg_prov_end; ++cfg_prov) { wstring target_name(std::move(cfg_prov->get_id())); // Get method configuration. diff --git a/lib/WinStd b/lib/WinStd index 3b4448d..7b0b38a 160000 --- a/lib/WinStd +++ b/lib/WinStd @@ -1 +1 @@ -Subproject commit 3b4448dcf4f2cfd54dc40be1ef262835ac532550 +Subproject commit 7b0b38aab38c777d2b058baaab62fe55cba09b64 diff --git a/lib/wxExtend b/lib/wxExtend index 2e3e188..d7ac16d 160000 --- a/lib/wxExtend +++ b/lib/wxExtend @@ -1 +1 @@ -Subproject commit 2e3e188026b7e6845e9e2b5552faf7589d25cbfc +Subproject commit d7ac16dd8dea0bc0d1e9618093f57e57538c1503