From 5060c5015882b7109c54598c4ea858949beafc43 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Tue, 24 May 2022 15:26:06 +0200 Subject: 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: I20600d61a5d59d739bc1bee838c0038e4611aec2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134875 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- xmloff/source/chart/SchXMLChartContext.cxx | 3 ++- xmloff/source/style/xmlprmap.cxx | 15 ++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) (limited to 'xmloff') diff --git a/xmloff/source/chart/SchXMLChartContext.cxx b/xmloff/source/chart/SchXMLChartContext.cxx index fb7deffd2527..23ea2f780041 100644 --- a/xmloff/source/chart/SchXMLChartContext.cxx +++ b/xmloff/source/chart/SchXMLChartContext.cxx @@ -57,6 +57,7 @@ #include #include +#include #include using namespace com::sun::star; @@ -578,7 +579,7 @@ void lcl_swapPointAndSeriesStylesForDonutCharts( ::std::vector< DataRowPointStyl sal_Int32 nNewSeriesIndex = aStyle.m_nPointIndex; sal_Int32 nRepeatCount = aStyle.m_nPointRepeat; - while( nRepeatCount && (nNewSeriesIndex>=0) && (nNewSeriesIndex< static_cast(aNewSeriesVector.size()) ) ) + while( nRepeatCount && (nNewSeriesIndex>=0) && (o3tl::make_unsigned(nNewSeriesIndex)< aNewSeriesVector.size() ) ) { NewDonutSeries& rNewSeries( aNewSeriesVector[nNewSeriesIndex] ); rNewSeries.setPointStyleNameToPoint( aStyle.msStyleName, nNewPointIndex ); diff --git a/xmloff/source/style/xmlprmap.cxx b/xmloff/source/style/xmlprmap.cxx index e6f8cd29ba4c..a2e35b774bd3 100644 --- a/xmloff/source/style/xmlprmap.cxx +++ b/xmloff/source/style/xmlprmap.cxx @@ -17,6 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include #include #include @@ -158,32 +159,32 @@ sal_Int32 XMLPropertySetMapper::GetEntryCount() const sal_uInt32 XMLPropertySetMapper::GetEntryFlags( sal_Int32 nIndex ) const { - assert((0 <= nIndex) && (nIndex < static_cast(mpImpl->maMapEntries.size()))); + assert((0 <= nIndex) && (o3tl::make_unsigned(nIndex) < mpImpl->maMapEntries.size())); return mpImpl->maMapEntries[nIndex].nType & ~MID_FLAG_MASK; } sal_uInt32 XMLPropertySetMapper::GetEntryType( sal_Int32 nIndex ) const { - assert((0 <= nIndex) && (nIndex < static_cast(mpImpl->maMapEntries.size()))); + assert((0 <= nIndex) && (o3tl::make_unsigned(nIndex) < mpImpl->maMapEntries.size())); sal_uInt32 nType = mpImpl->maMapEntries[nIndex].nType; return nType; } sal_uInt16 XMLPropertySetMapper::GetEntryNameSpace( sal_Int32 nIndex ) const { - assert((0 <= nIndex) && (nIndex < static_cast(mpImpl->maMapEntries.size()))); + assert((0 <= nIndex) && (o3tl::make_unsigned(nIndex) < mpImpl->maMapEntries.size())); return mpImpl->maMapEntries[nIndex].nXMLNameSpace; } const OUString& XMLPropertySetMapper::GetEntryXMLName( sal_Int32 nIndex ) const { - assert((0 <= nIndex) && (nIndex < static_cast(mpImpl->maMapEntries.size()))); + assert((0 <= nIndex) && (o3tl::make_unsigned(nIndex) < mpImpl->maMapEntries.size())); return mpImpl->maMapEntries[nIndex].sXMLAttributeName; } const OUString& XMLPropertySetMapper::GetEntryAPIName( sal_Int32 nIndex ) const { - assert((0 <= nIndex) && (nIndex < static_cast(mpImpl->maMapEntries.size()))); + assert((0 <= nIndex) && (o3tl::make_unsigned(nIndex) < mpImpl->maMapEntries.size())); return mpImpl->maMapEntries[nIndex].sAPIPropertyName; } @@ -196,13 +197,13 @@ sal_Int16 XMLPropertySetMapper::GetEntryContextId( sal_Int32 nIndex ) const SvtSaveOptions::ODFSaneDefaultVersion XMLPropertySetMapper::GetEarliestODFVersionForExport(sal_Int32 const nIndex) const { - assert((0 <= nIndex) && (nIndex < static_cast(mpImpl->maMapEntries.size()))); + assert((0 <= nIndex) && (o3tl::make_unsigned(nIndex) < mpImpl->maMapEntries.size())); return mpImpl->maMapEntries[nIndex].nEarliestODFVersionForExport; } const XMLPropertyHandler* XMLPropertySetMapper::GetPropertyHandler( sal_Int32 nIndex ) const { - assert((0 <= nIndex) && (nIndex < static_cast(mpImpl->maMapEntries.size()))); + assert((0 <= nIndex) && (o3tl::make_unsigned(nIndex) < mpImpl->maMapEntries.size())); return mpImpl->maMapEntries[nIndex].pHdl; } -- cgit