]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Cleanup: make static analyzers happier
authorAmos Jeffries <squid3@treenet.co.nz>
Sat, 6 Aug 2016 06:06:27 +0000 (18:06 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Sat, 6 Aug 2016 06:06:27 +0000 (18:06 +1200)
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 1364730136472713647241364729, 434088.

src/DelaySpec.cc
src/Parsing.cc

index b0da4ee41935cca46bbb5a63bda6d5154f0706e9..3e0afc24b56c5b68534c1b2943574fed8bd94fec 100644 (file)
@@ -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] == '-') {
index e49081eef25b1fee524eca042ccefc954fe5a943..7e04ae29db4c250304e203c2b43dfe1f6a1dd145 100644 (file)
@@ -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);
 }