tdf#120703 PVS: V560 A part of conditional expression is always true/false
Change-Id: I8d98aa7dd77fbd79611b8a4aba77e8c378fd1cae
Reviewed-on: https://gerrit.libreoffice.org/63981
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
diff --git a/cppcanvas/source/mtfrenderer/implrenderer.cxx b/cppcanvas/source/mtfrenderer/implrenderer.cxx
index cee91bc..84b46e0 100644
--- a/cppcanvas/source/mtfrenderer/implrenderer.cxx
+++ b/cppcanvas/source/mtfrenderer/implrenderer.cxx
@@ -2798,7 +2798,7 @@
aSubset.mnSubsetBegin = 0;
aSubset.mnSubsetEnd = nEndIndex - aRangeEnd->mnOrigIndex;
ENSURE_OR_RETURN_FALSE( aSubset.mnSubsetBegin >= 0 && aSubset.mnSubsetEnd >= 0,
ENSURE_OR_RETURN_FALSE(aSubset.mnSubsetEnd >= 0,
"ImplRenderer::forSubsetRange(): Invalid indices" );
rFunctor( *aRangeEnd, aSubset );
diff --git a/framework/source/layoutmanager/layoutmanager.cxx b/framework/source/layoutmanager/layoutmanager.cxx
index b33f925..d26927a 100644
--- a/framework/source/layoutmanager/layoutmanager.cxx
+++ b/framework/source/layoutmanager/layoutmanager.cxx
@@ -478,13 +478,12 @@
SolarMutexResettableGuard aWriteLock;
bool bGlobalSettings( bInGlobalSettings );
GlobalSettings* pGlobalSettings( nullptr );
if ( rGlobalSettings == nullptr )
{
rGlobalSettings.reset( new GlobalSettings( rComponentContext ) );
bGetSettingsState = true;
}
pGlobalSettings = rGlobalSettings.get();
GlobalSettings* pGlobalSettings = rGlobalSettings.get();
aWriteLock.clear();
try
@@ -563,7 +562,7 @@
}
// oversteer values with global settings
if ( pGlobalSettings && ( bGetSettingsState || bGlobalSettings ))
if (bGetSettingsState || bGlobalSettings)
{
if ( pGlobalSettings->HasToolbarStatesInfo())
{
diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index dea71b5e..71ee7fd 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -1146,7 +1146,7 @@
rendEl("style:header");
}
/* Will be the default. */
else if( pPage->header_odd && !pPage->header_even )
else if (pPage->header_odd)
{
rstartEl("style:header", mxList.get());
padd("text:style-name", sXML_CDATA, "Standard");
@@ -1181,7 +1181,7 @@
rendEl("style:header-left");
}
/* Will be the default. */
else if( pPage->header_even && !pPage->header_odd )
else if (pPage->header_even)
{
rstartEl("style:header-left", mxList.get());
padd("text:style-name", sXML_CDATA, "Standard");
@@ -1247,7 +1247,7 @@
rendEl("style:footer");
}
/* Will be the default. */
else if( pPage->footer_odd && !pPage->footer_even )
else if (pPage->footer_odd)
{
rstartEl("style:footer", mxList.get());
padd("text:style-name", sXML_CDATA, "Standard");
@@ -1282,7 +1282,7 @@
rendEl("style:footer-left");
}
/* Will be the default. */
else if( pPage->footer_even && !pPage->footer_odd )
else if (pPage->footer_even)
{
rstartEl("style:footer-left", mxList.get());
padd("text:style-name", sXML_CDATA, "Standard");
diff --git a/lingucomponent/source/hyphenator/hyphen/hyphenimp.cxx b/lingucomponent/source/hyphenator/hyphen/hyphenimp.cxx
index 01c587c..181d6a8 100644
--- a/lingucomponent/source/hyphenator/hyphen/hyphenimp.cxx
+++ b/lingucomponent/source/hyphenator/hyphen/hyphenimp.cxx
@@ -381,7 +381,7 @@
{
int leftrep = 0;
bool hit = (n >= minLen);
if (!rep || !rep[i] || (i >= n))
if (!rep || !rep[i])
{
hit = hit && (hyphens[i]&1) && (i < Leading);
hit = hit && (i >= (minLead-1) );
@@ -407,7 +407,7 @@
if (hit)
{
nHyphenationPos = i;
if (rep && (i < n) && rep[i])
if (rep && rep[i])
{
nHyphenationPosAlt = i - pos[i];
nHyphenationPosAltHyph = i + leftrep - pos[i];
diff --git a/linguistic/source/gciterator.cxx b/linguistic/source/gciterator.cxx
index 9e1e115..5d27876 100644
--- a/linguistic/source/gciterator.cxx
+++ b/linguistic/source/gciterator.cxx
@@ -206,14 +206,11 @@
if (0 <= nPosBefore && nPosBefore < nLen && lcl_IsWhiteSpace( pStart[ nPosBefore ] ))
{
nStartPos = nPosBefore;
if (0 <= nStartPos && nStartPos < nLen)
{
const sal_Unicode *pText = rText.getStr() + nStartPos;
while (pText > pStart && lcl_IsWhiteSpace( *pText ))
--pText;
// now add 1 since we want to point to the first char after the last char in the sentence...
nRes = pText - pStart + 1;
}
const sal_Unicode *pText = rText.getStr() + nStartPos;
while (pText > pStart && lcl_IsWhiteSpace( *pText ))
--pText;
// now add 1 since we want to point to the first char after the last char in the sentence...
nRes = pText - pStart + 1;
}
DBG_ASSERT( 0 <= nRes && nRes <= nLen, "lcl_BacktraceWhiteSpaces return value out of range" );
diff --git a/reportdesign/source/ui/dlg/GroupsSorting.cxx b/reportdesign/source/ui/dlg/GroupsSorting.cxx
index a47ae0e..bac0c4d 100644
--- a/reportdesign/source/ui/dlg/GroupsSorting.cxx
+++ b/reportdesign/source/ui/dlg/GroupsSorting.cxx
@@ -887,8 +887,8 @@
void OGroupsSortingDialog::DisplayData( sal_Int32 _nRow )
{
sal_Int32 nGroupPos = m_pFieldExpression->getGroupPosition(_nRow);
bool bEmpty = nGroupPos == NO_GROUP;
const sal_Int32 nGroupPos = m_pFieldExpression->getGroupPosition(_nRow);
const bool bEmpty = nGroupPos == NO_GROUP;
m_pProperties->Enable(!bEmpty);
checkButtons(_nRow);
@@ -896,7 +896,7 @@
if ( m_pCurrentGroupListener.is() )
m_pCurrentGroupListener->dispose();
m_pCurrentGroupListener = nullptr;
if ( !bEmpty && nGroupPos != NO_GROUP )
if (!bEmpty)
{
uno::Reference< report::XGroup> xGroup = getGroup(nGroupPos);
diff --git a/sc/source/core/data/global2.cxx b/sc/source/core/data/global2.cxx
index 6ae017c..04687ebf 100644
--- a/sc/source/core/data/global2.cxx
+++ b/sc/source/core/data/global2.cxx
@@ -229,7 +229,7 @@
bEqual = true;
else if ( !pStrTargetVal || !r.pStrTargetVal )
bEqual = false;
else if ( pStrTargetVal && r.pStrTargetVal )
else
bEqual = ( *pStrTargetVal == *(r.pStrTargetVal) );
}
diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx
index c151000..aeba2c6 100644
--- a/sc/source/core/tool/interpr2.cxx
+++ b/sc/source/core/tool/interpr2.cxx
@@ -627,7 +627,7 @@
while ( nRef >= 0 && nSortArray.at( nRef ) > nDate )
nRef--;
if ( !( nRef >= 0 && nSortArray.at( nRef ) == nDate ) || nRef < 0 )
if (nRef < 0 || nSortArray.at(nRef) != nDate)
nDays++;
}
}
diff --git a/sc/source/core/tool/interpr3.cxx b/sc/source/core/tool/interpr3.cxx
index 56078ea..ac980b7 100644
--- a/sc/source/core/tool/interpr3.cxx
+++ b/sc/source/core/tool/interpr3.cxx
@@ -218,7 +218,7 @@
0.00000000011301172, 0.00000000000511243, -0.00000000000021218 };
nVal = taylor(t0, 11, (xAbs * xAbs)) * xAbs;
}
else if ((xShort >= 1) && (xShort <= 2))
else if (xShort <= 2)
{
static const double t2[] =
{ 0.47724986805182079, 0.05399096651318805, -0.05399096651318805,
@@ -231,7 +231,7 @@
-0.00000000000172127, -0.00000000000008634, 0.00000000000007894 };
nVal = taylor(t2, 23, (xAbs - 2.0));
}
else if ((xShort >= 3) && (xShort <= 4))
else if (xShort <= 4)
{
static const double t4[] =
{ 0.49996832875816688, 0.00013383022576489, -0.00026766045152977,
@@ -4083,7 +4083,7 @@
double fFirstPos = -1.0;
bool bFinished = false;
SCSIZE i;
for ( i = 0; i < nSize && !bFinished && nGlobalError == FormulaError::NONE; i++ )
for (i = 0; i < nSize && !bFinished; i++)
{
if ( aSortArray[ i ] == fVal )
{
diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx
index 2ab0091..c898d7a 100644
--- a/sc/source/core/tool/interpr5.cxx
+++ b/sc/source/core/tool/interpr5.cxx
@@ -740,7 +740,7 @@
bool bSingular=false;
for (SCSIZE i=0; i<n && !bSingular; i++)
bSingular = bSingular || ((mA->GetDouble(i,i))==0.0);
bSingular = (mA->GetDouble(i,i)) == 0.0;
if (bSingular)
nSign = 0;
@@ -2520,7 +2520,7 @@
// that they aren't zero.
bool bIsSingular=false;
for (SCSIZE row=0; row < K && !bIsSingular; row++)
bIsSingular = bIsSingular || aVecR[row]==0.0;
bIsSingular = aVecR[row] == 0.0;
if (bIsSingular)
{
PushNoValue();
@@ -2677,7 +2677,7 @@
// that they aren't zero.
bool bIsSingular=false;
for (SCSIZE row=0; row < K && !bIsSingular; row++)
bIsSingular = bIsSingular || aVecR[row]==0.0;
bIsSingular = aVecR[row] == 0.0;
if (bIsSingular)
{
PushNoValue();
@@ -3018,7 +3018,7 @@
// that they aren't zero.
bool bIsSingular=false;
for (SCSIZE row=0; row < K && !bIsSingular; row++)
bIsSingular = bIsSingular || aVecR[row]==0.0;
bIsSingular = aVecR[row] == 0.0;
if (bIsSingular)
{
PushNoValue();
@@ -3077,7 +3077,7 @@
// that they aren't zero.
bool bIsSingular=false;
for (SCSIZE row=0; row < K && !bIsSingular; row++)
bIsSingular = bIsSingular || aVecR[row]==0.0;
bIsSingular = aVecR[row] == 0.0;
if (bIsSingular)
{
PushNoValue();
diff --git a/sd/source/ui/dlg/headerfooterdlg.cxx b/sd/source/ui/dlg/headerfooterdlg.cxx
index 1be962a..6f3e646 100644
--- a/sd/source/ui/dlg/headerfooterdlg.cxx
+++ b/sd/source/ui/dlg/headerfooterdlg.cxx
@@ -662,7 +662,7 @@
for (sal_Int32 nPara = 0; (nPara < nParaCount) && !bHasDateFieldItem; ++nPara)
{
sal_uInt16 nFieldCount = pEdit->GetFieldCount(nPara);
for (sal_uInt16 nField = 0; (nField < nFieldCount) && !bHasDateFieldItem; ++nField)
for (sal_uInt16 nField = 0; (nField < nFieldCount); ++nField)
{
EFieldInfo aFieldInfo = pEdit->GetFieldInfo(nPara, nField);
if (aFieldInfo.pFieldItem)
diff --git a/sdext/source/minimizer/impoptimizer.cxx b/sdext/source/minimizer/impoptimizer.cxx
index b1559d9..da4f611 100644
--- a/sdext/source/minimizer/impoptimizer.cxx
+++ b/sdext/source/minimizer/impoptimizer.cxx
@@ -306,7 +306,7 @@
if ( ( aSourceSizePixel.Width > 0 ) && ( aSourceSizePixel.Height > 0 ) )
{
OUString aDestMimeType( "image/png" );
if ( rGraphicSettings.mbJPEGCompression && !bTransparent && !bAlpha && !bAnimated )
if (rGraphicSettings.mbJPEGCompression && !bTransparent && !bAlpha)
{
aDestMimeType = "image/jpeg";
// if( aSourceMimeType != aDestMimeType )
diff --git a/smoketest/libtest.cxx b/smoketest/libtest.cxx
index 244d32a..c23f1d2 100644
--- a/smoketest/libtest.cxx
+++ b/smoketest/libtest.cxx
@@ -73,8 +73,7 @@
start = getTimeMS();
if( argc < 2 ||
( argc > 1 && ( !strcmp( argv[1], "--help" ) || !strcmp( argv[1], "-h" ) ) ) )
if (argc < 2 || !strcmp(argv[1], "--help") || !strcmp(argv[1], "-h"))
return help();
diff --git a/svtools/source/contnr/imivctl1.cxx b/svtools/source/contnr/imivctl1.cxx
index 0f11688..06656229 100644
--- a/svtools/source/contnr/imivctl1.cxx
+++ b/svtools/source/contnr/imivctl1.cxx
@@ -2425,7 +2425,7 @@
if( bSelected )
SelectEntry( pEntry, false, true );
}
else if( bAdd && bOverlaps )
else if (bOverlaps)
{
// The entry is inside an old (=>span multiple rectangles with Ctrl)
// selection rectangle.
diff --git a/svtools/source/control/inettbc.cxx b/svtools/source/control/inettbc.cxx
index 5120dfd..bcd14d5 100644
--- a/svtools/source/control/inettbc.cxx
+++ b/svtools/source/control/inettbc.cxx
@@ -1150,12 +1150,11 @@
INetProtocol eBaseProt = INetURLObject::CompareProtocolScheme( pBox->aBaseURL );
if ( pBox->aBaseURL.isEmpty() )
eBaseProt = INetURLObject::CompareProtocolScheme( SvtPathOptions().GetWorkPath() );
INetProtocol eSmartProt = INetProtocol::NotValid;
// if the user input is a valid URL, go on with it
// otherwise it could be parsed smart with a predefined smart protocol
// ( or if this is not set with the protocol of a predefined base URL )
if( eProt == INetProtocol::NotValid || eProt == eSmartProt || (eSmartProt == INetProtocol::NotValid && eProt == eBaseProt) )
if (eProt == INetProtocol::NotValid || eProt == eBaseProt)
{
// not stopped yet ?
if( schedule() )
@@ -1264,7 +1263,7 @@
INetURLObject aCurObj;
OUString aCurString, aCurMainURL;
INetURLObject aObj;
aObj.SetSmartProtocol( eSmartProt == INetProtocol::NotValid ? INetProtocol::Http : eSmartProt );
aObj.SetSmartProtocol(INetProtocol::Http);
for( ;; )
{
for(const auto& rPick : aPickList)
@@ -1279,9 +1278,6 @@
if( eProt != INetProtocol::NotValid && aCurObj.GetProtocol() != eProt )
continue;
if( eSmartProt != INetProtocol::NotValid && aCurObj.GetProtocol() != eSmartProt )
continue;
switch( aCurObj.GetProtocol() )
{
case INetProtocol::Http:
diff --git a/svx/source/dialog/graphctl.cxx b/svx/source/dialog/graphctl.cxx
index 22a4443..1292020 100644
--- a/svx/source/dialog/graphctl.cxx
+++ b/svx/source/dialog/graphctl.cxx
@@ -463,7 +463,7 @@
else
{
// move handle with index nHandleIndex
if(pHdl && (nX || nY))
if (nX || nY)
{
// now move the Handle (nX, nY)
Point aStartPoint(pHdl->GetPos());
diff --git a/svx/source/fmcomp/gridctrl.cxx b/svx/source/fmcomp/gridctrl.cxx
index 0827efb..d52cf33 100644
--- a/svx/source/fmcomp/gridctrl.cxx
+++ b/svx/source/fmcomp/gridctrl.cxx
@@ -2352,7 +2352,7 @@
DBG_ASSERT( !m_pSeekCursor->isAfterLast() && !m_pSeekCursor->isBeforeFirst(),
"DbGridControl::SeekCursor: how did the seek cursor get to this position?!" );
nSteps = nRow - (m_pSeekCursor->getRow() - 1);
bAbsolute = bAbsolute || (std::abs(nSteps) > 100);
bAbsolute = std::abs(nSteps) > 100;
}
if ( bAbsolute )
diff --git a/sw/source/core/layout/hffrm.cxx b/sw/source/core/layout/hffrm.cxx
index da34428..c3c5e34 100644
--- a/sw/source/core/layout/hffrm.cxx
+++ b/sw/source/core/layout/hffrm.cxx
@@ -715,7 +715,7 @@
if ( GetUpper() )
::RegistFlys( this, pH );
}
else if ( pLay && pLay->IsHeaderFrame() )
else if (pLay->IsHeaderFrame())
{ // Remove header if present.
::DelFlys( pLay, this );
pLay->Cut();
diff --git a/sw/source/filter/html/htmlatr.cxx b/sw/source/filter/html/htmlatr.cxx
index 2edf9a5..f3c55482 100644
--- a/sw/source/filter/html/htmlatr.cxx
+++ b/sw/source/filter/html/htmlatr.cxx
@@ -441,7 +441,6 @@
bool bNoEndTag = false; // don't output an end tag
rHWrt.m_bNoAlign = false; // no ALIGN=... possible
bool bNoStyle = false; // no STYLE=... possible
sal_uInt8 nBulletGrfLvl = 255; // The bullet graphic we want to output
// Are we in a bulleted or numbered list?
@@ -811,7 +810,6 @@
aToken = OOO_STRING_SVTOOLS_HTML_parabreak;
bPara = true;
rHWrt.m_bNoAlign = false;
bNoStyle = false;
}
LanguageType eLang;
@@ -921,7 +919,7 @@
pTextNd->GetAnyFormatColl().GetPoolFormatId(), pTextNd->GetText()) > -1;
// and now, if necessary, the STYLE options
if( rHWrt.m_bCfgOutStyles && rInfo.pItemSet && !bNoStyle)
if (rHWrt.m_bCfgOutStyles && rInfo.pItemSet)
{
OutCSS1_ParaTagStyleOpt( rWrt, *rInfo.pItemSet );
}
@@ -2368,8 +2366,7 @@
bool bOutChar = true;
const SwTextAttr * pTextHt = nullptr;
if( nAttrPos < nCntAttr && pHt->GetStart() == nStrPos
&& nStrPos != nEnd )
if (nAttrPos < nCntAttr && pHt->GetStart() == nStrPos)
{
do {
if ( pHt->End() && !pHt->HasDummyChar() )
diff --git a/sw/source/filter/html/htmlcss1.cxx b/sw/source/filter/html/htmlcss1.cxx
index 26b6d2d..cd94832 100644
--- a/sw/source/filter/html/htmlcss1.cxx
+++ b/sw/source/filter/html/htmlcss1.cxx
@@ -755,7 +755,7 @@
InsertTag( aToken2, rItemSet, rPropInfo );
return;
}
else if( pNext && CSS1_SELTYPE_PSEUDO == eNextType )
else if (CSS1_SELTYPE_PSEUDO == eNextType)
{
// maybe A:visited or A:link
diff --git a/sw/source/filter/html/htmlform.cxx b/sw/source/filter/html/htmlform.cxx
index d6b641ff..43873b2d 100644
--- a/sw/source/filter/html/htmlform.cxx
+++ b/sw/source/filter/html/htmlform.cxx
@@ -507,11 +507,8 @@
const SwDoc *pDoc = pFrameFormat->GetDoc();
const SwPosition* pAPos = pFrameFormat->GetAnchor().GetContentAnchor();
SwNode *pANd;
SwTableNode *pTableNd;
if( pAPos &&
nullptr != (pANd = & pAPos->nNode.GetNode()) &&
nullptr != (pTableNd = pANd->FindTableNode()) )
if (pAPos && nullptr != (pTableNd = pAPos->nNode.GetNode().FindTableNode()))
{
const bool bLastGrf = !pTableNd->GetTable().DecGrfsThatResize();
SwHTMLTableLayout *pLayout =
diff --git a/sw/source/filter/html/htmltabw.cxx b/sw/source/filter/html/htmltabw.cxx
index d0dd6ca..13dd69c 100644
--- a/sw/source/filter/html/htmltabw.cxx
+++ b/sw/source/filter/html/htmltabw.cxx
@@ -694,7 +694,7 @@
{
rWrt.OutBackground( pFrameFormat->GetAttrSet(), false );
if( rWrt.m_bCfgOutStyles && pFrameFormat )
if (rWrt.m_bCfgOutStyles)
rWrt.OutCSS1_TableFrameFormatOptions( *pFrameFormat );
}
diff --git a/tools/source/inet/inetmime.cxx b/tools/source/inet/inetmime.cxx
index 0b0cafc..decd104 100644
--- a/tools/source/inet/inetmime.cxx
+++ b/tools/source/inet/inetmime.cxx
@@ -1163,7 +1163,7 @@
for (const sal_Char * p = pBegin; p != pEnd;)
{
OUString sEncodedText;
if (p != pEnd && *p == '=' /* && bStartEncodedWord */)
if (*p == '=' /* && bStartEncodedWord */)
{
const sal_Char * q = p + 1;
bool bEncodedWord = q != pEnd && *q++ == '?';
diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx
index 6eaccfb..efe986c 100644
--- a/vcl/source/filter/graphicfilter.cxx
+++ b/vcl/source/filter/graphicfilter.cxx
@@ -1675,7 +1675,6 @@
ErrCode nStatus;
GfxLinkType eLinkType = GfxLinkType::NONE;
const bool bLinkSet = rGraphic.IsGfxLink();
std::unique_ptr<FilterConfigItem> pFilterConfigItem;
Size aPreviewSizeHint( 0, 0 );
bool bAllowPartialStreamRead = false;
@@ -2018,11 +2017,12 @@
nStatus = ERRCODE_GRFILTER_FILTERERROR;
else
{
std::unique_ptr<FilterConfigItem> pFilterConfigItem;
OUString aShortName;
if( nFormat != GRFILTER_FORMAT_DONTKNOW )
{
aShortName = GetImportFormatShortName( nFormat ).toAsciiUpperCase();
if ( ( !pFilterConfigItem ) && aShortName == "PCD" )
if (aShortName == "PCD")
{
OUString aFilterConfigPath( "Office.Common/Filter/Graphic/Import/PCD" );
pFilterConfigItem = o3tl::make_unique<FilterConfigItem>( aFilterConfigPath );
diff --git a/vcl/source/treelist/imap2.cxx b/vcl/source/treelist/imap2.cxx
index d2bcc37..80df5e6 100644
--- a/vcl/source/treelist/imap2.cxx
+++ b/vcl/source/treelist/imap2.cxx
@@ -254,7 +254,7 @@
// find instruction
OStringBuffer aBuf;
while( ( cChar >= 'a' ) && ( cChar <= 'z' ) && NOTEOL( cChar ) )
while ((cChar >= 'a') && (cChar <= 'z'))
{
aBuf.append(cChar);
cChar = *pStr++;
@@ -389,7 +389,7 @@
// find instruction
OStringBuffer aBuf;
while( ( cChar >= 'a' ) && ( cChar <= 'z' ) && NOTEOL( cChar ) )
while ((cChar >= 'a') && (cChar <= 'z'))
{
aBuf.append(cChar);
cChar = *pStr++;