You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2017/05/18 14:11:54 UTC

[trafficserver] branch master updated: Adds a coverity model file, and excludes a stat() check

This is an automated email from the ASF dual-hosted git repository.

zwoop pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git

The following commit(s) were added to refs/heads/master by this push:
       new  f29b920   Adds a coverity model file, and excludes a stat() check
f29b920 is described below

commit f29b920caa4d3da1c2132f262babe32aa0515b27
Author: Leif Hedstrom <zw...@apache.org>
AuthorDate: Wed May 17 16:33:32 2017 -0600

    Adds a coverity model file, and excludes a stat() check
    
    This also undoes a previous change, that hopefully the new model rule
    will take care of (instead of nesting the if/else).
---
 ci/coverity-model.cpp | 10 ++++++++++
 proxy/logstats.cc     | 25 +++++++++++++------------
 2 files changed, 23 insertions(+), 12 deletions(-)

diff --git a/ci/coverity-model.cpp b/ci/coverity-model.cpp
index c24cfde..02f2ed7 100644
--- a/ci/coverity-model.cpp
+++ b/ci/coverity-model.cpp
@@ -50,3 +50,13 @@ void _TSReleaseAssert(const char* txt, const char* f, int l)
 }
 
 } /* extern "C" */
+
+// Teach Coverity that the my_exit() in logstats.cc exits ...
+struct ExitStatus {
+};
+
+void
+my_exit(const ExitStatus &status)
+{
+  __coverity_panic__();
+}
diff --git a/proxy/logstats.cc b/proxy/logstats.cc
index d95dccf..15c946b 100644
--- a/proxy/logstats.cc
+++ b/proxy/logstats.cc
@@ -2578,6 +2578,7 @@ main(int /* argc ATS_UNUSED */, const char *argv[])
         exit_status.set(EXIT_WARNING, " can't read log directory");
       } else {
         while ((dp = readdir(dirp)) != NULL) {
+          // coverity[fs_check_call]
           if (stat(dp->d_name, &stat_buf) < 0) {
             exit_status.set(EXIT_WARNING, " can't stat ");
             exit_status.append(dp->d_name);
@@ -2643,23 +2644,23 @@ main(int /* argc ATS_UNUSED */, const char *argv[])
       exit_status.set(EXIT_CRITICAL, " can't open log file ");
       exit_status.append(cl.log_file);
       my_exit(exit_status);
-    } else {
-      if (cl.tail > 0) {
-        if (lseek(main_fd, 0, SEEK_END) < 0) {
-          exit_status.set(EXIT_CRITICAL, " can't lseek squid.blog");
-          my_exit(exit_status);
-        }
-        sleep(cl.tail);
-      }
+    }
 
-      if (process_file(main_fd, 0, max_age) != 0) {
-        close(main_fd);
-        exit_status.set(EXIT_CRITICAL, " can't parse log file ");
-        exit_status.append(cl.log_file);
+    if (cl.tail > 0) {
+      if (lseek(main_fd, 0, SEEK_END) < 0) {
+        exit_status.set(EXIT_CRITICAL, " can't lseek squid.blog");
         my_exit(exit_status);
       }
+      sleep(cl.tail);
+    }
+
+    if (process_file(main_fd, 0, max_age) != 0) {
       close(main_fd);
+      exit_status.set(EXIT_CRITICAL, " can't parse log file ");
+      exit_status.append(cl.log_file);
+      my_exit(exit_status);
     }
+    close(main_fd);
   }
 
   // All done.

-- 
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>'].