From c5a2862674d022b1f45ef74da79570620095805c Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 25 Jun 2015 14:26:08 +0300 Subject: Improve detecting null pointers in COMPONENT_REF. --- src/analysis/analysis.cpp | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/analysis/analysis.cpp b/src/analysis/analysis.cpp index 2be2381..024abc4 100644 --- a/src/analysis/analysis.cpp +++ b/src/analysis/analysis.cpp @@ -217,24 +217,27 @@ void reportParmDeclNullPointer(Node *mainNode, const WalkItem &wi) { node = skipNop(node); - if (node && !node->label.empty()) + if (node) { - if (node->nodeType == PARM_DECL) + if (!node->label.empty()) { - if (wi.checkNullVars.find(node->label) != wi.checkNullVars.end()) + if (node->nodeType == PARM_DECL) { - Log::warn(findBackLocation(mainNode), - "Using parameter '%s' without checking for null pointer", - node->label); + if (wi.checkNullVars.find(node->label) != wi.checkNullVars.end()) + { + Log::warn(findBackLocation(mainNode), + "Using parameter '%s' without checking for null pointer", + node->label); + } } - } - else if (node->nodeType == VAR_DECL) - { - if (wi.checkNullVars.find(node->label) != wi.checkNullVars.end()) + else if (node->nodeType == VAR_DECL) { - Log::warn(findBackLocation(mainNode), - "Using variable '%s' without checking for null pointer", - node->label); + if (wi.checkNullVars.find(node->label) != wi.checkNullVars.end()) + { + Log::warn(findBackLocation(mainNode), + "Using variable '%s' without checking for null pointer", + node->label); + } } } else if (node->nodeType == COMPONENT_REF) -- cgit v1.2.3-60-g2f50