linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Zhao Lei <zhaolei@cn.fujitsu.com>
To: <linux-btrfs@vger.kernel.org>
Cc: Zhao Lei <zhaolei@cn.fujitsu.com>
Subject: [PATCH 6/6] btrfs-progs: Avoid use pointer in handle_options
Date: Thu, 29 Oct 2015 17:31:48 +0800	[thread overview]
Message-ID: <067592f9b350f23dbe4c255238bfebcc9e34964c.1446111097.git.zhaolei@cn.fujitsu.com> (raw)
In-Reply-To: <e9288021adac2924ce1fdb637f61b9b924eff954.1446111097.git.zhaolei@cn.fujitsu.com>

We use pointer of argc and argv in handle_options() because they
are necessary in very old code which are not exist now.

This patch move to use argc and argv directly in handle_options(),
alone with following update:
1: rename handle_options() to check_options()
   to fit its function.
2: cleanup for condition in handle_options() to make line short.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
---
 btrfs.c | 30 ++++++++++++++++--------------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/btrfs.c b/btrfs.c
index 9416a29..f881c18 100644
--- a/btrfs.c
+++ b/btrfs.c
@@ -172,20 +172,22 @@ static int cmd_version(int argc, char **argv)
 	return 0;
 }
 
-static void handle_options(int *argc, char ***argv)
+static void check_options(int argc, char **argv)
 {
-	if (*argc > 0) {
-		const char *arg = (*argv)[0];
-		if (arg[0] != '-' ||
-		    !strcmp(arg, "--help") ||
-		    !strcmp(arg, "--version"))
-			return;
-		fprintf(stderr, "Unknown option: %s\n", arg);
-		fprintf(stderr, "usage: %s\n",
-			btrfs_cmd_group.usagestr[0]);
-		exit(129);
-	}
-	return;
+	if (argc == 0)
+		return;
+
+	const char *arg = argv[0];
+
+	if (arg[0] != '-' ||
+	    !strcmp(arg, "--help") ||
+	    !strcmp(arg, "--version"))
+		return;
+
+	fprintf(stderr, "Unknown option: %s\n", arg);
+	fprintf(stderr, "usage: %s\n",
+		btrfs_cmd_group.usagestr[0]);
+	exit(129);
 }
 
 static const struct cmd_group btrfs_cmd_group = {
@@ -227,7 +229,7 @@ int main(int argc, char **argv)
 	} else {
 		argc--;
 		argv++;
-		handle_options(&argc, &argv);
+		check_options(argc, argv);
 		if (argc > 0) {
 			if (!prefixcmp(argv[0], "--"))
 				argv[0] += 2;
-- 
1.8.5.1


  parent reply	other threads:[~2015-10-29  9:33 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-29  9:31 [PATCH 1/6] btrfs-progs: fix floating point exception for btrfs-calc-size Zhao Lei
2015-10-29  9:31 ` [PATCH 2/6] btrfs-progs: Fix negative eb's ref_cnt in btrfs-calc-size Zhao Lei
2015-10-29  9:31 ` [PATCH 3/6] btrfs-progs: free fslabel for btrfs-convert Zhao Lei
2015-10-29 13:08   ` David Sterba
2015-10-29  9:31 ` [PATCH 4/6] btrfs-progs: Fix uninitialized key.type for btrfs_find_free_objectid Zhao Lei
2015-10-29  9:31 ` [PATCH 5/6] btrfs-progs: free comparer_set in cmd_qgroup_show Zhao Lei
2015-10-30 13:35   ` David Sterba
2015-11-02  1:16     ` Zhao Lei
2015-10-29  9:31 ` Zhao Lei [this message]
2015-10-29 13:15   ` [PATCH 6/6] btrfs-progs: Avoid use pointer in handle_options David Sterba
2015-10-29 13:26 ` [PATCH 1/6] btrfs-progs: fix floating point exception for btrfs-calc-size David Sterba

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=067592f9b350f23dbe4c255238bfebcc9e34964c.1446111097.git.zhaolei@cn.fujitsu.com \
    --to=zhaolei@cn.fujitsu.com \
    --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).