summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDr. David Alan Gilbert <dave@treblig.org>2021-11-10 21:44:40 +0000
committerStephan Bergmann <sbergman@redhat.com>2021-11-22 10:03:22 +0100
commit4c577a0ada8c47483fb8a80a97478ffd3e2b37d3 (patch)
tree5fa1ff1287e8dcac7b06037276d265d732bce4ee
parent626296cb6cb1e81d40b9554fb6f15b8912d410ff (diff)
pszctrl: cppcheck undefined shift
cppcheck noticed that the shift in: for ( sal_uInt16 nCheck = 1; nCheck < 32; ++nCheck ) if ( nCheckEncoded & (1 << nCheck) ) is undefined since 1 << 31 is implementation defined. Make it 1u, and the others around. (Not that we define bits that high, but we are explicitly checking it) Change-Id: Ieb780ac999af71df2b48ce64daaf4b2878162e35 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125016 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
-rw-r--r--svx/source/stbctrls/pszctrl.cxx8
1 files changed, 4 insertions, 4 deletions
diff --git a/svx/source/stbctrls/pszctrl.cxx b/svx/source/stbctrls/pszctrl.cxx
index f273afcdbc61..129ac67eb085 100644
--- a/svx/source/stbctrls/pszctrl.cxx
+++ b/svx/source/stbctrls/pszctrl.cxx
@@ -162,7 +162,7 @@ FunctionPopup_Impl::FunctionPopup_Impl(sal_uInt32 nCheckEncoded)
, m_nSelected(nCheckEncoded)
{
for ( sal_uInt16 nCheck = 1; nCheck < 32; ++nCheck )
- if ( nCheckEncoded & (1 << nCheck) )
+ if ( nCheckEncoded & (1u << nCheck) )
m_xMenu->set_active(function_to_id(nCheck), true);
}
@@ -174,10 +174,10 @@ sal_uInt32 FunctionPopup_Impl::GetSelected(std::string_view curident) const
nSelected = ( 1 << PSZ_FUNC_NONE );
else
{
- nSelected &= (~( 1 << PSZ_FUNC_NONE )); // Clear the "None" bit
- nSelected ^= ( 1 << nCurItemId ); // Toggle the bit corresponding to nCurItemId
+ nSelected &= (~( 1u << PSZ_FUNC_NONE )); // Clear the "None" bit
+ nSelected ^= ( 1u << nCurItemId ); // Toggle the bit corresponding to nCurItemId
if ( !nSelected )
- nSelected = ( 1 << PSZ_FUNC_NONE );
+ nSelected = ( 1u << PSZ_FUNC_NONE );
}
return nSelected;
}