]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
fallocate: make posix_fadvise() use more readable for analyzers
authorKarel Zak <kzak@redhat.com>
Thu, 23 May 2019 13:17:16 +0000 (15:17 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 23 May 2019 13:17:16 +0000 (15:17 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/fallocate.c

index 04a3eaff53b77d8575725f9990396633d0416956..15dcbb0a623212894072e3595012a8ce4938333d 100644 (file)
@@ -219,8 +219,11 @@ static void dig_holes(int fd, off_t file_off, off_t len)
                if (file_end && end > file_end)
                        end = file_end;
 
+               if (off < 0 || end < 0)
+                       break;
+
 #if defined(POSIX_FADV_SEQUENTIAL) && defined(HAVE_POSIX_FADVISE)
-               posix_fadvise(fd, off, end, POSIX_FADV_SEQUENTIAL);
+               (void) posix_fadvise(fd, off, end, POSIX_FADV_SEQUENTIAL);
 #endif
                /*
                 * Dig holes in the area
@@ -251,7 +254,7 @@ static void dig_holes(int fd, off_t file_off, off_t len)
                                size_t clen = off - cache_start;
 
                                clen = (clen / cachesz) * cachesz;
-                               posix_fadvise(fd, cache_start, clen, POSIX_FADV_DONTNEED);
+                               (void) posix_fadvise(fd, cache_start, clen, POSIX_FADV_DONTNEED);
                                cache_start = cache_start + clen;
                        }
 #endif