From e578b59bf612178d7727c303102049e62676c308 Mon Sep 17 00:00:00 2001 From: David Sterba Date: Thu, 25 Oct 2018 14:10:54 +0200 Subject: 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 --- image/main.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) (limited to 'image') 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); -- cgit v1.2.3