From: jeffm@suse.com
To: linux-btrfs@vger.kernel.org
Cc: Jeff Mahoney <jeffm@suse.com>
Subject: [PATCH 09/18] btrfs-progs: help: convert ints used as bools to bool
Date: Wed, 16 May 2018 17:38:42 -0400 [thread overview]
Message-ID: <20180516213851.10196-10-jeffm@suse.com> (raw)
In-Reply-To: <20180516213851.10196-1-jeffm@suse.com>
From: Jeff Mahoney <jeffm@suse.com>
We use an int for 'full', 'all', and 'err' when we really mean a boolean.
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
---
btrfs.c | 14 +++++++-------
help.c | 25 +++++++++++++------------
help.h | 4 ++--
3 files changed, 22 insertions(+), 21 deletions(-)
diff --git a/btrfs.c b/btrfs.c
index 2d39f2ce..fec1a135 100644
--- a/btrfs.c
+++ b/btrfs.c
@@ -109,7 +109,7 @@ static void handle_help_options_next_level(const struct cmd_struct *cmd,
argv++;
help_command_group(cmd->next, argc, argv);
} else {
- usage_command(cmd, 1, 0);
+ usage_command(cmd, true, false);
}
exit(0);
@@ -125,7 +125,7 @@ int handle_command_group(const struct cmd_group *grp, int argc,
argc--;
argv++;
if (argc < 1) {
- usage_command_group(grp, 0, 0);
+ usage_command_group(grp, false, false);
exit(1);
}
@@ -212,20 +212,20 @@ static int handle_global_options(int argc, char **argv)
void handle_special_globals(int shift, int argc, char **argv)
{
- int has_help = 0;
- int has_full = 0;
+ bool has_help = false;
+ bool has_full = false;
int i;
for (i = 0; i < shift; i++) {
if (strcmp(argv[i], "--help") == 0)
- has_help = 1;
+ has_help = true;
else if (strcmp(argv[i], "--full") == 0)
- has_full = 1;
+ has_full = true;
}
if (has_help) {
if (has_full)
- usage_command_group(&btrfs_cmd_group, 1, 0);
+ usage_command_group(&btrfs_cmd_group, true, false);
else
cmd_help(argc, argv);
exit(0);
diff --git a/help.c b/help.c
index f1dd3946..99fd325b 100644
--- a/help.c
+++ b/help.c
@@ -196,8 +196,8 @@ static int do_usage_one_command(const char * const *usagestr,
}
static int usage_command_internal(const char * const *usagestr,
- const char *token, int full, int lst,
- int alias, FILE *outf)
+ const char *token, bool full, bool lst,
+ bool alias, FILE *outf)
{
unsigned int flags = 0;
int ret;
@@ -223,17 +223,17 @@ static int usage_command_internal(const char * const *usagestr,
}
static void usage_command_usagestr(const char * const *usagestr,
- const char *token, int full, int err)
+ const char *token, bool full, bool err)
{
FILE *outf = err ? stderr : stdout;
int ret;
- ret = usage_command_internal(usagestr, token, full, 0, 0, outf);
+ ret = usage_command_internal(usagestr, token, full, false, false, outf);
if (!ret)
fputc('\n', outf);
}
-void usage_command(const struct cmd_struct *cmd, int full, int err)
+void usage_command(const struct cmd_struct *cmd, bool full, bool err)
{
usage_command_usagestr(cmd->usagestr, cmd->token, full, err);
}
@@ -241,11 +241,11 @@ void usage_command(const struct cmd_struct *cmd, int full, int err)
__attribute__((noreturn))
void usage(const char * const *usagestr)
{
- usage_command_usagestr(usagestr, NULL, 1, 1);
+ usage_command_usagestr(usagestr, NULL, true, true);
exit(1);
}
-static void usage_command_group_internal(const struct cmd_group *grp, int full,
+static void usage_command_group_internal(const struct cmd_group *grp, bool full,
FILE *outf)
{
const struct cmd_struct *cmd = grp->commands;
@@ -265,7 +265,8 @@ static void usage_command_group_internal(const struct cmd_group *grp, int full,
}
usage_command_internal(cmd->usagestr, cmd->token, full,
- 1, cmd->flags & CMD_ALIAS, outf);
+ true, cmd->flags & CMD_ALIAS,
+ outf);
if (cmd->flags & CMD_ALIAS)
putchar('\n');
continue;
@@ -327,7 +328,7 @@ void usage_command_group_short(const struct cmd_group *grp)
fprintf(stderr, "All command groups have their manual page named 'btrfs-<group>'.\n");
}
-void usage_command_group(const struct cmd_group *grp, int full, int err)
+void usage_command_group(const struct cmd_group *grp, bool full, bool err)
{
const char * const *usagestr = grp->usagestr;
FILE *outf = err ? stderr : stdout;
@@ -350,7 +351,7 @@ __attribute__((noreturn))
void help_unknown_token(const char *arg, const struct cmd_group *grp)
{
fprintf(stderr, "%s: unknown token '%s'\n", get_argv0_buf(), arg);
- usage_command_group(grp, 0, 1);
+ usage_command_group(grp, false, true);
exit(1);
}
@@ -372,13 +373,13 @@ void help_ambiguous_token(const char *arg, const struct cmd_group *grp)
void help_command_group(const struct cmd_group *grp, int argc, char **argv)
{
- int full = 0;
+ bool full = false;
if (argc > 1) {
if (!strcmp(argv[1], "--full"))
full = 1;
}
- usage_command_group(grp, full, 0);
+ usage_command_group(grp, full, false);
}
diff --git a/help.h b/help.h
index a1405942..322b910a 100644
--- a/help.h
+++ b/help.h
@@ -57,8 +57,8 @@ struct cmd_group;
__attribute__((noreturn))
void usage(const char * const *usagestr);
-void usage_command(const struct cmd_struct *cmd, int full, int err);
-void usage_command_group(const struct cmd_group *grp, int all, int err);
+void usage_command(const struct cmd_struct *cmd, bool full, bool err);
+void usage_command_group(const struct cmd_group *grp, bool all, bool err);
void usage_command_group_short(const struct cmd_group *grp);
__attribute__((noreturn))
--
2.15.1
next prev parent reply other threads:[~2018-05-16 21:39 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-16 21:38 [PATCH v3 00/18] btrfs-progs: qgroups-usability jeffm
2018-05-16 21:38 ` [PATCH 01/18] btrfs-progs: quota: Add -W option to rescan to wait without starting rescan jeffm
2018-05-16 21:38 ` [PATCH 02/18] btrfs-progs: qgroups: fix misleading index check jeffm
2018-05-16 21:38 ` [PATCH 03/18] btrfs-progs: constify pathnames passed as arguments jeffm
2018-05-16 21:38 ` [PATCH 04/18] btrfs-progs: btrfs-list: add rb_entry helpers for root_info jeffm
2018-05-16 21:38 ` [PATCH 05/18] btrfs-progs: qgroups: add pathname to show output jeffm
2018-05-18 4:55 ` Misono Tomohiro
2018-05-16 21:38 ` [PATCH 06/18] btrfs-progs: qgroups: introduce and use info and limit structures jeffm
2018-05-16 21:38 ` [PATCH 07/18] btrfs-progs: qgroups: introduce btrfs_qgroup_query jeffm
2018-05-16 21:38 ` [PATCH 08/18] btrfs-progs: subvolume: add quota info to btrfs sub show jeffm
2018-05-16 21:38 ` jeffm [this message]
2018-05-16 21:38 ` [PATCH 10/18] btrfs-progs: reorder placement of help declarations for send/receive jeffm
2018-05-16 21:38 ` [PATCH 11/18] btrfs-progs: filesystem balance: split out special handling jeffm
2018-05-16 21:38 ` [PATCH 12/18] btrfs-progs: use cmd_struct as command entry point jeffm
2018-05-16 21:38 ` [PATCH 13/18] btrfs-progs: pass cmd_struct to command callback function jeffm
2018-05-16 21:38 ` [PATCH 14/18] btrfs-progs: pass cmd_struct to clean_args_no_options{,_relaxed} jeffm
2018-05-16 21:38 ` [PATCH 15/18] btrfs-progs: pass cmd_struct to usage() jeffm
2018-05-16 21:38 ` [PATCH 16/18] btrfs-progs: add support for output formats jeffm
2018-05-16 21:38 ` [PATCH 17/18] btrfs-progs: handle command groups directly for common case jeffm
2018-05-16 21:38 ` [PATCH 18/18] btrfs-progs: qgroups: don't print dead qgroups jeffm
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=20180516213851.10196-10-jeffm@suse.com \
--to=jeffm@suse.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).