summaryrefslogtreecommitdiff
path: root/vcl/source
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2020-01-27 09:30:39 +0100
committerStephan Bergmann <sbergman@redhat.com>2020-01-28 07:42:15 +0100
commitaef7feb3e695ecf6d411f0777196dcc4281e201a (patch)
tree6adff7e08e6431ff87c575d026e330badb9a6cd3 /vcl/source
parent65f007c629e5a7b2710e21e3f26164b433576e27 (diff)
New loplugin:unsignedcompare
"Find explicit casts from signed to unsigned integer in comparison against unsigned integer, where the cast is presumably used to avoid warnings about signed vs. unsigned comparisons, and could thus be replaced with o3tl::make_unsigned for clairty." (compilerplugins/clang/unsignedcompare.cxx) o3tl::make_unsigned requires its argument to be non-negative, and there is a chance that some original code like static_cast<sal_uInt32>(n) >= c used the explicit cast to actually force a (potentially negative) value of sal_Int32 to be interpreted as an unsigned sal_uInt32, rather than using the cast to avoid a false "signed vs. unsigned comparison" warning in a case where n is known to be non-negative. It appears that restricting this plugin to non- equality comparisons (<, >, <=, >=) and excluding equality comparisons (==, !=) is a useful heuristic to avoid such false positives. The only remainging false positive I found was 0288c8ffecff4956a52b9147d441979941e8b87f "Rephrase cast from sal_Int32 to sal_uInt32". But which of course does not mean that there were no further false positivies that I missed. So this commit may accidentally introduce some false hits of the assert in o3tl::make_unsigned. At least, it passed a full (Linux ASan+UBSan --enable-dbgutil) `make check && make screenshot`. It is by design that o3tl::make_unsigned only accepts signed integer parameter types (and is not defined as a nop for unsigned ones), to avoid unnecessary uses which would in general be suspicious. But the STATIC_ARRAY_SELECT macro in include/oox/helper/helper.hxx is used with both signed and unsigned types, so needs a little oox::detail::make_unsigned helper function for now. (The ultimate fix being to get rid of the macro in the first place.) Change-Id: Ia4adc9f44c70ad1dfd608784cac39ee922c32175 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87556 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'vcl/source')
-rw-r--r--vcl/source/app/salvtables.cxx17
-rw-r--r--vcl/source/control/edit.cxx10
-rw-r--r--vcl/source/control/imivctl.hxx7
-rw-r--r--vcl/source/control/imivctl2.cxx2
-rw-r--r--vcl/source/control/imp_listbox.cxx5
-rw-r--r--vcl/source/filter/FilterConfigCache.cxx5
-rw-r--r--vcl/source/fontsubset/cff.cxx3
-rw-r--r--vcl/source/gdi/dibtools.cxx7
-rw-r--r--vcl/source/gdi/pdfextoutdevdata.cxx7
-rw-r--r--vcl/source/gdi/pdfwriter_impl.hxx3
-rw-r--r--vcl/source/gdi/svmconverter.cxx6
-rw-r--r--vcl/source/treelist/svimpbox.cxx7
-rw-r--r--vcl/source/treelist/svtabbx.cxx3
-rw-r--r--vcl/source/window/syswin.cxx10
-rw-r--r--vcl/source/window/winproc.cxx5
15 files changed, 59 insertions, 38 deletions
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 687c0d63723a..46f2f070e3ca 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -19,6 +19,7 @@
#include <com/sun/star/accessibility/AccessibleRelationType.hpp>
#include <com/sun/star/awt/XWindow.hpp>
+#include <o3tl/safeint.hxx>
#include <officecfg/Office/Common.hxx>
#include <iconview.hxx>
#include <salframe.hxx>
@@ -3557,7 +3558,7 @@ struct SalInstanceTreeIter : public weld::TreeIter
if (static_cast<size_t>(col) == pEntry->ItemCount())
return TRISTATE_FALSE;
- assert(col >= 0 && static_cast<size_t>(col) < pEntry->ItemCount());
+ assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount());
SvLBoxItem& rItem = pEntry->GetItem(col);
assert(dynamic_cast<SvLBoxButton*>(&rItem));
SvLBoxButton& rToggle = static_cast<SvLBoxButton&>(rItem);
@@ -3572,7 +3573,7 @@ struct SalInstanceTreeIter : public weld::TreeIter
{
++col; //skip dummy/expander column
- assert(col >= 0 && static_cast<size_t>(col) < pEntry->ItemCount());
+ assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount());
SvLBoxItem& rItem = pEntry->GetItem(col);
assert(dynamic_cast<SvLBoxString*>(&rItem));
return static_cast<SvLBoxString&>(rItem).IsEmphasized();
@@ -4004,7 +4005,7 @@ public:
if (static_cast<size_t>(col) == pEntry->ItemCount())
return OUString();
- assert(col >= 0 && static_cast<size_t>(col) < pEntry->ItemCount());
+ assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount());
SvLBoxItem& rItem = pEntry->GetItem(col);
assert(dynamic_cast<SvLBoxString*>(&rItem));
return static_cast<SvLBoxString&>(rItem).GetText();
@@ -4038,7 +4039,7 @@ public:
}
else
{
- assert(col >= 0 && static_cast<size_t>(col) < pEntry->ItemCount());
+ assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount());
SvLBoxItem& rItem = pEntry->GetItem(col);
assert(dynamic_cast<SvLBoxString*>(&rItem));
static_cast<SvLBoxString&>(rItem).SetText(rText);
@@ -4072,7 +4073,7 @@ public:
++col; //skip dummy/expander column
- assert(col >= 0 && static_cast<size_t>(col) < pEntry->ItemCount());
+ assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount());
SvLBoxItem& rItem = pEntry->GetItem(col);
rItem.Enable(bSensitive);
@@ -4141,7 +4142,7 @@ public:
m_xTreeView->CheckBoxInserted(pEntry);
}
- assert(col >= 0 && static_cast<size_t>(col) < pEntry->ItemCount());
+ assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount());
SvLBoxItem& rItem = pEntry->GetItem(col);
assert(dynamic_cast<SvLBoxButton*>(&rItem));
switch (eState)
@@ -4176,7 +4177,7 @@ public:
{
++col; //skip dummy/expander column
- assert(col >= 0 && static_cast<size_t>(col) < pEntry->ItemCount());
+ assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount());
SvLBoxItem& rItem = pEntry->GetItem(col);
assert(dynamic_cast<SvLBoxString*>(&rItem));
static_cast<SvLBoxString&>(rItem).Emphasize(bOn);
@@ -4249,7 +4250,7 @@ public:
}
else
{
- assert(col >= 0 && static_cast<size_t>(col) < pEntry->ItemCount());
+ assert(col >= 0 && o3tl::make_unsigned(col) < pEntry->ItemCount());
SvLBoxItem& rItem = pEntry->GetItem(col);
assert(dynamic_cast<SvLBoxContextBmp*>(&rItem));
static_cast<SvLBoxContextBmp&>(rItem).SetBitmap1(rImage);
diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx
index 72c09a1e522a..a8a2cbe6f833 100644
--- a/vcl/source/control/edit.cxx
+++ b/vcl/source/control/edit.cxx
@@ -59,7 +59,7 @@
#include <i18nlangtag/languagetag.hxx>
#include <vcl/unohelp2.hxx>
-
+#include <o3tl/safeint.hxx>
#include <officecfg/Office/Common.hxx>
#include <memory>
@@ -471,7 +471,7 @@ void Edit::ImplRepaint(vcl::RenderContext& rRenderContext, const tools::Rectangl
if (nLen)
{
- if (static_cast<size_t>(2 * nLen) > SAL_N_ELEMENTS(nDXBuffer))
+ if (o3tl::make_unsigned(2 * nLen) > SAL_N_ELEMENTS(nDXBuffer))
{
pDXBuffer.reset(new long[2 * (nLen + 1)]);
pDX = pDXBuffer.get();
@@ -1060,7 +1060,7 @@ void Edit::ImplShowCursor( bool bOnlyIfVisible )
if( !aText.isEmpty() )
{
- if( static_cast<size_t>(2*aText.getLength()) > SAL_N_ELEMENTS(nDXBuffer) )
+ if( o3tl::make_unsigned(2*aText.getLength()) > SAL_N_ELEMENTS(nDXBuffer) )
{
pDXBuffer.reset(new long[2*(aText.getLength()+1)]);
pDX = pDXBuffer.get();
@@ -1181,7 +1181,7 @@ sal_Int32 Edit::ImplGetCharPos( const Point& rWindowPos ) const
long nDXBuffer[256];
std::unique_ptr<long[]> pDXBuffer;
long* pDX = nDXBuffer;
- if( static_cast<size_t>(2*aText.getLength()) > SAL_N_ELEMENTS(nDXBuffer) )
+ if( o3tl::make_unsigned(2*aText.getLength()) > SAL_N_ELEMENTS(nDXBuffer) )
{
pDXBuffer.reset(new long[2*(aText.getLength()+1)]);
pDX = pDXBuffer.get();
@@ -2112,7 +2112,7 @@ void Edit::Command( const CommandEvent& rCEvt )
if( !aText.isEmpty() )
{
- if( static_cast<size_t>(2*aText.getLength()) > SAL_N_ELEMENTS(nDXBuffer) )
+ if( o3tl::make_unsigned(2*aText.getLength()) > SAL_N_ELEMENTS(nDXBuffer) )
{
pDXBuffer.reset(new long[2*(aText.getLength()+1)]);
pDX = pDXBuffer.get();
diff --git a/vcl/source/control/imivctl.hxx b/vcl/source/control/imivctl.hxx
index be3a6ea287c2..a2765a95aea9 100644
--- a/vcl/source/control/imivctl.hxx
+++ b/vcl/source/control/imivctl.hxx
@@ -20,6 +20,9 @@
#ifndef INCLUDED_SVTOOLS_SOURCE_CONTNR_IMIVCTL_HXX
#define INCLUDED_SVTOOLS_SOURCE_CONTNR_IMIVCTL_HXX
+#include <sal/config.h>
+
+#include <o3tl/safeint.hxx>
#include <vcl/ivctrl.hxx>
#include <vcl/virdev.hxx>
#include <vcl/scrbar.hxx>
@@ -490,8 +493,8 @@ public:
void OccupyGrids( const SvxIconChoiceCtrlEntry* );
void OccupyGrid( GridId nId )
{
- DBG_ASSERT(!_pGridMap || nId<static_cast<sal_uLong>(_nGridCols*_nGridRows),"OccupyGrid: Bad GridId");
- if(_pGridMap && nId < static_cast<sal_uLong>(_nGridCols *_nGridRows) )
+ DBG_ASSERT(!_pGridMap || nId<o3tl::make_unsigned(_nGridCols*_nGridRows),"OccupyGrid: Bad GridId");
+ if(_pGridMap && nId < o3tl::make_unsigned(_nGridCols *_nGridRows) )
_pGridMap[ nId ] = true;
}
diff --git a/vcl/source/control/imivctl2.cxx b/vcl/source/control/imivctl2.cxx
index f7d2d787f864..284921f8f62e 100644
--- a/vcl/source/control/imivctl2.cxx
+++ b/vcl/source/control/imivctl2.cxx
@@ -597,7 +597,7 @@ GridId IcnGridMap_Impl::GetGrid( const Point& rDocPos )
nY = _nGridRows - 1;
}
GridId nId = GetGrid( static_cast<sal_uInt16>(nX), static_cast<sal_uInt16>(nY) );
- DBG_ASSERT(nId <static_cast<sal_uLong>(_nGridCols*_nGridRows),"GetGrid failed");
+ DBG_ASSERT(nId <o3tl::make_unsigned(_nGridCols*_nGridRows),"GetGrid failed");
return nId;
}
diff --git a/vcl/source/control/imp_listbox.cxx b/vcl/source/control/imp_listbox.cxx
index c65f63b4b782..8e912aeda4f2 100644
--- a/vcl/source/control/imp_listbox.cxx
+++ b/vcl/source/control/imp_listbox.cxx
@@ -35,6 +35,7 @@
#include <rtl/instance.hxx>
#include <sal/log.hxx>
+#include <o3tl/safeint.hxx>
#include <osl/diagnose.h>
#include <comphelper/string.hxx>
#include <comphelper/processfactory.hxx>
@@ -81,7 +82,7 @@ void ImplEntryList::Clear()
void ImplEntryList::SelectEntry( sal_Int32 nPos, bool bSelect )
{
- if (0 <= nPos && static_cast<size_t>(nPos) < maEntries.size())
+ if (0 <= nPos && o3tl::make_unsigned(nPos) < maEntries.size())
{
std::vector<std::unique_ptr<ImplEntryType> >::iterator iter = maEntries.begin()+nPos;
@@ -218,7 +219,7 @@ sal_Int32 ImplEntryList::InsertEntry( sal_Int32 nPos, ImplEntryType* pNewEntry,
void ImplEntryList::RemoveEntry( sal_Int32 nPos )
{
- if (0 <= nPos && static_cast<size_t>(nPos) < maEntries.size())
+ if (0 <= nPos && o3tl::make_unsigned(nPos) < maEntries.size())
{
std::vector<std::unique_ptr<ImplEntryType> >::iterator iter = maEntries.begin()+ nPos;
diff --git a/vcl/source/filter/FilterConfigCache.cxx b/vcl/source/filter/FilterConfigCache.cxx
index 0ed0a431e235..5321ea2599c5 100644
--- a/vcl/source/filter/FilterConfigCache.cxx
+++ b/vcl/source/filter/FilterConfigCache.cxx
@@ -19,6 +19,7 @@
#include "FilterConfigCache.hxx"
+#include <o3tl/safeint.hxx>
#include <vcl/graphicfilter.hxx>
#include <unotools/configmgr.hxx>
#include <tools/svlibrary.h>
@@ -380,7 +381,7 @@ OUString FilterConfigCache::GetImportFormatShortName( sal_uInt16 nFormat )
OUString FilterConfigCache::GetImportFormatExtension( sal_uInt16 nFormat, sal_Int32 nEntry )
{
- if ( (nFormat < aImport.size()) && (size_t(nEntry) < aImport[ nFormat ].lExtensionList.size()) )
+ if ( (nFormat < aImport.size()) && (o3tl::make_unsigned(nEntry) < aImport[ nFormat ].lExtensionList.size()) )
return aImport[ nFormat ].lExtensionList[ nEntry ];
return OUString();
}
@@ -505,7 +506,7 @@ OUString FilterConfigCache::GetExportFormatShortName( sal_uInt16 nFormat )
OUString FilterConfigCache::GetExportFormatExtension( sal_uInt16 nFormat, sal_Int32 nEntry )
{
- if ( (nFormat < aExport.size()) && (size_t(nEntry) < aExport[ nFormat ].lExtensionList.size()) )
+ if ( (nFormat < aExport.size()) && (o3tl::make_unsigned(nEntry) < aExport[ nFormat ].lExtensionList.size()) )
return aExport[ nFormat ].lExtensionList[ nEntry ];
return OUString();
}
diff --git a/vcl/source/fontsubset/cff.cxx b/vcl/source/fontsubset/cff.cxx
index 2698b22b54bc..959b59668f62 100644
--- a/vcl/source/fontsubset/cff.cxx
+++ b/vcl/source/fontsubset/cff.cxx
@@ -24,6 +24,7 @@
#include <fontsubset.hxx>
+#include <o3tl/safeint.hxx>
#include <vcl/strhelper.hxx>
#include <sal/log.hxx>
@@ -1368,7 +1369,7 @@ bool CffSubsetterContext::initialCffRead()
// assert( mnFontDictBase == tellRel());
mpReadPtr = mpBasePtr + mnFontDictBase;
mnFDAryCount = (mpReadPtr[0]<<8) + mpReadPtr[1];
- if (static_cast<size_t>(mnFDAryCount) >= SAL_N_ELEMENTS(maCffLocal))
+ if (o3tl::make_unsigned(mnFDAryCount) >= SAL_N_ELEMENTS(maCffLocal))
{
SAL_INFO("vcl.fonts", "CffSubsetterContext: too many CFF in font");
return false;
diff --git a/vcl/source/gdi/dibtools.cxx b/vcl/source/gdi/dibtools.cxx
index 6c29bc325397..b061da93022d 100644
--- a/vcl/source/gdi/dibtools.cxx
+++ b/vcl/source/gdi/dibtools.cxx
@@ -22,6 +22,7 @@
#include <cassert>
+#include <o3tl/safeint.hxx>
#include <vcl/dibtools.hxx>
#include <comphelper/fileformat.h>
#include <tools/zcodec.hxx>
@@ -276,7 +277,7 @@ bool ImplReadDIBInfoHeader(SvStream& rIStm, DIBV5Header& rHeader, bool& bTopDown
assert(rHeader.nHeight >= 0);
if (rHeader.nHeight != 0 && rHeader.nWidth >= 0
&& (rHeader.nSizeImage / 16 / static_cast<sal_uInt32>(rHeader.nHeight)
- > static_cast<sal_uInt32>(rHeader.nWidth)))
+ > o3tl::make_unsigned(rHeader.nWidth)))
{
rHeader.nSizeImage = 0;
}
@@ -929,7 +930,7 @@ bool ImplReadDIBBody(SvStream& rIStm, Bitmap& rBmp, AlphaMask* pBmpAlpha, sal_uL
sal_uInt64 nMaxWidth = pIStm->remainingSize();
nMaxWidth *= 256; //assume generous compression ratio
nMaxWidth /= aHeader.nHeight;
- if (nMaxWidth < static_cast<sal_uInt64>(aHeader.nWidth))
+ if (nMaxWidth < o3tl::make_unsigned(aHeader.nWidth))
return false;
break;
}
@@ -940,7 +941,7 @@ bool ImplReadDIBBody(SvStream& rIStm, Bitmap& rBmp, AlphaMask* pBmpAlpha, sal_uL
sal_uInt64 nMaxWidth = pIStm->remainingSize();
nMaxWidth *= 512; //assume generous compression ratio
nMaxWidth /= aHeader.nHeight;
- if (nMaxWidth < static_cast<sal_uInt64>(aHeader.nWidth))
+ if (nMaxWidth < o3tl::make_unsigned(aHeader.nWidth))
return false;
break;
}
diff --git a/vcl/source/gdi/pdfextoutdevdata.cxx b/vcl/source/gdi/pdfextoutdevdata.cxx
index e36cb0e9ceef..e46396e73f7a 100644
--- a/vcl/source/gdi/pdfextoutdevdata.cxx
+++ b/vcl/source/gdi/pdfextoutdevdata.cxx
@@ -27,6 +27,7 @@
#include <basegfx/polygon/b2dpolygon.hxx>
#include <basegfx/polygon/b2dpolygontools.hxx>
#include <sal/log.hxx>
+#include <o3tl/safeint.hxx>
#include <osl/diagnose.h>
#include <tools/stream.hxx>
@@ -121,7 +122,7 @@ sal_Int32 GlobalSyncData::GetMappedId()
*/
if( nLinkId >= 0 )
{
- if ( static_cast<sal_uInt32>(nLinkId) < mParaIds.size() )
+ if ( o3tl::make_unsigned(nLinkId) < mParaIds.size() )
nLinkId = mParaIds[ nLinkId ];
else
nLinkId = -1;
@@ -134,7 +135,7 @@ sal_Int32 GlobalSyncData::GetMappedId()
sal_Int32 GlobalSyncData::GetMappedStructId( sal_Int32 nStructId )
{
- if ( static_cast<sal_uInt32>(nStructId) < mStructIdMap.size() )
+ if ( o3tl::make_unsigned(nStructId) < mStructIdMap.size() )
nStructId = mStructIdMap[ nStructId ];
else
nStructId = -1;
@@ -753,7 +754,7 @@ void PDFExtOutDevData::EndStructureElement()
bool PDFExtOutDevData::SetCurrentStructureElement( sal_Int32 nStructId )
{
bool bSuccess = false;
- if( sal_uInt32(nStructId) < mpGlobalSyncData->mStructParents.size() )
+ if( o3tl::make_unsigned(nStructId) < mpGlobalSyncData->mStructParents.size() )
{
mpGlobalSyncData->mCurrentStructElement = nStructId;
mpPageSyncData->PushAction( mrOutDev, PDFExtOutDevDataSync::SetCurrentStructureElement );
diff --git a/vcl/source/gdi/pdfwriter_impl.hxx b/vcl/source/gdi/pdfwriter_impl.hxx
index 82afd47e850e..c70628ab1789 100644
--- a/vcl/source/gdi/pdfwriter_impl.hxx
+++ b/vcl/source/gdi/pdfwriter_impl.hxx
@@ -44,6 +44,7 @@
#include <vcl/virdev.hxx>
#include <vcl/pdfwriter.hxx>
#include <vcl/wall.hxx>
+#include <o3tl/safeint.hxx>
#include <o3tl/typed_flags_set.hxx>
#include <comphelper/hash.hxx>
#include <tools/stream.hxx>
@@ -287,7 +288,7 @@ public:
sal_Ucs getCode( sal_Int32 i_nIndex ) const
{
sal_Ucs nRet = 0;
- if (static_cast<size_t>(i_nIndex) < m_CodeUnits.size())
+ if (o3tl::make_unsigned(i_nIndex) < m_CodeUnits.size())
nRet = m_CodeUnits[i_nIndex];
return nRet;
}
diff --git a/vcl/source/gdi/svmconverter.cxx b/vcl/source/gdi/svmconverter.cxx
index dc48dea5c718..d65b6c52f796 100644
--- a/vcl/source/gdi/svmconverter.cxx
+++ b/vcl/source/gdi/svmconverter.cxx
@@ -19,6 +19,8 @@
#include <algorithm>
#include <string.h>
+
+#include <o3tl/safeint.hxx>
#include <osl/thread.h>
#include <tools/fract.hxx>
#include <tools/stream.hxx>
@@ -330,7 +332,7 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf )
const size_t nMinActionSize = sizeof(sal_uInt16) + sizeof(sal_Int32);
const size_t nMaxPossibleActions = rIStm.remainingSize() / nMinActionSize;
- if (static_cast<sal_uInt32>(nActions) > nMaxPossibleActions)
+ if (o3tl::make_unsigned(nActions) > nMaxPossibleActions)
{
SAL_WARN("vcl.gdi", "svm claims more actions (" << nActions << ") than stream could provide, truncating");
nActions = nMaxPossibleActions;
@@ -717,7 +719,7 @@ void SVMConverter::ImplConvertFromSVM1( SvStream& rIStm, GDIMetaFile& rMtf )
{
const size_t nMinRecordSize = sizeof(sal_Int32);
const size_t nMaxRecords = rIStm.remainingSize() / nMinRecordSize;
- if (static_cast<sal_uInt32>(nAryLen) > nMaxRecords)
+ if (o3tl::make_unsigned(nAryLen) > nMaxRecords)
{
SAL_WARN("vcl.gdi", "Parsing error: " << nMaxRecords <<
" max possible entries, but " << nAryLen << " claimed, truncating");
diff --git a/vcl/source/treelist/svimpbox.cxx b/vcl/source/treelist/svimpbox.cxx
index 0c3a2ef5bae0..6ae3daf0346c 100644
--- a/vcl/source/treelist/svimpbox.cxx
+++ b/vcl/source/treelist/svimpbox.cxx
@@ -17,6 +17,9 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <sal/config.h>
+
+#include <o3tl/safeint.hxx>
#include <vcl/svapp.hxx>
#include <vcl/salnativewidgets.hxx>
#include <vcl/help.hxx>
@@ -219,7 +222,7 @@ void SvImpLBox::CalcCellFocusRect( tools::Rectangle& rRect )
SvLBoxItem& rItem = m_pCursor->GetItem( m_nCurTabPos );
rRect.SetLeft( m_pView->GetTab( m_pCursor, &rItem )->GetPos() );
}
- if (m_pCursor->ItemCount() > static_cast<size_t>(m_nCurTabPos+1))
+ if (m_pCursor->ItemCount() > o3tl::make_unsigned(m_nCurTabPos+1))
{
SvLBoxItem& rNextItem = m_pCursor->GetItem( m_nCurTabPos + 1 );
long nRight = m_pView->GetTab( m_pCursor, &rNextItem )->GetPos() - 1;
@@ -1315,7 +1318,7 @@ void SvImpLBox::FillView()
long nTempThumb = m_aVerSBar->GetThumbPos();
if( nTempThumb < 0 )
nTempThumb = 0;
- else if( static_cast<unsigned long>(nTempThumb) >= nVisibleViewCount )
+ else if( o3tl::make_unsigned(nTempThumb) >= nVisibleViewCount )
nTempThumb = nVisibleViewCount == 0 ? 0 : nVisibleViewCount - 1;
m_pStartEntry = m_pView->GetEntryAtVisPos(nTempThumb);
}
diff --git a/vcl/source/treelist/svtabbx.cxx b/vcl/source/treelist/svtabbx.cxx
index 809f0885be4d..f573dbd2bd8a 100644
--- a/vcl/source/treelist/svtabbx.cxx
+++ b/vcl/source/treelist/svtabbx.cxx
@@ -26,6 +26,7 @@
#include <unotools/accessiblestatesethelper.hxx>
#include <com/sun/star/accessibility/AccessibleStateType.hpp>
#include <sal/log.hxx>
+#include <o3tl/safeint.hxx>
#include <osl/diagnose.h>
#include <strings.hrc>
#include <svdata.hxx>
@@ -298,7 +299,7 @@ OUString SvTabListBox::GetCellText( sal_uLong nPos, sal_uInt16 nCol ) const
SvTreeListEntry* pEntry = GetEntryOnPos( nPos );
DBG_ASSERT( pEntry, "SvTabListBox::GetCellText(): Invalid Entry" );
OUString aResult;
- if (pEntry && pEntry->ItemCount() > static_cast<size_t>(nCol+1))
+ if (pEntry && pEntry->ItemCount() > o3tl::make_unsigned(nCol+1))
{
const SvLBoxItem& rStr = pEntry->GetItem( nCol + 1 );
if (rStr.GetType() == SvLBoxItemType::String)
diff --git a/vcl/source/window/syswin.cxx b/vcl/source/window/syswin.cxx
index 5dbcd6852859..3c154dd228c7 100644
--- a/vcl/source/window/syswin.cxx
+++ b/vcl/source/window/syswin.cxx
@@ -18,6 +18,8 @@
*/
#include <memory>
+
+#include <o3tl/safeint.hxx>
#include <sal/config.h>
#include <sal/log.hxx>
@@ -705,15 +707,15 @@ void SystemWindow::SetWindowStateData( const WindowStateData& rData )
if( std::abs(g.nX-aState.mnX) < 2 && std::abs(g.nY-aState.mnY) < 5 )
{
long displacement = g.nTopDecoration ? g.nTopDecoration : 20;
- if( aState.mnX + displacement + aState.mnWidth + g.nRightDecoration > static_cast<unsigned long>(aDesktop.Right()) ||
- aState.mnY + displacement + aState.mnHeight + g.nBottomDecoration > static_cast<unsigned long>(aDesktop.Bottom()) )
+ if( aState.mnX + displacement + aState.mnWidth + g.nRightDecoration > o3tl::make_unsigned(aDesktop.Right()) ||
+ aState.mnY + displacement + aState.mnHeight + g.nBottomDecoration > o3tl::make_unsigned(aDesktop.Bottom()) )
{
// displacing would leave screen
aState.mnX = g.nLeftDecoration ? g.nLeftDecoration : 10; // should result in (0,0)
aState.mnY = displacement;
if( bWrapped ||
- aState.mnX + displacement + aState.mnWidth + g.nRightDecoration > static_cast<unsigned long>(aDesktop.Right()) ||
- aState.mnY + displacement + aState.mnHeight + g.nBottomDecoration > static_cast<unsigned long>(aDesktop.Bottom()) )
+ aState.mnX + displacement + aState.mnWidth + g.nRightDecoration > o3tl::make_unsigned(aDesktop.Right()) ||
+ aState.mnY + displacement + aState.mnHeight + g.nBottomDecoration > o3tl::make_unsigned(aDesktop.Bottom()) )
break; // further displacement not possible -> break
// avoid endless testing
bWrapped = true;
diff --git a/vcl/source/window/winproc.cxx b/vcl/source/window/winproc.cxx
index fc50ffe45567..50116e908559 100644
--- a/vcl/source/window/winproc.cxx
+++ b/vcl/source/window/winproc.cxx
@@ -17,6 +17,9 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <sal/config.h>
+
+#include <o3tl/safeint.hxx>
#include <tools/debug.hxx>
#include <tools/time.hxx>
#include <sal/log.hxx>
@@ -2336,7 +2339,7 @@ static void ImplHandleSalQueryCharPosition( vcl::Window *pWindow,
ImplCallCommand( pChild, CommandEventId::QueryCharPosition );
ImplWinData* pWinData = pChild->ImplGetWinData();
- if ( pWinData->mpCompositionCharRects && pEvt->mnCharPos < static_cast<sal_uLong>( pWinData->mnCompositionCharRects ) )
+ if ( pWinData->mpCompositionCharRects && pEvt->mnCharPos < o3tl::make_unsigned( pWinData->mnCompositionCharRects ) )
{
const OutputDevice *pChildOutDev = pChild->GetOutDev();
const tools::Rectangle& aRect = pWinData->mpCompositionCharRects[ pEvt->mnCharPos ];