summaryrefslogtreecommitdiff
path: root/sal
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-04-15 09:13:58 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-04-15 11:24:09 +0200
commit72d8f2961fd7f5670fe2564eeb3aa14a6eaf0d8d (patch)
tree7185da37593987f6084254f46705e2fe0890da65 /sal
parent7965bb9a1d8b29778c6eac279537952e6a9e9502 (diff)
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@collabora.co.uk>
Diffstat (limited to 'sal')
-rw-r--r--sal/osl/unx/profile.cxx14
-rw-r--r--sal/rtl/math.cxx16
-rw-r--r--sal/rtl/strtmpl.cxx8
-rw-r--r--sal/rtl/ustring.cxx16
4 files changed, 34 insertions, 20 deletions
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" );