From: Ian Jackson <ian.jackson@eu.citrix.com>
To: xen-devel@lists.xensource.com
Cc: Ian Jackson <Ian.Jackson@eu.citrix.com>,
Wei Liu <wei.liu2@citrix.com>,
Ian Campbell <ian.campbell@citrix.com>
Subject: [PATCH 3/5] xl: Command line: Support -h everywhere
Date: Fri, 17 Jul 2015 18:00:49 +0100 [thread overview]
Message-ID: <1437152451-22507-3-git-send-email-ian.jackson@eu.citrix.com> (raw)
In-Reply-To: <1437152451-22507-1-git-send-email-ian.jackson@eu.citrix.com>
xl subcommands ought all to take -h. def_getopt and hence
SWITCH_FOREACH_OPT already handles 'h' by calling helpstr. None of
the call sites see the 'h'.
In this patch:
* Change SWITCH_FOREACH_OPT to always add a "h" to the short opts
string, using string concatenation.
* Remove the now-redundant h's from some existing option strings.
Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
tools/libxl/xl_cmdimpl.c | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
index 770b71c..803c627 100644
--- a/tools/libxl/xl_cmdimpl.c
+++ b/tools/libxl/xl_cmdimpl.c
@@ -3073,14 +3073,15 @@ static int def_getopt(int argc, char * const argv[],
* Wraps def_getopt into a convenient loop+switch to process all
* arguments. This macro is intended to be called from main_XXX().
*
- * SWITCH_FOREACH_OPT(int *opt, const char *opts,
+ * SWITCH_FOREACH_OPT(int *opt, "OPTS",
* const struct option *longopts,
* const char *commandname,
* int num_opts_req) { ...
*
* opt: pointer to an int variable, holds the current option
* during processing.
- * opts: short options, as per getopt_long(3)'s optstring argument.
+ * OPTS: short options, as per getopt_long(3)'s optstring argument.
+ * do not include "h"; will be provided automatically
* longopts: long options, as per getopt_long(3)'s longopts argument.
* May be null.
* commandname: name of this command, for usage string.
@@ -3124,7 +3125,7 @@ static int def_getopt(int argc, char * const argv[],
*/
#define SWITCH_FOREACH_OPT(opt, opts, longopts, \
commandname, num_required_opts) \
- while (((opt) = def_getopt(argc, argv, (opts), (longopts), \
+ while (((opt) = def_getopt(argc, argv, "h" opts, (longopts), \
(commandname), (num_required_opts))) != -1) \
switch (opt)
@@ -3310,7 +3311,7 @@ int main_vncviewer(int argc, char **argv)
uint32_t domid;
int opt, autopass = 0;
- SWITCH_FOREACH_OPT(opt, "ah", opts, "vncviewer", 1) {
+ SWITCH_FOREACH_OPT(opt, "a", opts, "vncviewer", 1) {
case 'a':
autopass = 1;
break;
@@ -4442,7 +4443,7 @@ int main_restore(int argc, char **argv)
{0, 0, 0, 0}
};
- SWITCH_FOREACH_OPT(opt, "FhcpdeVA", opts, "restore", 1) {
+ SWITCH_FOREACH_OPT(opt, "FcpdeVA", opts, "restore", 1) {
case 'c':
console_autoconnect = 1;
break;
@@ -4893,7 +4894,7 @@ int main_create(int argc, char **argv)
argc--; argv++;
}
- SWITCH_FOREACH_OPT(opt, "Fhnqf:pcdeVA", opts, "create", 0) {
+ SWITCH_FOREACH_OPT(opt, "Fnqf:pcdeVA", opts, "create", 0) {
case 'f':
filename = optarg;
break;
@@ -4997,7 +4998,7 @@ int main_config_update(int argc, char **argv)
argc--; argv++;
}
- SWITCH_FOREACH_OPT(opt, "dhqf:", opts, "config_update", 0) {
+ SWITCH_FOREACH_OPT(opt, "dqf:", opts, "config_update", 0) {
case 'd':
debug = 1;
break;
@@ -5588,7 +5589,7 @@ int main_info(int argc, char **argv)
};
int numa = 0;
- SWITCH_FOREACH_OPT(opt, "hn", opts, "info", 0) {
+ SWITCH_FOREACH_OPT(opt, "n", opts, "info", 0) {
case 'n':
numa = 1;
break;
@@ -5926,7 +5927,7 @@ int main_sched_credit(int argc, char **argv)
{0, 0, 0, 0}
};
- SWITCH_FOREACH_OPT(opt, "d:w:c:p:t:r:hs", opts, "sched-credit", 0) {
+ SWITCH_FOREACH_OPT(opt, "d:w:c:p:t:r:s", opts, "sched-credit", 0) {
case 'd':
dom = optarg;
break;
@@ -6042,7 +6043,7 @@ int main_sched_credit2(int argc, char **argv)
{0, 0, 0, 0}
};
- SWITCH_FOREACH_OPT(opt, "d:w:p:h", opts, "sched-credit2", 0) {
+ SWITCH_FOREACH_OPT(opt, "d:w:p:", opts, "sched-credit2", 0) {
case 'd':
dom = optarg;
break;
@@ -6115,7 +6116,7 @@ int main_sched_rtds(int argc, char **argv)
{0, 0, 0, 0}
};
- SWITCH_FOREACH_OPT(opt, "d:p:b:c:h", opts, "sched-rtds", 0) {
+ SWITCH_FOREACH_OPT(opt, "d:p:b:c:", opts, "sched-rtds", 0) {
case 'd':
dom = optarg;
break;
@@ -7200,7 +7201,7 @@ int main_cpupoolcreate(int argc, char **argv)
libxl_cputopology *topology;
int rc = 1;
- SWITCH_FOREACH_OPT(opt, "hnf:", opts, "cpupool-create", 0) {
+ SWITCH_FOREACH_OPT(opt, "nf:", opts, "cpupool-create", 0) {
case 'f':
filename = optarg;
break;
@@ -7391,7 +7392,7 @@ int main_cpupoollist(int argc, char **argv)
uint32_t poolid;
char *name;
- SWITCH_FOREACH_OPT(opt, "hc", opts, "cpupool-list", 0) {
+ SWITCH_FOREACH_OPT(opt, "c", opts, "cpupool-list", 0) {
case 'c':
opt_cpus = 1;
break;
--
1.7.10.4
next prev parent reply other threads:[~2015-07-17 17:00 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-17 17:00 [PATCH 1/5] xl: Command line: Adjust "Fix segfaults from `xl psr-cat-cbm-set`..." Ian Jackson
2015-07-17 17:00 ` [PATCH 2/5] xl: Command line: Remove maximum argument limit for network-attach Ian Jackson
2015-07-20 10:00 ` Wei Liu
2015-07-17 17:00 ` Ian Jackson [this message]
2015-07-20 10:06 ` [PATCH 3/5] xl: Command line: Support -h everywhere Wei Liu
2015-07-17 17:00 ` [PATCH 4/5] xl: Command line: Make COMMON_LONG_OPTS include sentinel Ian Jackson
2015-07-17 17:09 ` Andrew Cooper
2015-07-17 17:11 ` Ian Jackson
2015-07-24 11:06 ` Ian Campbell
2015-07-17 17:00 ` [PATCH 5/5] xl: Command line: Support xl vcpu-set --help Ian Jackson
2015-07-20 10:07 ` Wei Liu
2015-07-17 17:04 ` [PATCH 1/5] xl: Command line: Adjust "Fix segfaults from `xl psr-cat-cbm-set`..." Andrew Cooper
2015-07-21 14:16 ` Ian Campbell
2015-07-21 14:27 ` Ian Jackson
2015-07-21 14:36 ` Wei Liu
2015-07-21 15:26 ` Ian Campbell
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=1437152451-22507-3-git-send-email-ian.jackson@eu.citrix.com \
--to=ian.jackson@eu.citrix.com \
--cc=ian.campbell@citrix.com \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xensource.com \
/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).