diff options
author | David Sterba <dsterba@suse.com> | 2018-10-25 14:10:54 +0200 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2018-10-31 18:24:14 +0100 |
commit | e578b59bf612178d7727c303102049e62676c308 (patch) | |
tree | a6d6edd7fb6f34f4ce753aa9a1d787198a0e1ddf /utils.c | |
parent | d59e19ca0786be2b415ca342b0fab5f222ecb702 (diff) |
btrfs-progs: convert strerror to implicit %m
Similar to the changes where strerror(errno) was converted, continue
with the remaining cases where the argument was stored in another
variable.
The savings in object size are about 4500 bytes:
$ size btrfs.old btrfs.new
text data bss dec hex filename
805055 24248 19748 849051 cf49b btrfs.old
804527 24248 19748 848523 cf28b btrfs.new
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'utils.c')
-rw-r--r-- | utils.c | 18 |
1 files changed, 11 insertions, 7 deletions
@@ -357,7 +357,8 @@ int btrfs_prepare_device(int fd, const char *file, u64 *block_count_ret, ZERO_DEV_BYTES, block_count); if (ret < 0) { - error("failed to zero device '%s': %s", file, strerror(-ret)); + errno = -ret; + error("failed to zero device '%s': %m", file); return 1; } @@ -530,7 +531,8 @@ int get_btrfs_mount(const char *dev, char *mp, size_t mp_size) error("not a block device: %s", dev); ret = -EINVAL; } else { - error("cannot check %s: %s", dev, strerror(-ret)); + errno = -ret; + error("cannot check %s: %m", dev); } goto out; } @@ -1492,8 +1494,10 @@ path: if (fd < 0) goto err; ret = lookup_path_rootid(fd, &id); - if (ret) - error("failed to lookup root id: %s", strerror(-ret)); + if (ret) { + errno = -ret; + error("failed to lookup root id: %m"); + } close(fd); if (ret < 0) goto err; @@ -1782,8 +1786,7 @@ int get_fsid(const char *path, u8 *fsid, int silent) if (fd < 0) { ret = -errno; if (!silent) - error("failed to open %s: %s", path, - strerror(-ret)); + error("failed to open %s: %m", path); goto out; } @@ -2000,7 +2003,8 @@ int btrfs_scan_devices(void) &num_devices, BTRFS_SUPER_INFO_OFFSET, SBREAD_DEFAULT); if (ret) { - error("cannot scan %s: %s", path, strerror(-ret)); + errno = -ret; + error("cannot scan %s: %m", path); close (fd); continue; } |