]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-fs,lib-storage: Fix posix_fadvise usage
authorAki Tuomi <aki.tuomi@open-xchange.com>
Fri, 29 Dec 2023 14:05:27 +0000 (16:05 +0200)
committerFred Morcos <fred.morcos@open-xchange.com>
Thu, 12 Dec 2024 11:14:09 +0000 (12:14 +0100)
Return value is non-zero on error, not negative.

src/lib-fs/fs-posix.c
src/lib-storage/index/index-mail.c

index b60555ddbdf8404d598ebeeed99d21b3c324bc7b..b996539c4187d71a51913122a12279eaa0806d61 100644 (file)
@@ -424,7 +424,7 @@ static bool fs_posix_prefetch(struct fs_file *_file, uoff_t length ATTR_UNUSED)
 
 /* HAVE_POSIX_FADVISE alone isn't enough for CentOS 4.9 */
 #if defined(HAVE_POSIX_FADVISE) && defined(POSIX_FADV_WILLNEED)
-       if (posix_fadvise(file->fd, 0, length, POSIX_FADV_WILLNEED) < 0) {
+       if ((errno = posix_fadvise(file->fd, 0, (off_t)length, POSIX_FADV_WILLNEED)) != 0) {
                e_error(_file->event, "posix_fadvise(%s) failed: %m", file->full_path);
                return TRUE;
        }
index f660770d15e00aa6ad99d2e0c2e6a9a2119a9049..ddded22e381d4fc51e5a4eb932ef1b6419750d4a 100644 (file)
@@ -2211,8 +2211,8 @@ bool index_mail_prefetch(struct mail *_mail)
                if ((mail->data.access_part & (READ_BODY | PARSE_BODY)) != 0)
                        len = 0;
                else
-                       len = MAIL_READ_HDR_BLOCK_SIZE;
-               if (posix_fadvise(fd, 0, len, POSIX_FADV_WILLNEED) < 0) {
+                       len = (off_t)MAIL_READ_HDR_BLOCK_SIZE;
+               if ((errno = posix_fadvise(fd, 0, len, POSIX_FADV_WILLNEED)) != 0) {
                        e_error(mail_event(_mail),
                                "posix_fadvise(%s) failed: %m",
                                i_stream_get_name(mail->data.stream));