From: Eric Sandeen <sandeen@redhat.com>
To: xfs@oss.sgi.com
Subject: [PATCH] libxfs: don't pass negative errnos to strerror()
Date: Thu, 14 Jan 2016 10:35:53 -0600 [thread overview]
Message-ID: <5697CE69.3050905@redhat.com> (raw)
The error negation work in 12b5319 tripped up a little bit
when we're reporting errors via strerror(). By negating
the error before passing it to strerror, we get i.e.
mkfs.xfs: pwrite64 failed: Unknown error -22
Keep the error positive, but return -error, just as we
do in the else clauses in these functions.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
diff --git a/libxfs/rdwr.c b/libxfs/rdwr.c
index 7a04985..7b23394 100644
--- a/libxfs/rdwr.c
+++ b/libxfs/rdwr.c
@@ -913,12 +913,12 @@ __read_buf(int fd, void *buf, int len, off64_t offset, int flags)
sts = pread64(fd, buf, len, offset);
if (sts < 0) {
- int error = -errno;
+ int error = errno;
fprintf(stderr, _("%s: read failed: %s\n"),
progname, strerror(error));
if (flags & LIBXFS_EXIT_ON_FAILURE)
exit(1);
- return error;
+ return -error;
} else if (sts != len) {
fprintf(stderr, _("%s: error - read only %d of %d bytes\n"),
progname, sts, len);
@@ -1081,12 +1081,12 @@ __write_buf(int fd, void *buf, int len, off64_t offset, int flags)
sts = pwrite64(fd, buf, len, offset);
if (sts < 0) {
- int error = -errno;
+ int error = errno;
fprintf(stderr, _("%s: pwrite64 failed: %s\n"),
progname, strerror(error));
if (flags & LIBXFS_B_EXIT)
exit(1);
- return error;
+ return -error;
} else if (sts != len) {
fprintf(stderr, _("%s: error - pwrite64 only %d of %d bytes\n"),
progname, sts, len);
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next reply other threads:[~2016-01-14 16:35 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-14 16:35 Eric Sandeen [this message]
2016-01-14 16:47 ` [PATCH] libxfs: don't pass negative errnos to strerror() Carlos Maiolino
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=5697CE69.3050905@redhat.com \
--to=sandeen@redhat.com \
--cc=xfs@oss.sgi.com \
/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