From 7cf60f4660d4705094eb111e4c52114f8dc348dc Mon Sep 17 00:00:00 2001 From: Zhao Lei Date: Thu, 6 Aug 2015 11:05:54 +0800 Subject: [PATCH] btrfs-progs: use switch instead of a series of ifs for output error message Signed-off-by: Zhao Lei Signed-off-by: David Sterba --- cmds-scrub.c | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/cmds-scrub.c b/cmds-scrub.c index 3ebda9dc..1c3fc034 100644 --- a/cmds-scrub.c +++ b/cmds-scrub.c @@ -1469,21 +1469,26 @@ static int scrub_start(int argc, char **argv, int resume) ++err; continue; } - if (sp[i].ret && sp[i].ioctl_errno == ENODEV) { - if (do_print) - fprintf(stderr, "WARNING: device %lld not " - "present\n", devid); - continue; - } - if (sp[i].ret && sp[i].ioctl_errno == ECANCELED) { - ++err; - } else if (sp[i].ret) { - if (do_print) - fprintf(stderr, "ERROR: scrubbing %s failed " - "for device id %lld (%s)\n", path, - devid, strerror(sp[i].ioctl_errno)); - ++err; - continue; + if (sp[i].ret) { + switch (sp[i].ioctl_errno) { + case ENODEV: + if (do_print) + fprintf(stderr, + "WARNING: device %lld not present\n", + devid); + continue; + case ECANCELED: + ++err; + break; + default: + if (do_print) + fprintf(stderr, + "ERROR: scrubbing %s failed for device id %lld (%s)\n", + path, devid, + strerror(sp[i].ioctl_errno)); + ++err; + continue; + } } if (sp[i].scrub_args.progress.uncorrectable_errors > 0) e_uncorrectable++;