From 633dc6f80f201afdf5b8524ae377187d58f0ef3b Mon Sep 17 00:00:00 2001 From: David Sterba Date: Tue, 12 Jan 2016 11:20:18 +0100 Subject: btrfs-progs: remove unnecessary errno temp variables We can read errno directly if it's not clobbered by any intermediate calls. Signed-off-by: David Sterba --- btrfs-list.c | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) (limited to 'btrfs-list.c') diff --git a/btrfs-list.c b/btrfs-list.c index 7529e11..f084b32 100644 --- a/btrfs-list.c +++ b/btrfs-list.c @@ -630,7 +630,7 @@ static int resolve_root(struct root_lookup *rl, struct root_info *ri, static int lookup_ino_path(int fd, struct root_info *ri) { struct btrfs_ioctl_ino_lookup_args args; - int ret, e; + int ret; if (ri->path) return 0; @@ -643,15 +643,14 @@ static int lookup_ino_path(int fd, struct root_info *ri) args.objectid = ri->dir_id; ret = ioctl(fd, BTRFS_IOC_INO_LOOKUP, &args); - e = errno; if (ret) { - if (e == ENOENT) { + if (errno == ENOENT) { ri->ref_tree = 0; return -ENOENT; } fprintf(stderr, "ERROR: Failed to lookup path for root %llu - %s\n", (unsigned long long)ri->ref_tree, - strerror(e)); + strerror(errno)); return ret; } @@ -694,18 +693,16 @@ static u64 find_root_gen(int fd) unsigned long off = 0; u64 max_found = 0; int i; - int e; memset(&ino_args, 0, sizeof(ino_args)); ino_args.objectid = BTRFS_FIRST_FREE_OBJECTID; /* this ioctl fills in ino_args->treeid */ ret = ioctl(fd, BTRFS_IOC_INO_LOOKUP, &ino_args); - e = errno; if (ret) { fprintf(stderr, "ERROR: Failed to lookup path for dirid %llu - %s\n", (unsigned long long)BTRFS_FIRST_FREE_OBJECTID, - strerror(e)); + strerror(errno)); return 0; } @@ -728,10 +725,9 @@ static u64 find_root_gen(int fd) while (1) { ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args); - e = errno; if (ret < 0) { fprintf(stderr, "ERROR: can't perform the search - %s\n", - strerror(e)); + strerror(errno)); return 0; } /* the ioctl returns the number of item it found in nr_items */ @@ -785,16 +781,14 @@ static char *__ino_resolve(int fd, u64 dirid) struct btrfs_ioctl_ino_lookup_args args; int ret; char *full; - int e; memset(&args, 0, sizeof(args)); args.objectid = dirid; ret = ioctl(fd, BTRFS_IOC_INO_LOOKUP, &args); - e = errno; if (ret) { fprintf(stderr, "ERROR: Failed to lookup path for dirid %llu - %s\n", - (unsigned long long)dirid, strerror(e) ); + (unsigned long long)dirid, strerror(errno)); return ERR_PTR(ret); } @@ -852,7 +846,6 @@ static char *ino_resolve(int fd, u64 ino, u64 *cache_dirid, char **cache_name) struct btrfs_ioctl_search_header *sh; unsigned long off = 0; int namelen; - int e; memset(&args, 0, sizeof(args)); @@ -871,10 +864,9 @@ static char *ino_resolve(int fd, u64 ino, u64 *cache_dirid, char **cache_name) sk->nr_items = 1; ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args); - e = errno; if (ret < 0) { fprintf(stderr, "ERROR: can't perform the search - %s\n", - strerror(e)); + strerror(errno)); return NULL; } /* the ioctl returns the number of item it found in nr_items */ @@ -1686,7 +1678,6 @@ int btrfs_list_find_updated_files(int fd, u64 root_id, u64 oldest_gen) u64 found_gen; u64 max_found = 0; int i; - int e; u64 cache_dirid = 0; u64 cache_ino = 0; char *cache_dir_name = NULL; @@ -1713,10 +1704,9 @@ int btrfs_list_find_updated_files(int fd, u64 root_id, u64 oldest_gen) max_found = find_root_gen(fd); while(1) { ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args); - e = errno; if (ret < 0) { fprintf(stderr, "ERROR: can't perform the search - %s\n", - strerror(e)); + strerror(errno)); break; } /* the ioctl returns the number of item it found in nr_items */ -- cgit v1.2.1