[Libreoffice-commits] core.git: include/osl sal/osl sal/rtl

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Wed Apr 15 09:24:48 UTC 2020


 include/osl/profile.hxx |   14 ++++++++++++--
 include/osl/socket.hxx  |    3 ++-
 sal/osl/unx/profile.cxx |   14 ++++++++------
 sal/rtl/math.cxx        |   16 +++++++++++-----
 sal/rtl/strtmpl.cxx     |    8 +++++---
 sal/rtl/ustring.cxx     |   16 ++++++++++------
 6 files changed, 48 insertions(+), 23 deletions(-)

New commits:
commit 72d8f2961fd7f5670fe2564eeb3aa14a6eaf0d8d
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Wed Apr 15 09:13:58 2020 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Wed Apr 15 11:24:09 2020 +0200

    loplugin:buriedassign in sal
    
    Change-Id: I5a7bc9378ceacb9116c03e3a9fc01c5675c40908
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92243
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/include/osl/profile.hxx b/include/osl/profile.hxx
index b62ea0628ca7..0ce69a8aea3b 100644
--- a/include/osl/profile.hxx
+++ b/include/osl/profile.hxx
@@ -160,8 +160,13 @@ namespace osl {
                 sal_Char* pBuf = new sal_Char[ n+1 ];
                 osl_getProfileSectionEntries( profile, rSection.getStr(), pBuf, n+1 );
                 size_t nLen;
-                for( n = 0; ( nLen = strlen( pBuf+n ) ); n += nLen+1 )
+                for( n = 0; ; n += nLen+1 )
+                {
+                    nLen = strlen( pBuf+n );
+                    if (!nLen)
+                        break;
                     aEntries.push_back( rtl::OString( pBuf+n ) );
+                }
                 delete[] pBuf;
             }
 
@@ -182,8 +187,13 @@ namespace osl {
                 sal_Char* pBuf = new sal_Char[ n+1 ];
                 osl_getProfileSections( profile, pBuf, n+1 );
                 size_t nLen;
-                for( n = 0; ( nLen = strlen( pBuf+n ) ); n += nLen+1 )
+                for( n = 0; ; n += nLen+1 )
+                {
+                    nLen = strlen( pBuf+n );
+                    if (!nLen)
+                        break;
                     aSections.push_back( rtl::OString( pBuf+n ) );
+                }
                 delete[] pBuf;
             }
 
diff --git a/include/osl/socket.hxx b/include/osl/socket.hxx
index 640880144177..2ea81fcfd3e0 100644
--- a/include/osl/socket.hxx
+++ b/include/osl/socket.hxx
@@ -242,7 +242,8 @@ namespace osl
 
     inline Socket&  Socket::operator= (const Socket& sock)
     {
-        return (*this) = sock.getHandle();
+        *this = sock.getHandle();
+        return *this;
     }
 
 
diff --git a/sal/osl/unx/profile.cxx b/sal/osl/unx/profile.cxx
index edb76019ff5d..ce3742bc8a10 100644
--- a/sal/osl/unx/profile.cxx
+++ b/sal/osl/unx/profile.cxx
@@ -391,8 +391,8 @@ sal_Bool SAL_CALL osl_readProfileString(oslProfile Profile,
 
     if (! (pProfile->m_Flags & osl_Profile_SYSTEM))
     {
-        osl_TProfileSection* pSec;
-        if (((pSec = findEntry(pProfile, pszSection, pszEntry, &NoEntry)) != nullptr) &&
+        osl_TProfileSection* pSec = findEntry(pProfile, pszSection, pszEntry, &NoEntry);
+        if ((pSec != nullptr) &&
             (NoEntry < pSec->m_NoEntries) &&
             ((pStr = strchr(pProfile->m_Lines[pSec->m_Entries[NoEntry].m_Line],
                             '=')) != nullptr))
@@ -535,7 +535,8 @@ sal_Bool SAL_CALL osl_writeProfileString(oslProfile Profile,
             Line[1 + strlen(pszSection)] = ']';
             Line[2 + strlen(pszSection)] = '\0';
 
-            if (((pStr = addLine(pProfile, Line)) == nullptr) ||
+            pStr = addLine(pProfile, Line);
+            if ((pStr == nullptr) ||
                 (! addSection(pProfile, pProfile->m_NoLines - 1, &pStr[1], strlen(pszSection))))
             {
                 bRet=releaseProfile(pProfile);
@@ -563,7 +564,8 @@ sal_Bool SAL_CALL osl_writeProfileString(oslProfile Profile,
             else
                 i = pSec->m_Line + 1;
 
-            if (((pStr = insertLine(pProfile, Line, i)) == nullptr) ||
+            pStr = insertLine(pProfile, Line, i);
+            if ((pStr == nullptr) ||
                 (! addEntry(pProfile, pSec, i, pStr, strlen(pszEntry))))
             {
                 bRet=releaseProfile(pProfile);
@@ -675,8 +677,8 @@ sal_Bool SAL_CALL osl_removeProfileEntry(oslProfile Profile,
 
     if (! (pProfile->m_Flags & osl_Profile_SYSTEM))
     {
-        osl_TProfileSection* pSec;
-        if (((pSec = findEntry(pProfile, pszSection, pszEntry, &NoEntry)) != nullptr) &&
+        osl_TProfileSection* pSec = findEntry(pProfile, pszSection, pszEntry, &NoEntry);
+        if ((pSec != nullptr) &&
             (NoEntry < pSec->m_NoEntries))
         {
             removeLine(pProfile, pSec->m_Entries[NoEntry].m_Line);
diff --git a/sal/rtl/math.cxx b/sal/rtl/math.cxx
index 135035e01138..099cd3d60578 100644
--- a/sal/rtl/math.cxx
+++ b/sal/rtl/math.cxx
@@ -172,9 +172,10 @@ bool isRepresentableInteger(double fAbsValue)
         // XXX loplugin:fpcomparison complains about floating-point comparison
         // for static_cast<double>(nInt) == fAbsValue, though we actually want
         // this here.
-        double fInt;
-        return (nInt <= kMaxInt &&
-                (!((fInt = static_cast< double >(nInt)) < fAbsValue) && !(fInt > fAbsValue)));
+        if (nInt > kMaxInt)
+            return false;
+        double fInt = static_cast< double >(nInt);
+        return !(fInt < fAbsValue) && !(fInt > fAbsValue);
     }
     return false;
 }
@@ -447,7 +448,8 @@ void doubleToString(typename T::String ** pResult,
     // Round the number
     if(nDigits >= 0)
     {
-        if ((fValue += nRoundVal[std::min<sal_Int32>(nDigits, 15)] ) >= 10)
+        fValue += nRoundVal[std::min<sal_Int32>(nDigits, 15)];
+        if (fValue >= 10)
         {
             fValue = 1.0;
             nExp++;
@@ -1213,7 +1215,11 @@ bool SAL_CALL rtl_math_approxEqual(double a, double b) SAL_THROW_EXTERN_C()
     if (!std::isfinite(d))
         return false;   // Nan or Inf involved
 
-    if (d > ((a = fabs(a)) * e44) || d > ((b = fabs(b)) * e44))
+    a = fabs(a);
+    if (d > (a * e44))
+        return false;
+    b = fabs(b);
+    if (d > (b * e44))
         return false;
 
     if (isRepresentableInteger(d) && isRepresentableInteger(a) && isRepresentableInteger(b))
diff --git a/sal/rtl/strtmpl.cxx b/sal/rtl/strtmpl.cxx
index 9ec3cc6efde8..8ff170767b18 100644
--- a/sal/rtl/strtmpl.cxx
+++ b/sal/rtl/strtmpl.cxx
@@ -101,10 +101,12 @@ sal_Int32 SAL_CALL IMPL_RTL_STRNAME( compare )( const IMPL_RTL_STRCODE* pStr1,
     else
     {
         sal_Int32 nRet;
-        while ( ((nRet = static_cast<sal_Int32>(IMPL_RTL_USTRCODE(*pStr1))-
-                         static_cast<sal_Int32>(IMPL_RTL_USTRCODE(*pStr2))) == 0) &&
-                *pStr2 )
+        for (;;)
         {
+            nRet = static_cast<sal_Int32>(IMPL_RTL_USTRCODE(*pStr1)) -
+                   static_cast<sal_Int32>(IMPL_RTL_USTRCODE(*pStr2));
+            if (!(nRet == 0 && *pStr2 ))
+                break;
             pStr1++;
             pStr2++;
         }
diff --git a/sal/rtl/ustring.cxx b/sal/rtl/ustring.cxx
index fca94a2fe6fd..01fea63e160c 100644
--- a/sal/rtl/ustring.cxx
+++ b/sal/rtl/ustring.cxx
@@ -213,10 +213,12 @@ sal_Int32 SAL_CALL rtl_ustr_ascii_compare( const sal_Unicode* pStr1,
     assert(pStr1);
     assert(pStr2);
     sal_Int32 nRet;
-    while ( ((nRet = static_cast<sal_Int32>(*pStr1)-
-                     static_cast<sal_Int32>(static_cast<unsigned char>(*pStr2))) == 0) &&
-            *pStr2 )
+    for (;;)
     {
+        nRet = static_cast<sal_Int32>(*pStr1)-
+                     static_cast<sal_Int32>(static_cast<unsigned char>(*pStr2));
+        if (!(nRet == 0 && *pStr2 ))
+            break;
         /* Check ASCII range */
         SAL_WARN_IF( (static_cast<unsigned char>(*pStr2)) > 127, "rtl.string",
                     "rtl_ustr_ascii_compare - Found char > 127" );
@@ -238,10 +240,12 @@ sal_Int32 SAL_CALL rtl_ustr_ascii_compare_WithLength( const sal_Unicode* pStr1,
     assert(nStr1Len >= 0);
     assert(pStr2);
     sal_Int32 nRet = 0;
-    while( ((nRet = (nStr1Len ? static_cast<sal_Int32>(*pStr1) : 0)-
-                    static_cast<sal_Int32>(static_cast<unsigned char>(*pStr2))) == 0) &&
-           nStr1Len && *pStr2 )
+    for (;;)
     {
+        nRet = (nStr1Len ? static_cast<sal_Int32>(*pStr1) : 0) -
+               static_cast<sal_Int32>(static_cast<unsigned char>(*pStr2));
+        if (!(nRet == 0 && nStr1Len && *pStr2 ))
+            break;
         /* Check ASCII range */
         SAL_WARN_IF( (static_cast<unsigned char>(*pStr2)) > 127, "rtl.string",
                     "rtl_ustr_ascii_compare_WithLength - Found char > 127" );


More information about the Libreoffice-commits mailing list