From b9e4cf0934a7586f9ec23e0d661fb602dfe539ad Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Sat, 6 Aug 2016 18:06:27 +1200 Subject: [PATCH] Cleanup: make static analyzers happier Coverity and other static analyers are not smart enough to detect that self_destruct() does not return.SO get confused about NULL derefernces. Coverity Scan. Issues 1364730, 1364727, 1364724, 1364729, 434088. --- src/DelaySpec.cc | 4 +++- src/Parsing.cc | 15 ++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/DelaySpec.cc b/src/DelaySpec.cc index b0da4ee419..3e0afc24b5 100644 --- a/src/DelaySpec.cc +++ b/src/DelaySpec.cc @@ -43,8 +43,10 @@ DelaySpec::parse() { // get the token. char *token = ConfigParser::NextToken(); - if (token == NULL) + if (!token) { self_destruct(); + return; + } // no-limit value if (strcmp(token, "none") == 0 || token[0] == '-') { diff --git a/src/Parsing.cc b/src/Parsing.cc index e49081eef2..7e04ae29db 100644 --- a/src/Parsing.cc +++ b/src/Parsing.cc @@ -126,9 +126,10 @@ int64_t GetInteger64(void) { char *token = ConfigParser::NextToken(); - - if (token == NULL) + if (!token) { self_destruct(); + return -1; // not reachable + } return xatoll(token, 10); } @@ -143,8 +144,10 @@ GetInteger(void) char *token = ConfigParser::NextToken(); int i; - if (token == NULL) + if (!token) { self_destruct(); + return -1; // not reachable + } // The conversion must honor 0 and 0x prefixes, which are important for things like umask int64_t ret = xatoll(token, 0); @@ -173,6 +176,7 @@ GetPercentage(bool limit) if (!token) { debugs(3, DBG_CRITICAL, "FATAL: A percentage value is missing."); self_destruct(); + return 0.0; // not reachable } //if there is a % in the end of the digits, we remove it and go on. @@ -195,9 +199,10 @@ unsigned short GetShort(void) { char *token = ConfigParser::NextToken(); - - if (token == NULL) + if (!token) { self_destruct(); + return 0; // not reachable + } return xatos(token); } -- 2.47.2