From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com [209.85.212.181]) by dpdk.org (Postfix) with ESMTP id A286AADF9 for ; Thu, 12 Feb 2015 17:48:37 +0100 (CET) Received: by mail-wi0-f181.google.com with SMTP id r20so5863695wiv.2 for ; Thu, 12 Feb 2015 08:48:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=u12GRulB4jsbG+ewIUjUZ7kVx2PCynaU8dVKiOb56OA=; b=c5Uf3tivo+DswgKEzJMCKGb4MRJEg5Jlm+079Q6i7NERAHl3b9XB2l+MwJeaCIH8GO yKisFnWh+rTLS6X5TinKZTe0zKDaY8HqsfpWU4qSPCcgyZCTeV8KasPA5gQxgmrdSHTE hNssks7ddQhdJCtoj8Dc8zh5wqNs6lmjASOrDybyjLy3ONBCO0qa5iD941OxIR2lWLNe 0cqZDs3v5NlsCWnZ335oPJUTEenVzd2ges1AeUV7nBvGOwRTqUhsCqt8mO10fFW8K5wU eVEduZcD0SvSRc9VnE0QbE7PU8mxKb9szbTb/UTg1Eo5boMe4611PMbjzoyT0hQk2fhx 6ddQ== X-Gm-Message-State: ALoCoQlhYPYnYgZWjDjohDOWX5nVRMcxCVDtVC2kpMJ1okKuvrX8bEbceaffOhUdebSVbLR9w024 X-Received: by 10.194.190.10 with SMTP id gm10mr9443552wjc.91.1423759717563; Thu, 12 Feb 2015 08:48:37 -0800 (PST) Received: from localhost.localdomain (136-92-190-109.dsl.ovh.fr. [109.190.92.136]) by mx.google.com with ESMTPSA id hn2sm6417959wjc.5.2015.02.12.08.48.36 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 12 Feb 2015 08:48:36 -0800 (PST) From: Thomas Monjalon To: dev@dpdk.org Date: Thu, 12 Feb 2015 17:47:57 +0100 Message-Id: <1423759677-32152-3-git-send-email-thomas.monjalon@6wind.com> X-Mailer: git-send-email 2.2.2 In-Reply-To: <1423759677-32152-1-git-send-email-thomas.monjalon@6wind.com> References: <1422899093-20207-1-git-send-email-thomas.monjalon@6wind.com> <1423759677-32152-1-git-send-email-thomas.monjalon@6wind.com> Subject: [dpdk-dev] [PATCH v3 2/2] eal: add help option X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Feb 2015 16:48:37 -0000 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 --- lib/librte_eal/bsdapp/eal/eal.c | 7 ++++++- lib/librte_eal/common/eal_common_options.c | 3 +++ lib/librte_eal/common/eal_options.h | 2 ++ lib/librte_eal/linuxapp/eal/eal.c | 8 +++++++- 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/lib/librte_eal/bsdapp/eal/eal.c b/lib/librte_eal/bsdapp/eal/eal.c index 69f3c03..ca2f445 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 3dda237..4314e4e 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 fe1c85d..d199a00 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 e3955e7..d8c0628 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)); -- 2.2.2