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

bcall 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 cac837ec3b Coverity 1022028: Unchecked return value from library 
(#10508)
cac837ec3b is described below

commit cac837ec3b26791c1fa631b9ffa8361a93246d96
Author: Bryan Call <bc...@apache.org>
AuthorDate: Mon Sep 25 06:55:59 2023 -0700

    Coverity 1022028: Unchecked return value from library (#10508)
    
    logcat wasn't checking the return value on posix_fadvise()
---
 src/traffic_logcat/logcat.cc | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/traffic_logcat/logcat.cc b/src/traffic_logcat/logcat.cc
index c1b337e638..6a07a95b7b 100644
--- a/src/traffic_logcat/logcat.cc
+++ b/src/traffic_logcat/logcat.cc
@@ -309,11 +309,15 @@ main(int /* argc ATS_UNUSED */, const char *argv[])
         // that we plan on reading the entire file so the kernel can do
         // some fancy optimizations.
         if (!follow_flag) {
-          posix_fadvise(in_fd, 0, 0, POSIX_FADV_WILLNEED);
+          if (posix_fadvise(in_fd, 0, 0, POSIX_FADV_WILLNEED) != 0) {
+            fprintf(stderr, "Error while trying to advise kernel about file 
access pattern: %s\n", strerror(errno));
+          }
         }
 
         // We're always reading the file sequentially so this will always help
-        posix_fadvise(in_fd, 0, 0, POSIX_FADV_SEQUENTIAL);
+        if (posix_fadvise(in_fd, 0, 0, POSIX_FADV_SEQUENTIAL) != 0) {
+          fprintf(stderr, "Error while trying to advise kernel about file 
access pattern: %s\n", strerror(errno));
+        }
 #endif
         if (auto_filenames) {
           // change .blog to .log
@@ -377,7 +381,9 @@ main(int /* argc ATS_UNUSED */, const char *argv[])
 #if HAVE_POSIX_FADVISE
       // Now that we're done reading a potentially large log file, we can tell 
the kernel that it's OK to evict
       // the associated log file pages from cache
-      posix_fadvise(in_fd, 0, 0, POSIX_FADV_DONTNEED);
+      if (posix_fadvise(in_fd, 0, 0, POSIX_FADV_DONTNEED) != 0) {
+        fprintf(stderr, "Error while trying to advise kernel about file access 
pattern: %s\n", strerror(errno));
+      }
 #endif
     }
   } else {

Reply via email to