Linux-EROFS Archive mirror
 help / color / mirror / Atom feed
From: Tianyi Liu <i.pear@outlook.com>
To: linux-erofs@lists.ozlabs.org
Cc: Tianyi Liu <i.pear@outlook.com>
Subject: [PATCH] erofs-utils: lib: fix incorrect usages of `erofs_strerror`
Date: Thu,  8 Feb 2024 21:59:09 +0800	[thread overview]
Message-ID: <SY6P282MB3193657433D35C3A7799CA5F9D442@SY6P282MB3193.AUSP282.PROD.OUTLOOK.COM> (raw)

`erofs_strerror` accepts a negative argument,
so `errno` should be negatived before passing to it.

Signed-off-by: Tianyi Liu <i.pear@outlook.com>
---
 lib/inode.c | 2 +-
 lib/tar.c   | 2 +-
 lib/xattr.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/inode.c b/lib/inode.c
index c6424c0..2a9b18c 100644
--- a/lib/inode.c
+++ b/lib/inode.c
@@ -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;
 	}
 
diff --git a/lib/tar.c b/lib/tar.c
index 8204939..ead74ba 100644
--- 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;
diff --git a/lib/xattr.c b/lib/xattr.c
index 77c8c3a..427933f 100644
--- a/lib/xattr.c
+++ b/lib/xattr.c
@@ -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;
 	}
 
-- 
2.43.0


             reply	other threads:[~2024-02-08 14:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-08 13:59 Tianyi Liu [this message]
2024-02-10  6:22 ` [PATCH] erofs-utils: lib: fix incorrect usages of `erofs_strerror` Gao Xiang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=SY6P282MB3193657433D35C3A7799CA5F9D442@SY6P282MB3193.AUSP282.PROD.OUTLOOK.COM \
    --to=i.pear@outlook.com \
    --cc=linux-erofs@lists.ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).