[Libreoffice-commits] core.git: sc/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sun Nov 18 10:07:35 UTC 2018


 sc/source/ui/inc/conflictsdlg.hxx      |    2 +-
 sc/source/ui/miscdlgs/conflictsdlg.cxx |   22 +++++++++++-----------
 2 files changed, 12 insertions(+), 12 deletions(-)

New commits:
commit cf6b3bece7d46878302075329c72c7541c65bbd0
Author:     Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Tue Nov 13 00:56:15 2018 +0300
Commit:     Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Sun Nov 18 11:07:12 2018 +0100

    tdf#120703 PVS: Let ScConflictsFinder::GetEntry return reference
    
    V560 A part of conditional expression is always true: pEntry.
    
    V560 A part of conditional expression is always true: pConflictEntry.
    
    Change-Id: I54fad2b0236c8c686f470a50ce45b096a842d56a
    Reviewed-on: https://gerrit.libreoffice.org/63519
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>

diff --git a/sc/source/ui/inc/conflictsdlg.hxx b/sc/source/ui/inc/conflictsdlg.hxx
index 5e1b742e7a4c..818023d75269 100644
--- a/sc/source/ui/inc/conflictsdlg.hxx
+++ b/sc/source/ui/inc/conflictsdlg.hxx
@@ -83,7 +83,7 @@ private:
 
     static bool             DoActionsIntersect( const ScChangeAction* pAction1, const ScChangeAction* pAction2 );
     ScConflictsListEntry*   GetIntersectingEntry( const ScChangeAction* pAction ) const;
-    ScConflictsListEntry*   GetEntry( sal_uLong nSharedAction, const std::vector<sal_uLong>& rOwnActions );
+    ScConflictsListEntry&   GetEntry(sal_uLong nSharedAction, const std::vector<sal_uLong>& rOwnActions);
 
 public:
                             ScConflictsFinder( ScChangeTrack* pTrack, sal_uLong nStartShared, sal_uLong nEndShared,
diff --git a/sc/source/ui/miscdlgs/conflictsdlg.cxx b/sc/source/ui/miscdlgs/conflictsdlg.cxx
index ee8104724c02..82270b55c0d2 100644
--- a/sc/source/ui/miscdlgs/conflictsdlg.cxx
+++ b/sc/source/ui/miscdlgs/conflictsdlg.cxx
@@ -155,13 +155,13 @@ ScConflictsListEntry* ScConflictsFinder::GetIntersectingEntry( const ScChangeAct
     return nullptr;
 }
 
-ScConflictsListEntry* ScConflictsFinder::GetEntry( sal_uLong nSharedAction, const std::vector<sal_uLong>& rOwnActions )
+ScConflictsListEntry& ScConflictsFinder::GetEntry( sal_uLong nSharedAction, const std::vector<sal_uLong>& rOwnActions )
 {
     // try to get a list entry which already contains the shared action
     ScConflictsListEntry* pEntry = ScConflictsListHelper::GetSharedActionEntry( mrConflictsList, nSharedAction );
     if ( pEntry )
     {
-        return pEntry;
+        return *pEntry;
     }
 
     // try to get a list entry for which the shared action intersects with any
@@ -170,7 +170,7 @@ ScConflictsListEntry* ScConflictsFinder::GetEntry( sal_uLong nSharedAction, cons
     if ( pEntry )
     {
         pEntry->maSharedActions.push_back( nSharedAction );
-        return pEntry;
+        return *pEntry;
     }
 
     // try to get a list entry for which any of the own actions intersects with
@@ -181,7 +181,7 @@ ScConflictsListEntry* ScConflictsFinder::GetEntry( sal_uLong nSharedAction, cons
         if ( pEntry )
         {
             pEntry->maSharedActions.push_back( nSharedAction );
-            return pEntry;
+            return *pEntry;
         }
     }
 
@@ -190,7 +190,7 @@ ScConflictsListEntry* ScConflictsFinder::GetEntry( sal_uLong nSharedAction, cons
     aEntry.meConflictAction = SC_CONFLICT_ACTION_NONE;
     aEntry.maSharedActions.push_back( nSharedAction );
     mrConflictsList.push_back( aEntry );
-    return &(mrConflictsList.back());
+    return mrConflictsList.back();
 }
 
 bool ScConflictsFinder::Find()
@@ -217,12 +217,12 @@ bool ScConflictsFinder::Find()
 
         if ( !aOwnActions.empty() )
         {
-            ScConflictsListEntry* pEntry = GetEntry( pSharedAction->GetActionNumber(), aOwnActions );
+            ScConflictsListEntry& rEntry = GetEntry(pSharedAction->GetActionNumber(), aOwnActions);
             for ( auto& aOwnAction : aOwnActions )
             {
-                if ( pEntry && !ScConflictsListHelper::HasOwnAction( mrConflictsList, aOwnAction ) )
+                if (!ScConflictsListHelper::HasOwnAction(mrConflictsList, aOwnAction))
                 {
-                    pEntry->maOwnActions.push_back( aOwnAction );
+                    rEntry.maOwnActions.push_back(aOwnAction);
                 }
             }
             bReturn = true;
@@ -631,11 +631,11 @@ void ScConflictsDlg::UpdateView()
     ScConflictsList::iterator aEndItr = mrConflictsList.end();
     for ( ScConflictsList::iterator aItr = mrConflictsList.begin(); aItr != aEndItr; ++aItr )
     {
-        ScConflictsListEntry* pConflictEntry = &(*aItr);
-        if ( pConflictEntry && pConflictEntry->meConflictAction == SC_CONFLICT_ACTION_NONE )
+        ScConflictsListEntry& rConflictEntry = *aItr;
+        if (rConflictEntry.meConflictAction == SC_CONFLICT_ACTION_NONE)
         {
             RedlinData* pRootUserData = new RedlinData();
-            pRootUserData->pData = static_cast< void* >( pConflictEntry );
+            pRootUserData->pData = static_cast<void*>(&rConflictEntry);
             SvTreeListEntry* pRootEntry = m_pLbConflicts->InsertEntry( GetConflictString( *aItr ), pRootUserData );
 
             for ( auto& aSharedAction : aItr->maSharedActions )


More information about the Libreoffice-commits mailing list