]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
Fix posix_memalign and posix_fadvise calls.
authorTheodore Ts'o <tytso@mit.edu>
Fri, 7 Jun 2019 17:07:12 +0000 (13:07 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 7 Jun 2019 17:07:12 +0000 (13:07 -0400)
Almost all posix_ functions return a positive errno value (without
setting errno) rather than -1 and setting errno. Most calls in this
project were correct, but these two weren't.

Reported-by: Hughes <enh@google.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
misc/badblocks.c
misc/e4defrag.c

index 44252dc6866189ab1a842807552c19ab74a5764e..abf315cdd6010adbd9c5d45b09307a3ac2ac5ba3 100644 (file)
@@ -130,7 +130,7 @@ static void *allocate_buffer(size_t size)
        void    *ret = 0;
 
 #ifdef HAVE_POSIX_MEMALIGN
-       if (posix_memalign(&ret, sys_page_size, size) < 0)
+       if (posix_memalign(&ret, sys_page_size, size) != 0)
                ret = 0;
 #else
 #ifdef HAVE_MEMALIGN
index b0a825f3ef6a7b7c4e39afae5345d72aff0d0d31..c6c6f134cd4fe1dd4e5d53490c38140bfea13e57 100644 (file)
@@ -441,7 +441,8 @@ static int defrag_fadvise(int fd, struct move_extent defrag_data,
                        offset += pagesize;
                        continue;
                }
-               if (posix_fadvise(fd, offset, pagesize, fadvise_flag) < 0) {
+               if ((errno = posix_fadvise(fd, offset,
+                                          pagesize, fadvise_flag)) != 0) {
                        if ((mode_flag & DETAIL) && flag) {
                                perror("\tFailed to fadvise");
                                flag = 0;