summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2022-04-26 15:08:36 +0200
committerStephan Bergmann <sbergman@redhat.com>2022-04-26 17:04:01 +0200
commitbdff0bb77b57def835fcaed3bded7519e69dc896 (patch)
treec330add464f566a32ebd82dd9ad29f91ba0d87f8 /vcl
parent651527b4efe9700c8c8dff58ce5aa86ad5681f16 (diff)
Use o3tl::make_unsigned in some places
...where a signed and an unsigned value are compared, and the signed value has just been proven to be non-negative here Change-Id: I9665e6c2c4c5557f2d4cf1bb646f9fffc7bd7d30 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133442 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/pdf/pdfwriter_impl.hxx2
-rw-r--r--vcl/source/control/ctrl.cxx3
-rw-r--r--vcl/source/control/roadmap.cxx3
-rw-r--r--vcl/source/window/printdlg.cxx3
4 files changed, 7 insertions, 4 deletions
diff --git a/vcl/inc/pdf/pdfwriter_impl.hxx b/vcl/inc/pdf/pdfwriter_impl.hxx
index b8bdc3825eee..29d1f598c68d 100644
--- a/vcl/inc/pdf/pdfwriter_impl.hxx
+++ b/vcl/inc/pdf/pdfwriter_impl.hxx
@@ -1071,7 +1071,7 @@ public:
Size getCurPageSize() const
{
Size aSize;
- if( m_nCurrentPage >= 0 && m_nCurrentPage < static_cast<sal_Int32>(m_aPages.size()) )
+ if( m_nCurrentPage >= 0 && o3tl::make_unsigned(m_nCurrentPage) < m_aPages.size() )
aSize = Size( m_aPages[ m_nCurrentPage ].m_nPageWidth, m_aPages[ m_nCurrentPage ].m_nPageHeight );
return aSize;
}
diff --git a/vcl/source/control/ctrl.cxx b/vcl/source/control/ctrl.cxx
index 00eb0035f1fd..6cb06bc1191d 100644
--- a/vcl/source/control/ctrl.cxx
+++ b/vcl/source/control/ctrl.cxx
@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <o3tl/safeint.hxx>
#include <vcl/svapp.hxx>
#include <vcl/event.hxx>
#include <vcl/ctrl.hxx>
@@ -103,7 +104,7 @@ ControlLayoutData::ControlLayoutData() : m_pParent( nullptr )
tools::Rectangle ControlLayoutData::GetCharacterBounds( tools::Long nIndex ) const
{
- return (nIndex >= 0 && nIndex < static_cast<tools::Long>(m_aUnicodeBoundRects.size())) ? m_aUnicodeBoundRects[ nIndex ] : tools::Rectangle();
+ return (nIndex >= 0 && o3tl::make_unsigned(nIndex) < m_aUnicodeBoundRects.size()) ? m_aUnicodeBoundRects[ nIndex ] : tools::Rectangle();
}
tools::Rectangle Control::GetCharacterBounds( tools::Long nIndex ) const
diff --git a/vcl/source/control/roadmap.cxx b/vcl/source/control/roadmap.cxx
index b0841b021292..7142c4dacaf4 100644
--- a/vcl/source/control/roadmap.cxx
+++ b/vcl/source/control/roadmap.cxx
@@ -19,6 +19,7 @@
#include <vector>
#include <algorithm>
+#include <o3tl/safeint.hxx>
#include <vcl/event.hxx>
#include <vcl/toolkit/roadmap.hxx>
#include <vcl/settings.hxx>
@@ -452,7 +453,7 @@ const RoadmapItem* ORoadmap::GetByID(ItemId _nID) const
RoadmapItem* ORoadmap::GetByIndex(ItemIndex _nItemIndex)
{
const HL_Vector& rItems = m_pImpl->getHyperLabels();
- if ( ( _nItemIndex > -1 ) && ( _nItemIndex < static_cast<ItemIndex>(rItems.size()) ) )
+ if ( ( _nItemIndex > -1 ) && ( o3tl::make_unsigned(_nItemIndex) < rItems.size() ) )
{
return rItems.at( _nItemIndex );
}
diff --git a/vcl/source/window/printdlg.cxx b/vcl/source/window/printdlg.cxx
index bce9870d41bc..2c305f170d13 100644
--- a/vcl/source/window/printdlg.cxx
+++ b/vcl/source/window/printdlg.cxx
@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <o3tl/safeint.hxx>
#include <sal/log.hxx>
#include <osl/diagnose.h>
#include <rtl/ustrbuf.hxx>
@@ -1756,7 +1757,7 @@ void PrintDialog::updateWindowFromProperty( const OUString& i_rProperty )
{
pList->set_active( static_cast< sal_uInt16 >(nVal) );
}
- else if( nVal >= 0 && nVal < sal_Int32(rWindows.size() ) )
+ else if( nVal >= 0 && o3tl::make_unsigned(nVal) < rWindows.size() )
{
weld::RadioButton* pBtn = dynamic_cast<weld::RadioButton*>(rWindows[nVal]);
SAL_WARN_IF( !pBtn, "vcl", "unexpected control for property" );