[Libreoffice-commits] core.git: vbahelper/source

Stephan Bergmann (via logerrit) logerrit at kemper.freedesktop.org
Sun Jan 26 16:34:50 UTC 2020


 vbahelper/source/msforms/vbacontrol.cxx |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

New commits:
commit 0288c8ffecff4956a52b9147d441979941e8b87f
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Sun Jan 26 15:10:03 2020 +0100
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Sun Jan 26 17:34:15 2020 +0100

    Rephrase cast from sal_Int32 to sal_uInt32
    
    ...to avoid false positives with upcoming loplugin:unsignedcompare:
    
    > vbahelper/source/msforms/vbacontrol.cxx:730:12: error: explicit cast from 'sal_Int32' (aka 'int') to 'sal_uInt32' (aka 'unsigned int') (of equal rank) in comparison against 'sal_uInt32': if the cast value is known to be non-negative, use o3tl::make_unsigned instead of the cast [loplugin:unsignedcompare]
    >     if ( ( static_cast<sal_uInt32>(nBackColor) >= sal_uInt32(0x80000000) ) &&
    >            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    > vbahelper/source/msforms/vbacontrol.cxx:731:12: error: explicit cast from 'sal_Int32' (aka 'int') to 'sal_uInt32' (aka 'unsigned int') (of equal rank) in comparison against 'unsigned long': if the cast value is known to be non-negative, use o3tl::make_unsigned instead of the cast [loplugin:unsignedcompare]
    >          ( static_cast<sal_uInt32>(nBackColor) <= sal_uInt32(0x80000000) + SAL_N_ELEMENTS(nSysCols) ) )
    >            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    (This is the only case I found where the plugin's heuristics failed.)
    
    Change-Id: I36d12caa0f837b8ba860eaf33b3e166a4f1001fb
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/87454
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/vbahelper/source/msforms/vbacontrol.cxx b/vbahelper/source/msforms/vbacontrol.cxx
index 1e877c66d063..bcbbbdcd446e 100644
--- a/vbahelper/source/msforms/vbacontrol.cxx
+++ b/vbahelper/source/msforms/vbacontrol.cxx
@@ -727,10 +727,11 @@ sal_Int32 ScVbaControl::getBackColor()
 
 void ScVbaControl::setBackColor( sal_Int32 nBackColor )
 {
-    if ( ( static_cast<sal_uInt32>(nBackColor) >= sal_uInt32(0x80000000) ) &&
-         ( static_cast<sal_uInt32>(nBackColor) <= sal_uInt32(0x80000000) + SAL_N_ELEMENTS(nSysCols) ) )
+    auto const col = static_cast<sal_uInt32>(nBackColor);
+    if ( ( col >= sal_uInt32(0x80000000) ) &&
+         ( col <= sal_uInt32(0x80000000) + SAL_N_ELEMENTS(nSysCols) ) )
     {
-        nBackColor = nSysCols[ nBackColor & 0x0FF];
+        nBackColor = nSysCols[ col & 0x0FF];
     }
     m_xProps->setPropertyValue( "BackgroundColor" , uno::makeAny( XLRGBToOORGB( nBackColor ) ) );
 }


More information about the Libreoffice-commits mailing list