diff options
author | Rosen Penev <rosenp@gmail.com> | 2018-01-07 13:54:21 -0800 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2018-01-31 15:14:03 +0100 |
commit | e4df433b8a2d5ef944ab4764a5ad237bcdbd1fdc (patch) | |
tree | 19aa758dee389cea7c86c68ce1c8cc8e9a52836c /btrfs-list.c | |
parent | 24103f42ad7a65457a62ae5c0190ea0e428cb14b (diff) |
btrfs-progs: treewide: Replace strerror(errno) with %m.
As btrfs is specific to Linux, %m can be used instead of strerror(errno)
in format strings. This has some size reduction benefits for embedded
systems.
glibc, musl, and uclibc-ng all support %m as a modifier to printf.
A quick glance at the BIONIC libc source indicates that it has
support for %m as well. BSDs and Windows do not but I do believe
them to be beyond the scope of btrfs-progs.
Compiled sizes on Ubuntu 16.04:
Before:
3916512 btrfs
233688 libbtrfs.so.0.1
4899 bcp
2367672 btrfs-convert
2208488 btrfs-corrupt-block
13302 btrfs-debugfs
2152160 btrfs-debug-tree
2136024 btrfs-find-root
2287592 btrfs-image
2144600 btrfs-map-logical
2130760 btrfs-select-super
2152608 btrfstune
2131760 btrfs-zero-log
2277752 mkfs.btrfs
9166 show-blocks
After:
3908744 btrfs
233256 libbtrfs.so.0.1
4899 bcp
2366560 btrfs-convert
2207432 btrfs-corrupt-block
13302 btrfs-debugfs
2151104 btrfs-debug-tree
2134968 btrfs-find-root
2281864 btrfs-image
2143536 btrfs-map-logical
2129704 btrfs-select-super
2151552 btrfstune
2130696 btrfs-zero-log
2276272 mkfs.btrfs
9166 show-blocks
Total savings: 23928 (24 kilo)bytes
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'btrfs-list.c')
-rw-r--r-- | btrfs-list.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/btrfs-list.c b/btrfs-list.c index b6d76585..e01c5899 100644 --- a/btrfs-list.c +++ b/btrfs-list.c @@ -644,8 +644,8 @@ static int lookup_ino_path(int fd, struct root_info *ri) ri->ref_tree = 0; return -ENOENT; } - error("failed to lookup path for root %llu: %s", - (unsigned long long)ri->ref_tree, strerror(errno)); + error("failed to lookup path for root %llu: %m", + (unsigned long long)ri->ref_tree); return ret; } @@ -695,9 +695,8 @@ static u64 find_root_gen(int fd) /* this ioctl fills in ino_args->treeid */ ret = ioctl(fd, BTRFS_IOC_INO_LOOKUP, &ino_args); if (ret < 0) { - error("failed to lookup path for dirid %llu: %s", - (unsigned long long)BTRFS_FIRST_FREE_OBJECTID, - strerror(errno)); + error("failed to lookup path for dirid %llu: %m", + (unsigned long long)BTRFS_FIRST_FREE_OBJECTID); return 0; } @@ -721,7 +720,7 @@ static u64 find_root_gen(int fd) while (1) { ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args); if (ret < 0) { - error("can't perform the search: %s", strerror(errno)); + error("can't perform the search: %m"); return 0; } /* the ioctl returns the number of item it found in nr_items */ @@ -781,8 +780,8 @@ static char *__ino_resolve(int fd, u64 dirid) ret = ioctl(fd, BTRFS_IOC_INO_LOOKUP, &args); if (ret < 0) { - error("failed to lookup path for dirid %llu: %s", - (unsigned long long)dirid, strerror(errno)); + error("failed to lookup path for dirid %llu: %m", + (unsigned long long)dirid); return ERR_PTR(ret); } @@ -860,7 +859,7 @@ static char *ino_resolve(int fd, u64 ino, u64 *cache_dirid, char **cache_name) ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args); if (ret < 0) { - error("can't perform the search: %s", strerror(errno)); + error("can't perform the search: %m"); return NULL; } /* the ioctl returns the number of item it found in nr_items */ @@ -1496,7 +1495,7 @@ static int btrfs_list_subvols(int fd, struct root_lookup *root_lookup) ret = list_subvol_search(fd, root_lookup); if (ret) { - error("can't perform the search: %s", strerror(errno)); + error("can't perform the search: %m"); return ret; } @@ -1732,7 +1731,7 @@ int btrfs_list_find_updated_files(int fd, u64 root_id, u64 oldest_gen) while(1) { ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args); if (ret < 0) { - error("can't perform the search: %s", strerror(errno)); + error("can't perform the search: %m"); break; } /* the ioctl returns the number of item it found in nr_items */ @@ -1926,8 +1925,7 @@ int btrfs_list_get_path_rootid(int fd, u64 *treeid) ret = lookup_path_rootid(fd, treeid); if (ret < 0) - error("cannot resolve rootid for path: %s", - strerror(errno)); + error("cannot resolve rootid for path: %m"); return ret; } |