From: Thomas Monjalon Date: Thu, 29 Jan 2015 16:51:17 +0000 (+0100) Subject: eal: add help option X-Git-Tag: spdx-start~9586 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=a906cf28fd34c6e79d06297f74e6c747b01fa8c1;p=dpdk.git eal: add help option Help is printed with -h or --help. Help is also printed for an unknown option. This was broken since the rework of options. Fixes: 489a9d6c9f77 ("merge bsd and linux common options parsing") Signed-off-by: Thomas Monjalon Acked-by: David Marchand Acked-by: Neil Horman --- diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c index 69f3c03423..ca2f445e1f 100644 --- a/lib/librte_eal/bsdapp/eal/eal.c +++ b/lib/librte_eal/bsdapp/eal/eal.c @@ -326,8 +326,10 @@ eal_parse_args(int argc, char **argv) int ret; /* getopt is not happy, stop right now */ - if (opt == '?') + if (opt == '?') { + eal_usage(prgname); return -1; + } ret = eal_parse_common_option(opt, optarg, &internal_config); /* common parser is not happy */ @@ -340,6 +342,9 @@ eal_parse_args(int argc, char **argv) continue; switch (opt) { + case 'h': + eal_usage(prgname); + exit(EXIT_SUCCESS); default: if (opt < OPT_LONG_MIN_NUM && isprint(opt)) { RTE_LOG(ERR, EAL, "Option %c is not supported " diff --git a/lib/librte_eal/common/eal_common_options.c b/lib/librte_eal/common/eal_common_options.c index 3dda237532..4314e4e0d2 100644 --- a/lib/librte_eal/common/eal_common_options.c +++ b/lib/librte_eal/common/eal_common_options.c @@ -57,6 +57,7 @@ eal_short_options[] = "b:" /* pci-blacklist */ "c:" /* coremask */ "d:" /* driver */ + "h" /* help */ "l:" /* corelist */ "m:" /* memory size */ "n:" /* memory channels */ @@ -70,6 +71,7 @@ eal_long_options[] = { {OPT_BASE_VIRTADDR, 1, NULL, OPT_BASE_VIRTADDR_NUM }, {OPT_CREATE_UIO_DEV, 1, NULL, OPT_CREATE_UIO_DEV_NUM }, {OPT_FILE_PREFIX, 1, NULL, OPT_FILE_PREFIX_NUM }, + {OPT_HELP, 0, NULL, OPT_HELP_NUM }, {OPT_HUGE_DIR, 1, NULL, OPT_HUGE_DIR_NUM }, {OPT_LOG_LEVEL, 1, NULL, OPT_LOG_LEVEL_NUM }, {OPT_MASTER_LCORE, 1, NULL, OPT_MASTER_LCORE_NUM }, @@ -605,6 +607,7 @@ eal_common_usage(void) " --"OPT_SYSLOG" Set syslog facility\n" " --"OPT_LOG_LEVEL" Set default log level\n" " -v Display version information on startup\n" + " -h, --help This help\n" "\nEAL options for DEBUG use only:\n" " --"OPT_NO_HUGE" Use malloc instead of hugetlbfs\n" " --"OPT_NO_PCI" Disable PCI\n" diff --git a/lib/librte_eal/common/eal_options.h b/lib/librte_eal/common/eal_options.h index fe1c85d60a..d199a00a18 100644 --- a/lib/librte_eal/common/eal_options.h +++ b/lib/librte_eal/common/eal_options.h @@ -35,6 +35,8 @@ enum { /* long options mapped to a short option */ +#define OPT_HELP "help" + OPT_HELP_NUM = 'h', #define OPT_PCI_BLACKLIST "pci-blacklist" OPT_PCI_BLACKLIST_NUM = 'b', #define OPT_PCI_WHITELIST "pci-whitelist" diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c index e3955e7eae..d8c06288fd 100644 --- a/lib/librte_eal/linuxapp/eal/eal.c +++ b/lib/librte_eal/linuxapp/eal/eal.c @@ -520,8 +520,10 @@ eal_parse_args(int argc, char **argv) int ret; /* getopt is not happy, stop right now */ - if (opt == '?') + if (opt == '?') { + eal_usage(prgname); return -1; + } ret = eal_parse_common_option(opt, optarg, &internal_config); /* common parser is not happy */ @@ -534,6 +536,10 @@ eal_parse_args(int argc, char **argv) continue; switch (opt) { + case 'h': + eal_usage(prgname); + exit(EXIT_SUCCESS); + /* force loading of external driver */ case 'd': solib = malloc(sizeof(*solib));