From 913262dff4d1224cf0f6e8a58a88b49cbc2dcd10 Mon Sep 17 00:00:00 2001
From: Avi <thnkslprpt@gmail.com>
Date: Fri, 28 Oct 2022 19:58:01 +1000
Subject: [PATCH] Fix issue #169, Remove unnecessary null pointer checks

---
 src/PLASMA/ConstraintEngine/base/DataType.cc               | 3 +--
 src/PLASMA/PlanDatabase/base/ObjectType.cc                 | 6 ++----
 src/PLASMA/Resource/component/FlowProfile.hh               | 6 ++----
 src/PLASMA/Solvers/component/OpenConditionDecisionPoint.cc | 3 +--
 src/PLASMA/Utils/base/Logger-log4cpp.hh                    | 2 +-
 5 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/src/PLASMA/ConstraintEngine/base/DataType.cc b/src/PLASMA/ConstraintEngine/base/DataType.cc
index d5ae3419d..b4f5f243c 100644
--- a/src/PLASMA/ConstraintEngine/base/DataType.cc
+++ b/src/PLASMA/ConstraintEngine/base/DataType.cc
@@ -25,8 +25,7 @@ DataType::~DataType()
 {
     m_id.remove();
 
-    if (m_baseDomain != NULL)
-        delete m_baseDomain;
+    delete m_baseDomain;
 }
 
 const DataTypeId DataType::getId() const { return m_id; }
diff --git a/src/PLASMA/PlanDatabase/base/ObjectType.cc b/src/PLASMA/PlanDatabase/base/ObjectType.cc
index e73485177..4c8e520cd 100644
--- a/src/PLASMA/PlanDatabase/base/ObjectType.cc
+++ b/src/PLASMA/PlanDatabase/base/ObjectType.cc
@@ -506,8 +506,7 @@ void* ObjectEvalContext::getElement(const std::string& name) const {
 
   InterpretedObjectFactory::~InterpretedObjectFactory()
   {
-    if (m_superCallExpr != NULL)
-      delete m_superCallExpr;
+    delete m_superCallExpr;
 
     for (unsigned int i=0; i < m_constructorBody.size(); i++)
       delete m_constructorBody[i];
@@ -655,8 +654,7 @@ void* ObjectFactoryEvalContext::getElement(const std::string& name) const {
         );
         ObjectEvalContext evalContext(&factoryEvalContext,instance);
 
-        if (m_superCallExpr != NULL)
-            m_superCallExpr->eval(evalContext);
+        m_superCallExpr->eval(evalContext);
 
         for (unsigned int i=0; i < m_constructorBody.size(); i++)
             m_constructorBody[i]->eval(evalContext);
diff --git a/src/PLASMA/Resource/component/FlowProfile.hh b/src/PLASMA/Resource/component/FlowProfile.hh
index d5eef4b94..bebbb4af1 100644
--- a/src/PLASMA/Resource/component/FlowProfile.hh
+++ b/src/PLASMA/Resource/component/FlowProfile.hh
@@ -96,13 +96,11 @@ private:
    */
   template<typename FlowGraphType>
   void initializeGraphs() {
-    if(m_lowerLevelGraph != NULL)
-      delete m_lowerLevelGraph;
+    delete m_lowerLevelGraph;
     m_lowerLevelGraph = new FlowGraphType(m_dummySourceTransaction,
                                           m_dummySinkTransaction, true);
 
-    if(m_upperLevelGraph != NULL)
-      delete m_upperLevelGraph;
+    delete m_upperLevelGraph;
     m_upperLevelGraph = new FlowGraphType(m_dummySourceTransaction,
                                           m_dummySinkTransaction, false);
   }
diff --git a/src/PLASMA/Solvers/component/OpenConditionDecisionPoint.cc b/src/PLASMA/Solvers/component/OpenConditionDecisionPoint.cc
index 858f5600e..074db7b1b 100644
--- a/src/PLASMA/Solvers/component/OpenConditionDecisionPoint.cc
+++ b/src/PLASMA/Solvers/component/OpenConditionDecisionPoint.cc
@@ -219,8 +219,7 @@ SupportedOCDecisionPoint::~SupportedOCDecisionPoint()
 
   m_choices.clear();
 
-  if (m_heuristic != NULL)
-    delete m_heuristic;
+  delete m_heuristic;
 }
 
 std::string SupportedOCDecisionPoint::toString() const
diff --git a/src/PLASMA/Utils/base/Logger-log4cpp.hh b/src/PLASMA/Utils/base/Logger-log4cpp.hh
index 5e787acb3..9cdeb3f12 100644
--- a/src/PLASMA/Utils/base/Logger-log4cpp.hh
+++ b/src/PLASMA/Utils/base/Logger-log4cpp.hh
@@ -69,7 +69,7 @@ public:
 	    //TODO - mcr - iterate through and delete loggers
 	}
 	delete loggers;
-	if( instance != NULL ) {delete instance;}
+	delete instance;
     }
 
     void readConfiguration( string configFilename ) {