btrfs-progs: qgroups show: clean up errno passing
authorDavid Sterba <dsterba@suse.com>
Fri, 20 Jan 2017 16:41:55 +0000 (17:41 +0100)
committerDavid Sterba <dsterba@suse.com>
Wed, 25 Jan 2017 08:47:56 +0000 (09:47 +0100)
We should use return value for errors, not errno.

Signed-off-by: David Sterba <dsterba@suse.com>
cmds-qgroup.c
qgroup.c

index bc15077..59a5926 100644 (file)
@@ -296,7 +296,6 @@ static int cmd_qgroup_show(int argc, char **argv)
        char *path;
        int ret = 0;
        int fd;
-       int e;
        DIR *dirstream = NULL;
        u64 qgroupid;
        int filter_flag = 0;
@@ -383,10 +382,9 @@ static int cmd_qgroup_show(int argc, char **argv)
                                        qgroupid);
        }
        ret = btrfs_show_qgroups(fd, filter_set, comparer_set);
-       e = errno;
        close_file_or_dir(fd, dirstream);
        if (ret < 0)
-               error("can't list qgroups: %s", strerror(e));
+               error("can't list qgroups: %s", strerror(-ret));
 
 out:
        return !!ret;
index 071d15e..21526ce 100644 (file)
--- a/qgroup.c
+++ b/qgroup.c
@@ -1067,7 +1067,7 @@ static int __qgroups_search(int fd, struct qgroup_lookup *qgroup_lookup)
                if (ret < 0) {
                        error("cannot perform the search: %s",
                                        strerror(errno));
-                       return ret;
+                       return -errno;
                }
                /* the ioctl returns the number of item it found in nr_items */
                if (sk->nr_items == 0)