From: Theodore Ts'o Date: Fri, 7 Jun 2019 17:07:12 +0000 (-0400) Subject: Fix posix_memalign and posix_fadvise calls. X-Git-Tag: v1.45.3~27 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c2eedf431e13c8bbdfc5bb81e8fec912fdf643cb;p=thirdparty%2Fe2fsprogs.git Fix posix_memalign and posix_fadvise calls. 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 Signed-off-by: Theodore Ts'o --- diff --git a/misc/badblocks.c b/misc/badblocks.c index 44252dc68..abf315cdd 100644 --- a/misc/badblocks.c +++ b/misc/badblocks.c @@ -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 diff --git a/misc/e4defrag.c b/misc/e4defrag.c index b0a825f3e..c6c6f134c 100644 --- a/misc/e4defrag.c +++ b/misc/e4defrag.c @@ -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;