erofs-utils: lib: fix incorrect usage of `erofs_strerror`
authorTianyi Liu <i.pear@outlook.com>
Thu, 8 Feb 2024 13:59:09 +0000 (21:59 +0800)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Mon, 12 Feb 2024 09:27:45 +0000 (17:27 +0800)
`erofs_strerror` accepts a negative argument,
so `errno` should be inverted before passing to it.

Signed-off-by: Tianyi Liu <i.pear@outlook.com>
Link: https://lore.kernel.org/r/SY6P282MB3193657433D35C3A7799CA5F9D442@SY6P282MB3193.AUSP282.PROD.OUTLOOK.COM
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
lib/inode.c
lib/tar.c
lib/xattr.c

index c6424c0adc7fd36de707f2ac89a15acc74e23009..2a9b18cd2775a302e37e16f8eefc3c7317a9e8a7 100644 (file)
@@ -1146,7 +1146,7 @@ static int erofs_mkfs_build_tree(struct erofs_inode *dir, struct list_head *dirs
        _dir = opendir(dir->i_srcpath);
        if (!_dir) {
                erofs_err("failed to opendir at %s: %s",
-                         dir->i_srcpath, erofs_strerror(errno));
+                         dir->i_srcpath, erofs_strerror(-errno));
                return -errno;
        }
 
index 8204939276a40f5ceefad2ba9988def2db0b2048..ead74ba40b22e20f190dfecbb192fbf55bf478fc 100644 (file)
--- a/lib/tar.c
+++ b/lib/tar.c
@@ -106,7 +106,7 @@ int erofs_iostream_open(struct erofs_iostream *ios, int fd, int decoder)
 #ifdef HAVE_POSIX_FADVISE
                        if (posix_fadvise(fd, 0, 0, POSIX_FADV_SEQUENTIAL))
                                erofs_warn("failed to fadvise: %s, ignored.",
-                                          erofs_strerror(errno));
+                                          erofs_strerror(-errno));
 #endif
                }
                ios->bufsize = 16384;
index 77c8c3a4492bb385576292b869f4f357fabcef75..427933fa4ae3ac62de3c0c68595c11f590761675 100644 (file)
@@ -698,7 +698,7 @@ static int erofs_count_all_xattrs_from_path(const char *path)
        _dir = opendir(path);
        if (!_dir) {
                erofs_err("failed to opendir at %s: %s",
-                         path, erofs_strerror(errno));
+                         path, erofs_strerror(-errno));
                return -errno;
        }