From 5fa66f625db9095e71b4bbe0fb03a389956700c7 Mon Sep 17 00:00:00 2001 From: Simon Rozman Date: Wed, 12 Feb 2020 13:19:11 +0100 Subject: [PATCH] Address some additional code analysis warnings Signed-off-by: Simon Rozman --- include/wxex/common.h | 11 +++++------ include/wxex/crypto.h | 14 +++++++------- include/wxex/hex.h | 4 ++-- src/pch.h | 2 +- 4 files changed, 15 insertions(+), 16 deletions(-) diff --git a/include/wxex/common.h b/include/wxex/common.h index 45ae02f..98d8c3b 100644 --- a/include/wxex/common.h +++ b/include/wxex/common.h @@ -46,7 +46,7 @@ #include #ifndef WXWIDGETS_CODE_ANALYSIS_WARNINGS -#define WXWIDGETS_CODE_ANALYSIS_WARNINGS ALL_CODE_ANALYSIS_WARNINGS 26812 +#define WXWIDGETS_CODE_ANALYSIS_WARNINGS ALL_CODE_ANALYSIS_WARNINGS 26812 26814 #endif #pragma warning(push) @@ -129,8 +129,8 @@ inline bool wxModifyStyleEx(_In_ WXHWND hWnd, _In_ DWORD dwRemove, _In_ DWORD dw { wxASSERT(IsWindow(hWnd)); - DWORD dwStyle = GetWindowLong(hWnd, GWL_EXSTYLE); - DWORD dwNewStyle = (dwStyle & ~dwRemove) | dwAdd; + const DWORD dwStyle = GetWindowLong(hWnd, GWL_EXSTYLE); + const DWORD dwNewStyle = (dwStyle & ~dwRemove) | dwAdd; if(dwStyle == dwNewStyle) return false; @@ -159,13 +159,12 @@ inline bool wxModifyStyleEx(_In_ WXHWND hWnd, _In_ DWORD dwRemove, _In_ DWORD dw inline bool wxInitializeLocale(wxLocale &locale, wxLanguage *language = NULL) { // Read language from configuration. - wxLanguage lang_code; + wxLanguage lang_code = wxLANGUAGE_DEFAULT; wxString lang; if (wxConfigBase::Get()->Read(wxT("Language"), &lang)) { const wxLanguageInfo *lang_info = wxLocale::FindLanguageInfo(lang); lang_code = lang_info ? (wxLanguage)lang_info->Language : wxLANGUAGE_DEFAULT; - } else - lang_code = wxLANGUAGE_DEFAULT; + } if (language) *language = lang_code; diff --git a/include/wxex/crypto.h b/include/wxex/crypto.h index 2b558e1..316d511 100644 --- a/include/wxex/crypto.h +++ b/include/wxex/crypto.h @@ -64,7 +64,7 @@ public: /// - \c true if creation succeeded /// - \c false otherwise /// - inline bool IsOk() const + inline bool IsOk() const noexcept { return m_h != NULL; } @@ -73,7 +73,7 @@ public: /// /// \returns Session handle to be used in native API calls. /// - inline operator HCRYPTPROV() const + inline operator HCRYPTPROV() const noexcept { return m_h; } @@ -121,7 +121,7 @@ public: /// - \c true if creation succeeded /// - \c false otherwise /// - inline bool IsOk() const + inline bool IsOk() const noexcept { return m_h != NULL; } @@ -130,7 +130,7 @@ public: /// /// \returns Hash handle to be used in native API calls. /// - inline operator HCRYPTHASH() const + inline operator HCRYPTHASH() const noexcept { return m_h; } @@ -195,7 +195,7 @@ public: if (file.IsOpened()) { wxMemoryBuffer buf(4*1024); void *data = buf.GetData(); - size_t nBlock = buf.GetBufSize(); + const size_t nBlock = buf.GetBufSize(); while (!file.Eof()) Hash(data, file.Read(data, nBlock)); @@ -298,7 +298,7 @@ public: /// - \c true if creation succeeded /// - \c false otherwise /// - inline bool IsOk() const + inline bool IsOk() const noexcept { return m_h != NULL; } @@ -307,7 +307,7 @@ public: /// /// \returns Key handle to be used in native API calls. /// - inline operator HCRYPTKEY() const + inline operator HCRYPTKEY() const noexcept { return m_h; } diff --git a/include/wxex/hex.h b/include/wxex/hex.h index 6f61982..9362387 100644 --- a/include/wxex/hex.h +++ b/include/wxex/hex.h @@ -45,7 +45,7 @@ /// /// \returns Maximum encoded representation size (in characters) /// -inline size_t wxHexEncodedSize(size_t len) +inline constexpr size_t wxHexEncodedSize(size_t len) noexcept { return 2*len; } @@ -124,7 +124,7 @@ enum class wxHexDecodeMode /// /// \returns Maximum decoded representation size (in bytes) /// -inline size_t wxHexDecodedSize(size_t len) +inline constexpr size_t wxHexDecodedSize(size_t len) noexcept { return (len + 1)/2; } diff --git a/src/pch.h b/src/pch.h index 3b41de2..2edb700 100644 --- a/src/pch.h +++ b/src/pch.h @@ -24,7 +24,7 @@ // include the grand at a cost of longer pre-compilation phase. #include #pragma warning(push) -#pragma warning(disable: ALL_CODE_ANALYSIS_WARNINGS 26812) +#pragma warning(disable: ALL_CODE_ANALYSIS_WARNINGS 26812 26814) #include #pragma warning(pop)