From: bugzilla@dpdk.org
To: dev@dpdk.org
Subject: [dpdk-dev] [Bug 238] [tree-wide] enhance getopt_long usage
Date: Tue, 02 Apr 2019 07:38:39 +0000 [thread overview]
Message-ID: <bug-238-3@http.bugs.dpdk.org/> (raw)
https://bugs.dpdk.org/show_bug.cgi?id=238
Bug ID: 238
Summary: [tree-wide] enhance getopt_long usage
Product: DPDK
Version: unspecified
Hardware: All
OS: All
Status: CONFIRMED
Severity: enhancement
Priority: Low
Component: other
Assignee: dev@dpdk.org
Reporter: david.marchand@redhat.com
Target Milestone: future
We have quite a couple of the following pattern in the apps and examples
(quoting examples/fips_validation/main.c as a bad example):
struct option lgopts[] = {
{REQ_FILE_PATH_KEYWORD, required_argument, 0, 0},
{RSP_FILE_PATH_KEYWORD, required_argument, 0, 0},
{FOLDER_KEYWORD, no_argument, 0, 0},
{CRYPTODEV_KEYWORD, required_argument, 0, 0},
{CRYPTODEV_ID_KEYWORD, required_argument, 0, 0},
{CRYPTODEV_ST_KEYWORD, no_argument, 0, 0},
{CRYPTODEV_BK_ID_KEYWORD, required_argument, 0, 0},
{CRYPTODEV_BK_DIR_KEY, required_argument, 0, 0},
{NULL, 0, 0, 0}
};
while ((opt = getopt_long(argc, argvopt, "s:",
lgopts, &option_index)) != EOF) {
switch (opt) {
case 0:
if (strcmp(lgopts[option_index].name,
REQ_FILE_PATH_KEYWORD) == 0)
env.req_path = optarg;
else if (strcmp(lgopts[option_index].name,
RSP_FILE_PATH_KEYWORD) == 0)
env.rsp_path = optarg;
else if (strcmp(lgopts[option_index].name,
FOLDER_KEYWORD) == 0)
env.is_path_folder = 1;
else if (strcmp(lgopts[option_index].name,
...
We can get rid of all those strcmp by directly binding each longopt with an int
enum.
eal has been using this convention for quite some time, see:
https://git.dpdk.org/dpdk/tree/lib/librte_eal/common/eal_options.h?h=v19.02
https://git.dpdk.org/dpdk/tree/lib/librte_eal/common/eal_common_options.c?h=v19.02
--
You are receiving this mail because:
You are the assignee for the bug.
next reply other threads:[~2019-04-02 7:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-02 7:38 bugzilla [this message]
2019-04-02 7:38 ` bugzilla
2021-04-01 23:44 ` bugzilla
2021-04-02 7:57 ` bugzilla
2021-04-22 8:50 ` bugzilla
2021-04-26 9:04 ` bugzilla
2021-11-26 18:03 ` bugzilla
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=bug-238-3@http.bugs.dpdk.org/ \
--to=bugzilla@dpdk.org \
--cc=dev@dpdk.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).