From 49747ff2337fd1f4a3ee8e16d6328b8dacad99ec Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Sat, 3 Nov 2018 15:43:04 +0300 Subject: tdf#120703 PVS: V547 Expression is always true/false Change-Id: I75082c85862b83ed2503900186ce9c70783e54db Reviewed-on: https://gerrit.libreoffice.org/62817 Tested-by: Jenkins Reviewed-by: Mike Kaganski --- sc/source/filter/excel/excform.cxx | 5 +++-- sc/source/ui/view/dbfunc3.cxx | 35 ++++++++++++++++------------------- 2 files changed, 19 insertions(+), 21 deletions(-) (limited to 'sc') diff --git a/sc/source/filter/excel/excform.cxx b/sc/source/filter/excel/excform.cxx index de4f83c73121..ed4078f5fe25 100644 --- a/sc/source/filter/excel/excform.cxx +++ b/sc/source/filter/excel/excform.cxx @@ -1600,11 +1600,12 @@ void ExcelToSc::DoMulArgs( DefTokenId eId, sal_uInt8 nCnt ) // [Parameter{;Parameter}] if( nLast > nSkipEnd ) { + // nSkipEnd is either 0 or -1 => nLast >= 0 aPool << eParam[ nLast ]; for( nLauf = nLast - 1 ; nLauf > nSkipEnd ; nLauf-- ) { - if( nLauf != -1 ) // skip this parameter - aPool << ocSep << eParam[ nLauf ]; + // nLauf > nSkipEnd => nLauf >= 0 + aPool << ocSep << eParam[nLauf]; } } } diff --git a/sc/source/ui/view/dbfunc3.cxx b/sc/source/ui/view/dbfunc3.cxx index 8baad38731e2..7ca42e09f0e2 100644 --- a/sc/source/ui/view/dbfunc3.cxx +++ b/sc/source/ui/view/dbfunc3.cxx @@ -1697,29 +1697,26 @@ void ScDBFunc::DataPilotSort(ScDPObject* pDPObj, long nDimIndex, bool bAscending typedef std::unordered_map UserSortMap; UserSortMap aSubStrs; sal_uInt16 nSubCount = 0; - if (pUserListId) + ScUserList* pUserList = ScGlobal::GetUserList(); + if (!pUserList) + return; + { - ScUserList* pUserList = ScGlobal::GetUserList(); - if (!pUserList) + size_t n = pUserList->size(); + if (!n || *pUserListId >= static_cast(n)) return; + } - { - size_t n = pUserList->size(); - if (!n || *pUserListId >= static_cast(n)) - return; - } - - const ScUserListData& rData = (*pUserList)[*pUserListId]; - sal_uInt16 n = rData.GetSubCount(); - for (sal_uInt16 i = 0; i < n; ++i) - { - OUString aSub = rData.GetSubStr(i); - if (!aMemberSet.count(aSub)) - // This string doesn't exist in the member name set. Don't add this. - continue; + const ScUserListData& rData = (*pUserList)[*pUserListId]; + sal_uInt16 n = rData.GetSubCount(); + for (sal_uInt16 i = 0; i < n; ++i) + { + OUString aSub = rData.GetSubStr(i); + if (!aMemberSet.count(aSub)) + // This string doesn't exist in the member name set. Don't add this. + continue; - aSubStrs.emplace(aSub, nSubCount++); - } + aSubStrs.emplace(aSub, nSubCount++); } // Rank all members. -- cgit