Merge branch 'fix-shorten-64-to-32-warn'

Fix clang warnings about truncating 64 bit ints to 32 bits.

See #23301.
This commit is contained in:
Vadim Zeitlin 2023-02-27 16:08:55 +01:00
commit 2c530fa513
5 changed files with 14 additions and 8 deletions

View file

@ -87,7 +87,7 @@ public:
virtual bool LoadFile(const wxString& file = wxT("")) override;
virtual bool DisplaySection(int sectionNo) override;
virtual bool DisplaySection(const wxString& section) override { return Display(section); }
virtual bool DisplayBlock(long blockNo) override { return DisplaySection(blockNo); }
virtual bool DisplayBlock(long blockNo) override { return DisplaySection(static_cast<int>(blockNo)); }
virtual bool DisplayTextPopup(const wxString& text, const wxPoint& pos) override;
virtual void SetFrameParameters(const wxString& titleFormat,

View file

@ -88,7 +88,7 @@ public:
// override wxSocketBase::SetTimeout function to avoid that the internal
// m_uiDefaultTimeout goes out-of-sync:
virtual void SetTimeout(long seconds) override
{ SetDefaultTimeout(seconds); }
{ SetDefaultTimeout(static_cast<wxUint32>(seconds)); }
// logging support: each wxProtocol object may have the associated logger

View file

@ -85,8 +85,13 @@ public:
// return the total number of selected items
unsigned GetSelectedCount() const
{
return m_defaultState ? m_count - m_itemsSel.GetCount()
: m_itemsSel.GetCount();
// we can we never have more than UINT_MAX selected items, knowing that
// we store the total number of items in an unsigned m_count, so the
// cast is safe.
return static_cast<unsigned>(
m_defaultState ? m_count - m_itemsSel.GetCount()
: m_itemsSel.GetCount()
);
}
// type of a "cookie" used to preserve the iteration state, this is an

View file

@ -553,7 +553,7 @@ private:
c->Reset();
// and remember the last used element
LastUsedCacheElement() = c - cacheBegin;
LastUsedCacheElement() = static_cast<unsigned int>(c - cacheBegin);
}
return c;

View file

@ -349,13 +349,14 @@
GCC_TURN_OFF(padded)
#endif // gcc >= 4.6
// Do the same for clang too except here we don't bother with the individual
// warnings and just enable the usual ones because clang mostly includes all
// the useful warnings in them anyhow.
// Do the same for clang too except here most of the useful warnings are
// already included in -Wall, so we just need a few more.
#ifdef CLANG_TURN_ON
CLANG_TURN_ON(all)
CLANG_TURN_ON(extra)
CLANG_TURN_ON(pedantic)
CLANG_TURN_ON(shorten-64-to-32)
#endif // clang