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:
orbitcowboy
2018-05-29 09:54:19 +02:00
committed by Vadim Zeitlin
parent 2fc20abbdd
commit 8dfd799fd5
9 changed files with 19 additions and 19 deletions

View File

@@ -280,9 +280,9 @@ public:
pointer operator->() const { return m_ptr; }
itor& operator++() { --m_ptr; return *this; }
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; }
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; }
};
@@ -307,9 +307,9 @@ public:
pointer operator->() const { return m_ptr; }
itor& operator++() { --m_ptr; return *this; }
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; }
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; }
};
@@ -421,7 +421,7 @@ public:
wxString* GetStrings()
{
if( m_strings ) return m_strings;
size_t count = m_array.GetCount();
const size_t count = m_array.GetCount();
m_strings = new wxString[count];
for( size_t i = 0; i < count; ++i )
m_strings[i] = m_array[i];

View File

@@ -47,7 +47,7 @@ public:
if (it == m_methods.end())
return false;
wxShadowObjectMethod method = it->second;
int ret = (*method)(window, param);
const int ret = (*method)(window, param);
if (returnValue)
*returnValue = ret;
return true;

View File

@@ -972,7 +972,7 @@ public:
// propagation level value
int StopPropagation()
{
int propagationLevel = m_propagationLevel;
const int propagationLevel = m_propagationLevel;
m_propagationLevel = wxEVENT_PROPAGATE_NONE;
return propagationLevel;
}

View File

@@ -65,7 +65,7 @@ public:
// assign an existing file descriptor and get it back from wxFile object
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; }
// read/write (unbuffered)

View File

@@ -244,7 +244,7 @@ public:
if ( !m_data )
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() )
return false;
@@ -258,7 +258,7 @@ public:
if ( !m_data )
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() )
return false;
@@ -379,7 +379,7 @@ public:
return EnableThreadLogging(enable);
#endif // wxUSE_THREADS
bool doLogOld = ms_doLog;
const bool doLogOld = ms_doLog;
ms_doLog = enable;
return doLogOld;
}

View File

@@ -1060,7 +1060,7 @@ inline wxULongLong operator+(unsigned long l, const wxULongLong& ull) { return u
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());
}

View File

@@ -38,7 +38,7 @@
// return true if ok, false otherwise
inline bool wxOleInitialize()
{
HRESULT
const HRESULT
hr = ::OleInitialize(NULL);
// RPC_E_CHANGED_MODE indicates that OLE had been already initialized

View File

@@ -207,7 +207,7 @@ public:
wxCHECK_MSG( m_iocp != INVALID_HANDLE_VALUE, false, "IOCP not init" );
// 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)
{
wxLogSysError(_("Unable to post completion status"));
@@ -244,7 +244,7 @@ public:
wxCHECK_MSG( count && watch && overlapped, Status_Error,
"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);
if ( ret != 0 )
{

View File

@@ -994,7 +994,7 @@ public:
// This is logically equivalent to strlen(str.mb_str()) but avoids
// actually converting the string to multibyte and just computes the
// 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);
}
@@ -2161,17 +2161,17 @@ public:
// searching (return starting index, or -1 if not found)
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;
}
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;
}
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;
}