]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
libxfs: don't pass negative errnos to strerror()
authorEric Sandeen <sandeen@redhat.com>
Thu, 4 Feb 2016 21:34:58 +0000 (08:34 +1100)
committerDave Chinner <david@fromorbit.com>
Thu, 4 Feb 2016 21:34:58 +0000 (08:34 +1100)
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>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
libxfs/rdwr.c

index 7a049850971a3e76fb39d778696f4421bc56e01a..7b23394e397f1d5f2e9b7bca402452ab8a3756ec 100644 (file)
@@ -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);