From e473d49f5666382a8d5b696a00330a55c889f56e Mon Sep 17 00:00:00 2001 From: Mike Kaganski Date: Sun, 21 Oct 2018 17:08:51 +0200 Subject: tdf#120703 (PVS): redundant nullptr check; loop index size V668 There is no sense in testing the 's' pointer against null, as the memory was allocated using the 'new' operator. The exception will be generated in the case of memory allocation error. V1029 Numeric Truncation Error. Result of the 'size' function is written to the 16-bit variable. Change-Id: I8e0598e892ca160ac074bccfed87c14367a3b46a Reviewed-on: https://gerrit.libreoffice.org/62139 Tested-by: Jenkins Reviewed-by: Mike Kaganski --- svl/source/svdde/ddesvr.cxx | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/svl/source/svdde/ddesvr.cxx b/svl/source/svdde/ddesvr.cxx index 1848342b893b..b9b6bcce4660 100644 --- a/svl/source/svdde/ddesvr.cxx +++ b/svl/source/svdde/ddesvr.cxx @@ -577,11 +577,8 @@ DdeItem* DdeTopic::AddItem( const DdeItem& r ) else s = new DdeItem( r ); - if ( s ) - { - aItems.push_back( s ); - s->pMyTopic = this; - } + aItems.push_back( s ); + s->pMyTopic = this; return s; } @@ -770,9 +767,9 @@ short DdeItem::GetLinks() short nCnt = 0; if( pImpData ) { - for( sal_uInt16 n = pImpData->size(); n; ) + for (const auto& rData : *pImpData) { - nCnt = nCnt + (*pImpData)[ --n ].nCnt; + nCnt += rData.nCnt; } } return nCnt; -- cgit v1.2.3