From patchwork Sat Oct 10 14:30:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Jain X-Patchwork-Id: 7366681 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 06B4E9F1B9 for ; Sat, 10 Oct 2015 14:32:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3E0CF208E2 for ; Sat, 10 Oct 2015 14:32:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5186320873 for ; Sat, 10 Oct 2015 14:32:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751968AbbJJObf (ORCPT ); Sat, 10 Oct 2015 10:31:35 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:24823 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751867AbbJJOb1 (ORCPT ); Sat, 10 Oct 2015 10:31:27 -0400 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t9AEVObv030272 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sat, 10 Oct 2015 14:31:24 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0022.oracle.com (8.13.8/8.13.8) with ESMTP id t9AEVNej016159 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Sat, 10 Oct 2015 14:31:23 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by aserv0122.oracle.com (8.13.8/8.13.8) with ESMTP id t9AEVNs0019549; Sat, 10 Oct 2015 14:31:23 GMT Received: from localhost.localdomain (/42.60.253.93) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sat, 10 Oct 2015 07:31:23 -0700 From: Anand Jain 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 Message-Id: <1444487458-2988-3-git-send-email-anand.jain@oracle.com> X-Mailer: git-send-email 2.4.1 In-Reply-To: <1444487458-2988-1-git-send-email-anand.jain@oracle.com> References: <1444487458-2988-1-git-send-email-anand.jain@oracle.com> X-Source-IP: userv0022.oracle.com [156.151.31.74] Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This is needed by the patch which introduces new devid option for the btrfs device delete. Signed-off-by: Anand Jain --- 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;