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 /image | |
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 'image')
-rw-r--r-- | image/main.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/image/main.c b/image/main.c index 5b0050a0..c680ab19 100644 --- a/image/main.c +++ b/image/main.c @@ -499,7 +499,8 @@ static int write_buffers(struct metadump_struct *md, u64 *next) } if (err) { - error("one of the threads failed: %s", strerror(-err)); + errno = -err; + error("one of the threads failed: %m"); goto out; } @@ -690,10 +691,12 @@ static int flush_pending(struct metadump_struct *md, int done) } if (md->num_items >= ITEMS_PER_CLUSTER || done) { ret = write_buffers(md, &start); - if (ret) - error("unable to write buffers: %s", strerror(-ret)); - else + if (ret) { + errno = -ret; + error("unable to write buffers: %m"); + } else { meta_cluster_init(md, start); + } } pthread_mutex_unlock(&md->mutex); return ret; @@ -2377,10 +2380,12 @@ static int update_disk_super_on_device(struct btrfs_fs_info *info, ret = pwrite64(fp, buf, BTRFS_SUPER_INFO_SIZE, BTRFS_SUPER_INFO_OFFSET); if (ret != BTRFS_SUPER_INFO_SIZE) { - if (ret < 0) - error("cannot write superblock: %s", strerror(ret)); - else + if (ret < 0) { + errno = ret; + error("cannot write superblock: %m"); + } else { error("cannot write superblock"); + } ret = -EIO; goto out; } @@ -2535,8 +2540,8 @@ int main(int argc, char *argv[]) if (create) { ret = check_mounted(source); if (ret < 0) { - warning("unable to check mount status of: %s", - strerror(-ret)); + errno = -ret; + warning("unable to check mount status of: %m"); } else if (ret) { warning("%s already mounted, results may be inaccurate", source); |