From df62ebebc1b784a60ef7ac7a0246e044f5ccc64b Mon Sep 17 00:00:00 2001 From: Avi Date: Fri, 28 Oct 2022 19:31:07 +1000 Subject: [PATCH] Fix #169, Remove unnecessary null pointer checks --- src/PLASMA/ANML/base/ANMLTranslator.cc | 3 +-- src/PLASMA/ConstraintEngine/base/DataType.cc | 3 +-- src/PLASMA/ConstraintEngine/component/Constraints.cc | 6 ++---- src/PLASMA/NDDL/component/Interpreter.cc | 9 +++------ src/PLASMA/PlanDatabase/base/ObjectType.cc | 3 +-- src/PLASMA/Resource/component/FlowProfile.hh | 6 ++---- src/PLASMA/RulesEngine/base/RuleInstance.cc | 3 +-- .../Solvers/component/OpenConditionDecisionPoint.cc | 3 +-- src/PLASMA/Utils/base/Logger-log4cpp.hh | 2 +- 9 files changed, 13 insertions(+), 25 deletions(-) diff --git a/src/PLASMA/ANML/base/ANMLTranslator.cc b/src/PLASMA/ANML/base/ANMLTranslator.cc index 74ea695b9..ad3ec103d 100644 --- a/src/PLASMA/ANML/base/ANMLTranslator.cc +++ b/src/PLASMA/ANML/base/ANMLTranslator.cc @@ -1239,8 +1239,7 @@ namespace ANML Change::~Change() { - if (m_whenCondition != NULL) - delete m_whenCondition; + delete m_whenCondition; delete m_changeStmt; } 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/ConstraintEngine/component/Constraints.cc b/src/PLASMA/ConstraintEngine/component/Constraints.cc index 68692eb70..9647f8212 100644 --- a/src/PLASMA/ConstraintEngine/component/Constraints.cc +++ b/src/PLASMA/ConstraintEngine/component/Constraints.cc @@ -1085,8 +1085,7 @@ EqualSumConstraint::EqualSumConstraint(const std::string& name, if (canProveTrue) boolDom.remove(false); // Before it goes out of scope: - if (common != 0) - delete common; + delete common; } //if !boolDom.isSingleton // Whether the condition was singleton on entry to this function @@ -1324,8 +1323,7 @@ void addToUnion(Domain **unionOfDomains, } } // for ( ; i < ARG_COUNT; i++) // Don't need this below, so: - if (unionOfOthers != 0) - delete unionOfOthers; + delete unionOfOthers; if (canProveTrue) boolDom.remove(false); diff --git a/src/PLASMA/NDDL/component/Interpreter.cc b/src/PLASMA/NDDL/component/Interpreter.cc index c0be9b04a..c98d410ce 100644 --- a/src/PLASMA/NDDL/component/Interpreter.cc +++ b/src/PLASMA/NDDL/component/Interpreter.cc @@ -1918,8 +1918,7 @@ DataRef ExprEnumdef::eval(EvalContext& context) const { ExprVarDeclaration::~ExprVarDeclaration() { - if (m_initValue != NULL) - delete m_initValue; + delete m_initValue; } const std::string& ExprVarDeclaration::getName() const { return m_name; } @@ -2238,8 +2237,7 @@ void evalArgs(EvalContext& context, ExprMethodCall::~ExprMethodCall() { - if (m_varExpr != NULL) - delete m_varExpr; + delete m_varExpr; for (unsigned int i=0;i 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/RulesEngine/base/RuleInstance.cc b/src/PLASMA/RulesEngine/base/RuleInstance.cc index 95400d446..7b4599cbe 100644 --- a/src/PLASMA/RulesEngine/base/RuleInstance.cc +++ b/src/PLASMA/RulesEngine/base/RuleInstance.cc @@ -145,8 +145,7 @@ RuleInstance::RuleInstance(const RuleInstanceId parent, undo(); // If there is a guard domain, delete it - if(m_guardDomain != 0) - delete m_guardDomain; + delete m_guardDomain; // Delete the guard listener if we are not in purge mode. Purge mode will handle the deletion // of the constraint in the Constraint Engine. We can deactivate this constraint since it does not impose a restriction 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 ) {