linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anand Jain <anand.jain@oracle.com>
To: linux-btrfs@vger.kernel.org
Cc: dsterba@suse.cz
Subject: [PATCH 2/3] btrfs-progs: Code optimize and cleanup device add
Date: Sat, 10 Oct 2015 22:30:57 +0800	[thread overview]
Message-ID: <1444487458-2988-3-git-send-email-anand.jain@oracle.com> (raw)
In-Reply-To: <1444487458-2988-1-git-send-email-anand.jain@oracle.com>

This is needed by the patch which introduces new devid option for the
btrfs device delete.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 cmds-device.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/cmds-device.c b/cmds-device.c
index 5f2b952..ee48c2e 100644
--- a/cmds-device.c
+++ b/cmds-device.c
@@ -51,8 +51,9 @@ static int cmd_device_add(int argc, char **argv)
 	char	*mntpnt;
 	int	i, fdmnt, ret=0, e;
 	DIR	*dirstream = NULL;
-	int discard = 1;
-	int force = 0;
+	int	discard = 1;
+	int	force = 0;
+	int	last_dev;
 
 	while (1) {
 		int c;
@@ -77,18 +78,17 @@ static int cmd_device_add(int argc, char **argv)
 		}
 	}
 
-	argc = argc - optind;
-
-	if (check_argc_min(argc, 2))
+	if (check_argc_min(argc - optind, 2))
 		usage(cmd_device_add_usage);
 
-	mntpnt = argv[optind + argc - 1];
+	last_dev = argc - 1;
+	mntpnt = argv[last_dev];
 
 	fdmnt = btrfs_open_dir(mntpnt, &dirstream, 1);
 	if (fdmnt < 0)
 		return 1;
 
-	for (i = optind; i < optind + argc - 1; i++){
+	for (i = optind; i < last_dev; i++){
 		struct btrfs_ioctl_vol_args ioctl_args;
 		int	devfd, res;
 		u64 dev_block_count = 0;
-- 
2.4.1


  parent reply	other threads:[~2015-10-10 14:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-10 14:30 [PATCH RESEND 0/3] btrfs-progs: Introduce device delete by devid Anand Jain
2015-10-10 14:30 ` [PATCH RESEND V2 1/3] btrfs-progs: Create is_numerical() helper function Anand Jain
2015-10-10 14:30 ` Anand Jain [this message]
2015-10-10 14:30 ` [PATCH V4 3/3] btrfs-progs: Introduce device delete by devid Anand Jain
2015-10-13 12:48 ` [PATCH RESEND 0/3] " David Sterba
2015-10-14 10:56   ` Anand Jain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1444487458-2988-3-git-send-email-anand.jain@oracle.com \
    --to=anand.jain@oracle.com \
    --cc=dsterba@suse.cz \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).