Address some additional code analysis warnings

Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
Simon Rozman 2020-02-12 13:19:11 +01:00
parent 45598f8ef8
commit 5fa66f625d
4 changed files with 15 additions and 16 deletions

View File

@ -46,7 +46,7 @@
#include <codeanalysis\warnings.h> #include <codeanalysis\warnings.h>
#ifndef WXWIDGETS_CODE_ANALYSIS_WARNINGS #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 #endif
#pragma warning(push) #pragma warning(push)
@ -129,8 +129,8 @@ inline bool wxModifyStyleEx(_In_ WXHWND hWnd, _In_ DWORD dwRemove, _In_ DWORD dw
{ {
wxASSERT(IsWindow(hWnd)); wxASSERT(IsWindow(hWnd));
DWORD dwStyle = GetWindowLong(hWnd, GWL_EXSTYLE); const DWORD dwStyle = GetWindowLong(hWnd, GWL_EXSTYLE);
DWORD dwNewStyle = (dwStyle & ~dwRemove) | dwAdd; const DWORD dwNewStyle = (dwStyle & ~dwRemove) | dwAdd;
if(dwStyle == dwNewStyle) if(dwStyle == dwNewStyle)
return false; 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) inline bool wxInitializeLocale(wxLocale &locale, wxLanguage *language = NULL)
{ {
// Read language from configuration. // Read language from configuration.
wxLanguage lang_code; wxLanguage lang_code = wxLANGUAGE_DEFAULT;
wxString lang; wxString lang;
if (wxConfigBase::Get()->Read(wxT("Language"), &lang)) { if (wxConfigBase::Get()->Read(wxT("Language"), &lang)) {
const wxLanguageInfo *lang_info = wxLocale::FindLanguageInfo(lang); const wxLanguageInfo *lang_info = wxLocale::FindLanguageInfo(lang);
lang_code = lang_info ? (wxLanguage)lang_info->Language : wxLANGUAGE_DEFAULT; lang_code = lang_info ? (wxLanguage)lang_info->Language : wxLANGUAGE_DEFAULT;
} else }
lang_code = wxLANGUAGE_DEFAULT;
if (language) if (language)
*language = lang_code; *language = lang_code;

View File

@ -64,7 +64,7 @@ public:
/// - \c true if creation succeeded /// - \c true if creation succeeded
/// - \c false otherwise /// - \c false otherwise
/// ///
inline bool IsOk() const inline bool IsOk() const noexcept
{ {
return m_h != NULL; return m_h != NULL;
} }
@ -73,7 +73,7 @@ public:
/// ///
/// \returns Session handle to be used in native API calls. /// \returns Session handle to be used in native API calls.
/// ///
inline operator HCRYPTPROV() const inline operator HCRYPTPROV() const noexcept
{ {
return m_h; return m_h;
} }
@ -121,7 +121,7 @@ public:
/// - \c true if creation succeeded /// - \c true if creation succeeded
/// - \c false otherwise /// - \c false otherwise
/// ///
inline bool IsOk() const inline bool IsOk() const noexcept
{ {
return m_h != NULL; return m_h != NULL;
} }
@ -130,7 +130,7 @@ public:
/// ///
/// \returns Hash handle to be used in native API calls. /// \returns Hash handle to be used in native API calls.
/// ///
inline operator HCRYPTHASH() const inline operator HCRYPTHASH() const noexcept
{ {
return m_h; return m_h;
} }
@ -195,7 +195,7 @@ public:
if (file.IsOpened()) { if (file.IsOpened()) {
wxMemoryBuffer buf(4*1024); wxMemoryBuffer buf(4*1024);
void *data = buf.GetData(); void *data = buf.GetData();
size_t nBlock = buf.GetBufSize(); const size_t nBlock = buf.GetBufSize();
while (!file.Eof()) while (!file.Eof())
Hash(data, file.Read(data, nBlock)); Hash(data, file.Read(data, nBlock));
@ -298,7 +298,7 @@ public:
/// - \c true if creation succeeded /// - \c true if creation succeeded
/// - \c false otherwise /// - \c false otherwise
/// ///
inline bool IsOk() const inline bool IsOk() const noexcept
{ {
return m_h != NULL; return m_h != NULL;
} }
@ -307,7 +307,7 @@ public:
/// ///
/// \returns Key handle to be used in native API calls. /// \returns Key handle to be used in native API calls.
/// ///
inline operator HCRYPTKEY() const inline operator HCRYPTKEY() const noexcept
{ {
return m_h; return m_h;
} }

View File

@ -45,7 +45,7 @@
/// ///
/// \returns Maximum encoded representation size (in characters) /// \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; return 2*len;
} }
@ -124,7 +124,7 @@ enum class wxHexDecodeMode
/// ///
/// \returns Maximum decoded representation size (in bytes) /// \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; return (len + 1)/2;
} }

View File

@ -24,7 +24,7 @@
// include the grand <wx/wx.h> at a cost of longer pre-compilation phase. // include the grand <wx/wx.h> at a cost of longer pre-compilation phase.
#include <codeanalysis\warnings.h> #include <codeanalysis\warnings.h>
#pragma warning(push) #pragma warning(push)
#pragma warning(disable: ALL_CODE_ANALYSIS_WARNINGS 26812) #pragma warning(disable: ALL_CODE_ANALYSIS_WARNINGS 26812 26814)
#include <wx/wx.h> #include <wx/wx.h>
#pragma warning(pop) #pragma warning(pop)