summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnand Jain <anand.jain@oracle.com>2015-04-13 20:37:01 +0800
committerDavid Sterba <dsterba@suse.cz>2015-04-14 15:19:04 +0200
commit32ca2fa502c0a00a7dc40adbdae2e7b7765e6d63 (patch)
tree19d65b118136d99133d438e5e537148913fded38
parent672076d4b73577898e3768fddd95af178a964c47 (diff)
btrfs-progs: improve troubleshooting avoid duplicate error strings
my troubleshooting experience says have unique error string per module. In the below eg, its one additional step to know error line, cat -n cmds-device.c | egrep "error removing the device" 185 "ERROR: error removing the device '%s' - %s\n", 190 "ERROR: error removing the device '%s' - %s\n", which is completely avoidable. Signed-off-by: Anand Jain <anand.jain@oracle.com> [merged the two messages into one] Signed-off-by: David Sterba <dsterba@suse.cz>
-rw-r--r--cmds-device.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/cmds-device.c b/cmds-device.c
index f9ac7f5f..9a7287a6 100644
--- a/cmds-device.c
+++ b/cmds-device.c
@@ -180,15 +180,16 @@ static int cmd_rm_dev(int argc, char **argv)
strncpy_null(arg.name, argv[i]);
res = ioctl(fdmnt, BTRFS_IOC_RM_DEV, &arg);
e = errno;
- if (res > 0) {
- fprintf(stderr,
- "ERROR: error removing the device '%s' - %s\n",
- argv[i], btrfs_err_str(res));
- ret++;
- } else if (res < 0) {
+ if (res) {
+ const char *msg;
+
+ if (ret > 0)
+ msg = btrfs_err_str(res);
+ else
+ msg = strerror(e);
fprintf(stderr,
"ERROR: error removing the device '%s' - %s\n",
- argv[i], strerror(e));
+ argv[i], msg);
ret++;
}
}