aboutsummaryrefslogtreecommitdiffstats
path: root/cmds-device.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.com>2016-01-12 11:20:18 +0100
committerDavid Sterba <dsterba@suse.com>2016-01-12 15:02:55 +0100
commit633dc6f80f201afdf5b8524ae377187d58f0ef3b (patch)
treeca5b6375fb6910ac51eea8b89173c45390ce0355 /cmds-device.c
parent374d67fdef869d2e2dfb9907d21c85ee6c19e1d7 (diff)
downloadbtrfs-progs-633dc6f80f201afdf5b8524ae377187d58f0ef3b.tar.gz
btrfs-progs-633dc6f80f201afdf5b8524ae377187d58f0ef3b.tar.xz
btrfs-progs-633dc6f80f201afdf5b8524ae377187d58f0ef3b.zip
btrfs-progs: remove unnecessary errno temp variables
We can read errno directly if it's not clobbered by any intermediate calls. Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'cmds-device.c')
-rw-r--r--cmds-device.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/cmds-device.c b/cmds-device.c
index efe5b4c..f69d024 100644
--- a/cmds-device.c
+++ b/cmds-device.c
@@ -49,7 +49,7 @@ static const char * const cmd_device_add_usage[] = {
static int cmd_device_add(int argc, char **argv)
{
char *mntpnt;
- int i, fdmnt, ret=0, e;
+ int i, fdmnt, ret = 0;
DIR *dirstream = NULL;
int discard = 1;
int force = 0;
@@ -126,10 +126,9 @@ static int cmd_device_add(int argc, char **argv)
memset(&ioctl_args, 0, sizeof(ioctl_args));
strncpy_null(ioctl_args.name, path);
res = ioctl(fdmnt, BTRFS_IOC_ADD_DEV, &ioctl_args);
- e = errno;
if (res < 0) {
error("error adding device '%s': %s",
- path, strerror(e));
+ path, strerror(errno));
ret++;
}
free(path);
@@ -144,7 +143,7 @@ static int _cmd_device_remove(int argc, char **argv,
const char * const *usagestr)
{
char *mntpnt;
- int i, fdmnt, ret=0, e;
+ int i, fdmnt, ret = 0;
DIR *dirstream = NULL;
if (check_argc_min(argc, 3))
@@ -168,14 +167,13 @@ static int _cmd_device_remove(int argc, char **argv,
memset(&arg, 0, sizeof(arg));
strncpy_null(arg.name, argv[i]);
res = ioctl(fdmnt, BTRFS_IOC_RM_DEV, &arg);
- e = errno;
if (res) {
const char *msg;
if (res > 0)
msg = btrfs_err_str(res);
else
- msg = strerror(e);
+ msg = strerror(errno);
error("error removing device '%s': %s",
argv[i], msg);
ret++;