Address code analysis warnings

Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
Simon Rozman 2019-08-23 04:10:16 +02:00
parent bfa23771d9
commit 23f8c36900
6 changed files with 65 additions and 33 deletions

View File

@ -281,12 +281,12 @@ protected:
private: private:
/// \cond internal /// \cond internal
inline bool DockAppBar(wxAppBarState state); inline _Success_(return != 0) bool DockAppBar(_In_ wxAppBarState state);
inline bool UndockAppBar(); inline _Success_(return != 0) bool UndockAppBar();
inline bool RegisterAutoHide(wxAppBarState state); inline _Success_(return != 0) bool RegisterAutoHide(_In_ wxAppBarState state);
inline bool UnregisterAutoHide(wxAppBarState state); inline _Success_(return != 0) bool UnregisterAutoHide(_In_ wxAppBarState state);
inline bool GetDockedRect(wxAppBarState state, LPRECT rect) const; inline _Success_(return != 0) bool GetDockedRect(_In_ wxAppBarState state, _Out_ LPRECT rect) const;
inline bool GetAutoHideRect(wxAppBarState state, bool bAutoHidden, LPRECT rect) const; inline _Success_(return != 0) bool GetAutoHideRect(_In_ wxAppBarState state, _In_ bool bAutoHidden, _Out_ LPRECT rect) const;
/// \endcond /// \endcond
protected: protected:
@ -516,9 +516,19 @@ inline UINT_PTR wxAppBarGetTaskBarState()
template <class W> template <class W>
wxAppBar<W>::wxAppBar() : wxAppBar<W>::wxAppBar() :
m_taskbarList(NULL), m_state(wxABS_UNKNOWN),
m_timerID(0) m_stateDesired(wxABS_UNKNOWN),
m_flags(0),
m_stateTaskBar(0),
m_timerID(0),
m_taskbarList(NULL)
{ {
m_sizeFloat .cx = -1;
m_sizeFloat .cy = -1;
m_sizeDocked.cx = -1;
m_sizeDocked.cy = -1;
m_sizeMin .cx = -1;
m_sizeMin .cy = -1;
} }
@ -926,6 +936,9 @@ void wxAppBar<W>::ShowAutoHideAppBar(bool show)
GetAutoHideRect(m_state, bHidden, &rcStart); GetAutoHideRect(m_state, bHidden, &rcStart);
if (bFullDragOn && (rcStart.left != rcEnd.left || rcStart.top != rcEnd.top || rcStart.right != rcEnd.right || rcStart.bottom != rcEnd.bottom)) { if (bFullDragOn && (rcStart.left != rcEnd.left || rcStart.top != rcEnd.top || rcStart.right != rcEnd.right || rcStart.bottom != rcEnd.bottom)) {
#pragma warning(push)
#pragma warning(disable: 28159)
// Get our starting and ending time. // Get our starting and ending time.
DWORD dwTimeStart = ::GetTickCount(); DWORD dwTimeStart = ::GetTickCount();
DWORD dwTimeElapsed; DWORD dwTimeElapsed;
@ -949,6 +962,8 @@ void wxAppBar<W>::ShowAutoHideAppBar(bool show)
wxVERIFY(::SetWindowPos(m_hWnd, NULL, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOZORDER | SWP_NOACTIVATE)); wxVERIFY(::SetWindowPos(m_hWnd, NULL, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOZORDER | SWP_NOACTIVATE));
wxVERIFY(::UpdateWindow(m_hWnd)); wxVERIFY(::UpdateWindow(m_hWnd));
} }
#pragma warning(pop)
} }
} }
@ -1112,7 +1127,7 @@ WXLRESULT wxAppBar<W>::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM l
if (m_state != m_stateDesired && wxAppBarIsDocked(m_stateDesired)) { if (m_state != m_stateDesired && wxAppBarIsDocked(m_stateDesired)) {
wxASSERT(lParam); wxASSERT(lParam);
LPWINDOWPOS lpwndpos = (LPWINDOWPOS)lParam; LPWINDOWPOS lpwndpos = (LPWINDOWPOS)lParam;
if (lpwndpos) {
// When about to get docked, fix position and size to avoid Aero Snap interfering with window size. // When about to get docked, fix position and size to avoid Aero Snap interfering with window size.
RECT rect; RECT rect;
GetDockedRect(m_stateDesired, &rect); GetDockedRect(m_stateDesired, &rect);
@ -1122,6 +1137,7 @@ WXLRESULT wxAppBar<W>::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM l
lpwndpos->cy = rect.bottom - rect.top; lpwndpos->cy = rect.bottom - rect.top;
lpwndpos->flags &= ~(SWP_NOMOVE | SWP_NOSIZE); lpwndpos->flags &= ~(SWP_NOMOVE | SWP_NOSIZE);
} }
}
return W::MSWWindowProc(message, wParam, lParam); return W::MSWWindowProc(message, wParam, lParam);
} }
@ -1439,6 +1455,7 @@ WXLRESULT wxAppBar<W>::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM l
/// \cond internal /// \cond internal
template <class W> template <class W>
_Use_decl_annotations_
inline bool wxAppBar<W>::DockAppBar(wxAppBarState state) inline bool wxAppBar<W>::DockAppBar(wxAppBarState state)
{ {
wxASSERT(wxAppBarIsDocked(state)); wxASSERT(wxAppBarIsDocked(state));
@ -1454,6 +1471,7 @@ inline bool wxAppBar<W>::DockAppBar(wxAppBarState state)
template <class W> template <class W>
_Use_decl_annotations_
inline bool wxAppBar<W>::UndockAppBar() inline bool wxAppBar<W>::UndockAppBar()
{ {
// Free application bar's space to undock. // Free application bar's space to undock.
@ -1466,6 +1484,7 @@ inline bool wxAppBar<W>::UndockAppBar()
template <class W> template <class W>
_Use_decl_annotations_
inline bool wxAppBar<W>::RegisterAutoHide(wxAppBarState state) inline bool wxAppBar<W>::RegisterAutoHide(wxAppBarState state)
{ {
wxASSERT(wxAppBarIsDocked(state)); wxASSERT(wxAppBarIsDocked(state));
@ -1498,6 +1517,7 @@ inline bool wxAppBar<W>::RegisterAutoHide(wxAppBarState state)
template <class W> template <class W>
_Use_decl_annotations_
inline bool wxAppBar<W>::UnregisterAutoHide(wxAppBarState state) inline bool wxAppBar<W>::UnregisterAutoHide(wxAppBarState state)
{ {
wxASSERT(wxAppBarIsDocked(state)); wxASSERT(wxAppBarIsDocked(state));
@ -1518,6 +1538,7 @@ inline bool wxAppBar<W>::UnregisterAutoHide(wxAppBarState state)
template <class W> template <class W>
_Use_decl_annotations_
inline bool wxAppBar<W>::GetDockedRect(wxAppBarState state, LPRECT rect) const inline bool wxAppBar<W>::GetDockedRect(wxAppBarState state, LPRECT rect) const
{ {
wxASSERT(wxAppBarIsDocked(state)); wxASSERT(wxAppBarIsDocked(state));
@ -1568,6 +1589,7 @@ inline bool wxAppBar<W>::GetDockedRect(wxAppBarState state, LPRECT rect) const
template <class W> template <class W>
_Use_decl_annotations_
inline bool wxAppBar<W>::GetAutoHideRect(wxAppBarState state, bool bAutoHidden, LPRECT rect) const inline bool wxAppBar<W>::GetAutoHideRect(wxAppBarState state, bool bAutoHidden, LPRECT rect) const
{ {
wxASSERT(wxAppBarIsDocked(state)); wxASSERT(wxAppBarIsDocked(state));

View File

@ -142,7 +142,7 @@ public:
/// - \c true if hashing succeeded /// - \c true if hashing succeeded
/// - \c false otherwise /// - \c false otherwise
/// ///
bool Hash(const void *data, size_t size); _Success_(return != 0) bool Hash(_In_reads_bytes_(size) const void *data, _In_ size_t size);
/// ///
@ -154,7 +154,7 @@ public:
/// - \c true if hashing succeeded /// - \c true if hashing succeeded
/// - \c false otherwise /// - \c false otherwise
/// ///
inline bool Hash(const wxMemoryBuffer &data) inline _Success_(return != 0) bool Hash(_In_ const wxMemoryBuffer &data)
{ {
return Hash(data.GetData(), data.GetDataLen()); return Hash(data.GetData(), data.GetDataLen());
} }
@ -169,7 +169,7 @@ public:
/// - \c true if hashing succeeded /// - \c true if hashing succeeded
/// - \c false otherwise /// - \c false otherwise
/// ///
inline bool HashAsUTF8(const wxString &str) inline _Success_(return != 0) bool HashAsUTF8(_In_ const wxString &str)
{ {
const wxScopedCharBuffer buf(str.ToUTF8()); const wxScopedCharBuffer buf(str.ToUTF8());
return Hash(buf.data(), buf.length()); return Hash(buf.data(), buf.length());
@ -185,7 +185,7 @@ public:
/// - \c true if hashing succeeded /// - \c true if hashing succeeded
/// - \c false otherwise /// - \c false otherwise
/// ///
inline bool HashFile(const wxString &fileName) inline _Success_(return != 0) bool HashFile(_In_ const wxString &fileName)
{ {
wxFFile file(fileName, wxT("rb")); wxFFile file(fileName, wxT("rb"));
if (file.IsOpened()) { if (file.IsOpened()) {
@ -212,19 +212,19 @@ public:
/// - \c true if succeeded /// - \c true if succeeded
/// - \c false otherwise /// - \c false otherwise
/// ///
virtual bool GetValue(wxMemoryBuffer &hash); virtual _Success_(return != 0) bool GetValue(_Out_ wxMemoryBuffer &hash);
/// ///
/// Signs the hash using session key /// Signs the hash using session key
/// ///
/// \param[out] signature Digital signature /// \param[inout] signature Digital signature
/// ///
/// \returns /// \returns
/// - \c true if signing succeeded /// - \c true if signing succeeded
/// - \c false otherwise /// - \c false otherwise
/// ///
bool Sign(wxMemoryBuffer &signature); _Success_(return != 0) bool Sign(_Inout_ wxMemoryBuffer &signature);
/// ///
@ -262,7 +262,7 @@ public:
/// - \c true if succeeded /// - \c true if succeeded
/// - \c false otherwise /// - \c false otherwise
/// ///
virtual bool GetValue(wxMemoryBuffer &hash); virtual _Success_(return != 0) bool GetValue(_Out_ wxMemoryBuffer &hash);
}; };
@ -312,13 +312,13 @@ public:
/// ///
/// Imports private key /// Imports private key
/// ///
bool ImportPrivate(wxCryptoSession &session, const void *data, size_t size); _Success_(return != 0) bool ImportPrivate(_Inout_ wxCryptoSession &session, _In_reads_bytes_(size) const void *data, _In_ size_t size);
/// ///
/// Imports public key /// Imports public key
/// ///
bool ImportPublic(wxCryptoSession &session, const void *data, size_t size); _Success_(return != 0) bool ImportPublic(_Inout_ wxCryptoSession &session, _In_reads_bytes_(size) const void *data, _In_ size_t size);
}; };
@ -334,7 +334,7 @@ public:
/// - \c true if verification succeeded and the hash matches /// - \c true if verification succeeded and the hash matches
/// - \c false otherwise /// - \c false otherwise
/// ///
bool WXEXTEND_API wxCryptoVerifySignature(const wxCryptoHash &hash, const void *signature_data, size_t signature_size, const wxCryptoKey &key); _Success_(return != 0) bool WXEXTEND_API wxCryptoVerifySignature(_In_ const wxCryptoHash &hash, _In_reads_bytes_(signature_size) const void *signature_data, _In_ size_t signature_size, _In_ const wxCryptoKey &key);
/// ///
@ -348,7 +348,7 @@ bool WXEXTEND_API wxCryptoVerifySignature(const wxCryptoHash &hash, const void *
/// - \c true if verification succeeded and the hash matches /// - \c true if verification succeeded and the hash matches
/// - \c false otherwise /// - \c false otherwise
/// ///
inline bool wxCryptoVerifySignature(const wxCryptoHash &hash, const wxMemoryBuffer &signature, const wxCryptoKey &key) inline _Success_(return != 0) bool wxCryptoVerifySignature(_In_ const wxCryptoHash &hash, _In_ const wxMemoryBuffer &signature, _In_ const wxCryptoKey &key)
{ {
return wxCryptoVerifySignature(hash, signature.GetData(), signature.GetDataLen(), key); return wxCryptoVerifySignature(hash, signature.GetData(), signature.GetDataLen(), key);
} }

View File

@ -178,6 +178,7 @@ public:
HMONITOR hMonitor = ::MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST); HMONITOR hMonitor = ::MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST);
wxASSERT_MSG(hMonitor, wxT("error locating monitor")); wxASSERT_MSG(hMonitor, wxT("error locating monitor"));
_Analysis_assume_(hMonitor);
if (!::GetMonitorInfo(hMonitor, &m_mntinfo)) if (!::GetMonitorInfo(hMonitor, &m_mntinfo))
{ {
wxLogLastError(wxS("GetMonitorInfo")); wxLogLastError(wxS("GetMonitorInfo"));
@ -206,6 +207,7 @@ public:
// Get monitor to restore window to. // Get monitor to restore window to.
HMONITOR hMonitor = ::MonitorFromRect(&m_mntinfo.rcWork, MONITOR_DEFAULTTONEAREST); HMONITOR hMonitor = ::MonitorFromRect(&m_mntinfo.rcWork, MONITOR_DEFAULTTONEAREST);
wxASSERT_MSG(hMonitor, wxT("error locating monitor")); wxASSERT_MSG(hMonitor, wxT("error locating monitor"));
_Analysis_assume_(hMonitor);
MONITORINFO mntinfo; MONITORINFO mntinfo;
mntinfo.cbSize = sizeof(mntinfo); mntinfo.cbSize = sizeof(mntinfo);
if (!::GetMonitorInfo(hMonitor, &mntinfo)) if (!::GetMonitorInfo(hMonitor, &mntinfo))
@ -283,7 +285,7 @@ public:
} }
private: private:
static bool GetDPI(HWND hWnd, UINT *dpiHorz, UINT *dpiVert) static bool GetDPI(_In_ HWND hWnd, _Out_ UINT *dpiHorz, _Out_ UINT *dpiVert)
{ {
wxASSERT(dpiHorz); wxASSERT(dpiHorz);
wxASSERT(dpiVert); wxASSERT(dpiVert);
@ -307,7 +309,7 @@ private:
return false; return false;
} }
static bool GetDPI(HMONITOR hMonitor, UINT *dpiHorz, UINT *dpiVert) static bool GetDPI(_In_ HMONITOR hMonitor, _Out_ UINT *dpiHorz, _Out_ UINT *dpiVert)
{ {
wxASSERT(dpiHorz); wxASSERT(dpiHorz);
wxASSERT(dpiVert); wxASSERT(dpiVert);

View File

@ -117,6 +117,6 @@ inline wxString wxXmlEscapeAttr(_In_ const wxString& str)
/// \param[in] node Root node /// \param[in] node Root node
/// ///
/// ///
bool WXEXTEND_API wxXmlHashNode(_In_ wxCryptoHash &hash, const wxXmlNode *node); bool WXEXTEND_API wxXmlHashNode(_In_ wxCryptoHash &hash, _In_ const wxXmlNode *node);
/// @} /// @}

View File

@ -65,6 +65,7 @@ wxCryptoHash::~wxCryptoHash()
} }
_Use_decl_annotations_
bool wxCryptoHash::Hash(const void *data, size_t size) bool wxCryptoHash::Hash(const void *data, size_t size)
{ {
wxASSERT_MSG(m_h, wxT("object uninitialized")); wxASSERT_MSG(m_h, wxT("object uninitialized"));
@ -79,6 +80,7 @@ bool wxCryptoHash::Hash(const void *data, size_t size)
} }
_Use_decl_annotations_
bool wxCryptoHash::GetValue(wxMemoryBuffer &hash) bool wxCryptoHash::GetValue(wxMemoryBuffer &hash)
{ {
wxASSERT_MSG(m_h, wxT("object uninitialized")); wxASSERT_MSG(m_h, wxT("object uninitialized"));
@ -106,6 +108,7 @@ bool wxCryptoHash::GetValue(wxMemoryBuffer &hash)
} }
_Use_decl_annotations_
bool wxCryptoHash::Sign(wxMemoryBuffer &signature) bool wxCryptoHash::Sign(wxMemoryBuffer &signature)
{ {
// Try with the current buffer size first. // Try with the current buffer size first.
@ -146,6 +149,7 @@ wxCryptoHashSHA1::wxCryptoHashSHA1(wxCryptoSession &session)
} }
_Use_decl_annotations_
bool wxCryptoHashSHA1::GetValue(wxMemoryBuffer &hash) bool wxCryptoHashSHA1::GetValue(wxMemoryBuffer &hash)
{ {
wxASSERT_MSG(m_h, wxT("object uninitialized")); wxASSERT_MSG(m_h, wxT("object uninitialized"));
@ -182,6 +186,7 @@ wxCryptoKey::~wxCryptoKey()
} }
_Use_decl_annotations_
bool wxCryptoKey::ImportPrivate(wxCryptoSession &session, const void *data, size_t size) bool wxCryptoKey::ImportPrivate(wxCryptoSession &session, const void *data, size_t size)
{ {
wxASSERT_MSG(!m_h, wxT("object initialized")); wxASSERT_MSG(!m_h, wxT("object initialized"));
@ -209,6 +214,7 @@ bool wxCryptoKey::ImportPrivate(wxCryptoSession &session, const void *data, size
} }
_Use_decl_annotations_
bool wxCryptoKey::ImportPublic(wxCryptoSession &session, const void *data, size_t size) bool wxCryptoKey::ImportPublic(wxCryptoSession &session, const void *data, size_t size)
{ {
wxASSERT_MSG(!m_h, wxT("object initialized")); wxASSERT_MSG(!m_h, wxT("object initialized"));
@ -237,6 +243,7 @@ bool wxCryptoKey::ImportPublic(wxCryptoSession &session, const void *data, size_
// wxCryptoVerifySignature // wxCryptoVerifySignature
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
_Use_decl_annotations_
bool WXEXTEND_API wxCryptoVerifySignature(const wxCryptoHash &hash, const void *signature_data, size_t signature_size, const wxCryptoKey &key) bool WXEXTEND_API wxCryptoVerifySignature(const wxCryptoHash &hash, const void *signature_data, size_t signature_size, const wxCryptoKey &key)
{ {
wxASSERT_MSG(hash.IsOk() , wxT("invalid hash")); wxASSERT_MSG(hash.IsOk() , wxT("invalid hash"));

View File

@ -21,7 +21,8 @@
#include "stdafx.h" #include "stdafx.h"
bool WXEXTEND_API wxXmlHashNode(_In_ wxCryptoHash &hash, const wxXmlNode *node) _Use_decl_annotations_
bool WXEXTEND_API wxXmlHashNode(wxCryptoHash &hash, const wxXmlNode *node)
{ {
wxASSERT_MSG(node, wxT("invalid parameter")); wxASSERT_MSG(node, wxT("invalid parameter"));