Use const for constant local variables in wxWidgets headers
This avoids warnings from MSVS 2017 static analyzer when C++ core rule set is activated. Closes https://github.com/wxWidgets/wxWidgets/pull/819
This commit is contained in:
committed by
Vadim Zeitlin
parent
2fc20abbdd
commit
8dfd799fd5
@@ -280,9 +280,9 @@ public:
|
|||||||
pointer operator->() const { return m_ptr; }
|
pointer operator->() const { return m_ptr; }
|
||||||
itor& operator++() { --m_ptr; return *this; }
|
itor& operator++() { --m_ptr; return *this; }
|
||||||
const itor operator++(int)
|
const itor operator++(int)
|
||||||
{ reverse_iterator tmp = *this; --m_ptr; return tmp; }
|
{ const reverse_iterator tmp = *this; --m_ptr; return tmp; }
|
||||||
itor& operator--() { ++m_ptr; return *this; }
|
itor& operator--() { ++m_ptr; return *this; }
|
||||||
const itor operator--(int) { itor tmp = *this; ++m_ptr; return tmp; }
|
const itor operator--(int) { const itor tmp = *this; ++m_ptr; return tmp; }
|
||||||
bool operator ==(const itor& it) const { return m_ptr == it.m_ptr; }
|
bool operator ==(const itor& it) const { return m_ptr == it.m_ptr; }
|
||||||
bool operator !=(const itor& it) const { return m_ptr != it.m_ptr; }
|
bool operator !=(const itor& it) const { return m_ptr != it.m_ptr; }
|
||||||
};
|
};
|
||||||
@@ -307,9 +307,9 @@ public:
|
|||||||
pointer operator->() const { return m_ptr; }
|
pointer operator->() const { return m_ptr; }
|
||||||
itor& operator++() { --m_ptr; return *this; }
|
itor& operator++() { --m_ptr; return *this; }
|
||||||
const itor operator++(int)
|
const itor operator++(int)
|
||||||
{ itor tmp = *this; --m_ptr; return tmp; }
|
{ const itor tmp = *this; --m_ptr; return tmp; }
|
||||||
itor& operator--() { ++m_ptr; return *this; }
|
itor& operator--() { ++m_ptr; return *this; }
|
||||||
const itor operator--(int) { itor tmp = *this; ++m_ptr; return tmp; }
|
const itor operator--(int) { const itor tmp = *this; ++m_ptr; return tmp; }
|
||||||
bool operator ==(const itor& it) const { return m_ptr == it.m_ptr; }
|
bool operator ==(const itor& it) const { return m_ptr == it.m_ptr; }
|
||||||
bool operator !=(const itor& it) const { return m_ptr != it.m_ptr; }
|
bool operator !=(const itor& it) const { return m_ptr != it.m_ptr; }
|
||||||
};
|
};
|
||||||
@@ -421,7 +421,7 @@ public:
|
|||||||
wxString* GetStrings()
|
wxString* GetStrings()
|
||||||
{
|
{
|
||||||
if( m_strings ) return m_strings;
|
if( m_strings ) return m_strings;
|
||||||
size_t count = m_array.GetCount();
|
const size_t count = m_array.GetCount();
|
||||||
m_strings = new wxString[count];
|
m_strings = new wxString[count];
|
||||||
for( size_t i = 0; i < count; ++i )
|
for( size_t i = 0; i < count; ++i )
|
||||||
m_strings[i] = m_array[i];
|
m_strings[i] = m_array[i];
|
||||||
|
@@ -47,7 +47,7 @@ public:
|
|||||||
if (it == m_methods.end())
|
if (it == m_methods.end())
|
||||||
return false;
|
return false;
|
||||||
wxShadowObjectMethod method = it->second;
|
wxShadowObjectMethod method = it->second;
|
||||||
int ret = (*method)(window, param);
|
const int ret = (*method)(window, param);
|
||||||
if (returnValue)
|
if (returnValue)
|
||||||
*returnValue = ret;
|
*returnValue = ret;
|
||||||
return true;
|
return true;
|
||||||
|
@@ -972,7 +972,7 @@ public:
|
|||||||
// propagation level value
|
// propagation level value
|
||||||
int StopPropagation()
|
int StopPropagation()
|
||||||
{
|
{
|
||||||
int propagationLevel = m_propagationLevel;
|
const int propagationLevel = m_propagationLevel;
|
||||||
m_propagationLevel = wxEVENT_PROPAGATE_NONE;
|
m_propagationLevel = wxEVENT_PROPAGATE_NONE;
|
||||||
return propagationLevel;
|
return propagationLevel;
|
||||||
}
|
}
|
||||||
|
@@ -65,7 +65,7 @@ public:
|
|||||||
|
|
||||||
// assign an existing file descriptor and get it back from wxFile object
|
// assign an existing file descriptor and get it back from wxFile object
|
||||||
void Attach(int lfd) { Close(); m_fd = lfd; m_lasterror = 0; }
|
void Attach(int lfd) { Close(); m_fd = lfd; m_lasterror = 0; }
|
||||||
int Detach() { int fdOld = m_fd; m_fd = fd_invalid; return fdOld; }
|
int Detach() { const int fdOld = m_fd; m_fd = fd_invalid; return fdOld; }
|
||||||
int fd() const { return m_fd; }
|
int fd() const { return m_fd; }
|
||||||
|
|
||||||
// read/write (unbuffered)
|
// read/write (unbuffered)
|
||||||
|
@@ -244,7 +244,7 @@ public:
|
|||||||
if ( !m_data )
|
if ( !m_data )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
wxStringToNumHashMap::const_iterator it = m_data->numValues.find(key);
|
const wxStringToNumHashMap::const_iterator it = m_data->numValues.find(key);
|
||||||
if ( it == m_data->numValues.end() )
|
if ( it == m_data->numValues.end() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -258,7 +258,7 @@ public:
|
|||||||
if ( !m_data )
|
if ( !m_data )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
wxStringToStringHashMap::const_iterator it = m_data->strValues.find(key);
|
const wxStringToStringHashMap::const_iterator it = m_data->strValues.find(key);
|
||||||
if ( it == m_data->strValues.end() )
|
if ( it == m_data->strValues.end() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -379,7 +379,7 @@ public:
|
|||||||
return EnableThreadLogging(enable);
|
return EnableThreadLogging(enable);
|
||||||
#endif // wxUSE_THREADS
|
#endif // wxUSE_THREADS
|
||||||
|
|
||||||
bool doLogOld = ms_doLog;
|
const bool doLogOld = ms_doLog;
|
||||||
ms_doLog = enable;
|
ms_doLog = enable;
|
||||||
return doLogOld;
|
return doLogOld;
|
||||||
}
|
}
|
||||||
|
@@ -1060,7 +1060,7 @@ inline wxULongLong operator+(unsigned long l, const wxULongLong& ull) { return u
|
|||||||
|
|
||||||
inline wxLongLong operator-(unsigned long l, const wxULongLong& ull)
|
inline wxLongLong operator-(unsigned long l, const wxULongLong& ull)
|
||||||
{
|
{
|
||||||
wxULongLong ret = wxULongLong(l) - ull;
|
const wxULongLong ret = wxULongLong(l) - ull;
|
||||||
return wxLongLong((wxInt32)ret.GetHi(),ret.GetLo());
|
return wxLongLong((wxInt32)ret.GetHi(),ret.GetLo());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -38,7 +38,7 @@
|
|||||||
// return true if ok, false otherwise
|
// return true if ok, false otherwise
|
||||||
inline bool wxOleInitialize()
|
inline bool wxOleInitialize()
|
||||||
{
|
{
|
||||||
HRESULT
|
const HRESULT
|
||||||
hr = ::OleInitialize(NULL);
|
hr = ::OleInitialize(NULL);
|
||||||
|
|
||||||
// RPC_E_CHANGED_MODE indicates that OLE had been already initialized
|
// RPC_E_CHANGED_MODE indicates that OLE had been already initialized
|
||||||
|
@@ -207,7 +207,7 @@ public:
|
|||||||
wxCHECK_MSG( m_iocp != INVALID_HANDLE_VALUE, false, "IOCP not init" );
|
wxCHECK_MSG( m_iocp != INVALID_HANDLE_VALUE, false, "IOCP not init" );
|
||||||
|
|
||||||
// The special values of 0 will make GetStatus() return Status_Exit.
|
// The special values of 0 will make GetStatus() return Status_Exit.
|
||||||
int ret = PostQueuedCompletionStatus(m_iocp, 0, 0, NULL);
|
const int ret = PostQueuedCompletionStatus(m_iocp, 0, 0, NULL);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
{
|
{
|
||||||
wxLogSysError(_("Unable to post completion status"));
|
wxLogSysError(_("Unable to post completion status"));
|
||||||
@@ -244,7 +244,7 @@ public:
|
|||||||
wxCHECK_MSG( count && watch && overlapped, Status_Error,
|
wxCHECK_MSG( count && watch && overlapped, Status_Error,
|
||||||
"Output parameters can't be NULL" );
|
"Output parameters can't be NULL" );
|
||||||
|
|
||||||
int ret = GetQueuedCompletionStatus(m_iocp, count, (ULONG_PTR *)watch,
|
const int ret = GetQueuedCompletionStatus(m_iocp, count, (ULONG_PTR *)watch,
|
||||||
overlapped, INFINITE);
|
overlapped, INFINITE);
|
||||||
if ( ret != 0 )
|
if ( ret != 0 )
|
||||||
{
|
{
|
||||||
|
@@ -994,7 +994,7 @@ public:
|
|||||||
// This is logically equivalent to strlen(str.mb_str()) but avoids
|
// This is logically equivalent to strlen(str.mb_str()) but avoids
|
||||||
// actually converting the string to multibyte and just computes the
|
// actually converting the string to multibyte and just computes the
|
||||||
// length that it would have after conversion.
|
// length that it would have after conversion.
|
||||||
size_t ofs = wxConvLibc.FromWChar(NULL, 0, str.wc_str(), str.length());
|
const size_t ofs = wxConvLibc.FromWChar(NULL, 0, str.wc_str(), str.length());
|
||||||
return ofs == wxCONV_FAILED ? 0 : static_cast<ptrdiff_t>(ofs);
|
return ofs == wxCONV_FAILED ? 0 : static_cast<ptrdiff_t>(ofs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2161,17 +2161,17 @@ public:
|
|||||||
// searching (return starting index, or -1 if not found)
|
// searching (return starting index, or -1 if not found)
|
||||||
int Find(const wxString& sub) const // like strstr
|
int Find(const wxString& sub) const // like strstr
|
||||||
{
|
{
|
||||||
size_type idx = find(sub);
|
const size_type idx = find(sub);
|
||||||
return (idx == npos) ? wxNOT_FOUND : (int)idx;
|
return (idx == npos) ? wxNOT_FOUND : (int)idx;
|
||||||
}
|
}
|
||||||
int Find(const char *sub) const // like strstr
|
int Find(const char *sub) const // like strstr
|
||||||
{
|
{
|
||||||
size_type idx = find(sub);
|
const size_type idx = find(sub);
|
||||||
return (idx == npos) ? wxNOT_FOUND : (int)idx;
|
return (idx == npos) ? wxNOT_FOUND : (int)idx;
|
||||||
}
|
}
|
||||||
int Find(const wchar_t *sub) const // like strstr
|
int Find(const wchar_t *sub) const // like strstr
|
||||||
{
|
{
|
||||||
size_type idx = find(sub);
|
const size_type idx = find(sub);
|
||||||
return (idx == npos) ? wxNOT_FOUND : (int)idx;
|
return (idx == npos) ? wxNOT_FOUND : (int)idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user