From: David Marchand <david.marchand@redhat.com> To: Ibtisam Tariq <ibtisam.tariq@emumba.com> Cc: Maxime Coquelin <maxime.coquelin@redhat.com>, "Xia, Chenbo" <chenbo.xia@intel.com>, Cristian Dumitrescu <cristian.dumitrescu@intel.com>, "Singh, Jasvinder" <jasvinder.singh@intel.com>, "Mcnamara, John" <john.mcnamara@intel.com>, "Pattan, Reshma" <reshma.pattan@intel.com>, "Ananyev, Konstantin" <konstantin.ananyev@intel.com>, "Kovacevic, Marko" <marko.kovacevic@intel.com>, dev <dev@dpdk.org> Subject: Re: [dpdk-dev] [PATCH 1/7] examples/fips_validation: enhance getopt_long usage Date: Mon, 7 Dec 2020 11:50:55 +0100 Message-ID: <CAJFAV8zXrcSbBPT8v0AP5UCCYsDjhzNaO643eg1cM2g=9-DQ2w@mail.gmail.com> (raw) In-Reply-To: <20201124123249.14451-1-ibtisam.tariq@emumba.com> On Tue, Nov 24, 2020 at 1:33 PM Ibtisam Tariq <ibtisam.tariq@emumba.com> wrote: > > Instead of using getopt_long return value, strcmp was used to > compare the input parameters with the struct option array. This > patch get rid of all those strcmp by directly binding each longopt > with an int enum. This is to improve readability and consistency in > all examples. > > Bugzilla ID: 238 > Cc: marko.kovacevic@intel.com > > Reported-by: David Marchand <david.marchand@redhat.com> > Signed-off-by: Ibtisam Tariq <ibtisam.tariq@emumba.com> > --- > v3: > * None. We lost the version prefix in the patch title, please do not forget it in the next revision. [snip] > diff --git a/examples/fips_validation/main.c b/examples/fips_validation/main.c > index cad6bcb18..36ed4b546 100644 > --- a/examples/fips_validation/main.c > +++ b/examples/fips_validation/main.c > @@ -15,17 +15,26 @@ > #include "fips_validation.h" > #include "fips_dev_self_test.h" > > -#define REQ_FILE_PATH_KEYWORD "req-file" > -#define RSP_FILE_PATH_KEYWORD "rsp-file" > -#define MBUF_DATAROOM_KEYWORD "mbuf-dataroom" > -#define FOLDER_KEYWORD "path-is-folder" > -#define CRYPTODEV_KEYWORD "cryptodev" > -#define CRYPTODEV_ID_KEYWORD "cryptodev-id" > -#define CRYPTODEV_ST_KEYWORD "self-test" > -#define CRYPTODEV_BK_ID_KEYWORD "broken-test-id" > -#define CRYPTODEV_BK_DIR_KEY "broken-test-dir" > -#define CRYPTODEV_ENC_KEYWORD "enc" > -#define CRYPTODEV_DEC_KEYWORD "dec" > +enum { > +#define OPT_REQ_FILE_PATH "req-file" > + OPT_REQ_FILE_PATH_NUM = 256, > +#define OPT_RSP_FILE_PATH "rsp-file" > + OPT_RSP_FILE_PATH_NUM, > +#define OPT_MBUF_DATAROOM "mbuf-dataroom" > + OPT_MBUF_DATAROOM_NUM, > +#define OPT_FOLDER "path-is-folder" > + OPT_FOLDER_NUM, > +#define OPT_CRYPTODEV "cryptodev" > + OPT_CRYPTODEV_NUM, Nit: could you realign those two strings? > +#define OPT_CRYPTODEV_ID "cryptodev-id" > + OPT_CRYPTODEV_ID_NUM, > +#define OPT_CRYPTODEV_ST "self-test" > + OPT_CRYPTODEV_ST_NUM, > +#define OPT_CRYPTODEV_BK_ID "broken-test-id" > + OPT_CRYPTODEV_BK_ID_NUM, > +#define OPT_CRYPTODEV_BK_DIR_KEY "broken-test-dir" > + OPT_CRYPTODEV_BK_DIR_KEY_NUM, > +}; [snip] > @@ -248,108 +266,113 @@ cryptodev_fips_validate_parse_args(int argc, char **argv) > return -EINVAL; > } > > - while ((opt = getopt_long(argc, argvopt, "s:", > + while ((opt = getopt_long(argc, argvopt, "", Passing "s:" was a bug (since nothing was done with it). But this was not an issue requiring a separate fix + backport from my pov. Let's at least mention it in the commitlog. > lgopts, &option_index)) != EOF) { > > + if (opt == '?') { > + cryptodev_fips_validate_usage(prgname); > + return -1; > + } Why a separate check here? The default: block below will handle an unknown option fine. > + > switch (opt) { [snip] > + > default: > - return -1; > + cryptodev_fips_validate_usage(prgname); > + return -EINVAL; > } > } > -- David Marchand
next prev parent reply other threads:[~2020-12-07 10:51 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-11-24 12:32 Ibtisam Tariq 2020-11-24 12:32 ` [dpdk-dev] [PATCH 2/7] examples/l3fwd-acl: " Ibtisam Tariq 2020-11-24 12:32 ` [dpdk-dev] [PATCH 3/7] examples/packet_ordering: " Ibtisam Tariq 2020-11-24 12:32 ` [dpdk-dev] [PATCH 4/7] examples/performance-thread/l3fwd-thread: " Ibtisam Tariq 2020-11-24 12:32 ` [dpdk-dev] [PATCH 5/7] examples/qos_sched: " Ibtisam Tariq 2020-11-24 12:32 ` [dpdk-dev] [PATCH 6/7] examples/vhost: " Ibtisam Tariq 2020-12-07 10:51 ` David Marchand 2020-12-31 7:00 ` Ibtisam Tariq 2020-11-24 12:32 ` [dpdk-dev] [PATCH 7/7] examples/vhost_crypto: " Ibtisam Tariq 2020-12-07 10:50 ` David Marchand [this message] -- strict thread matches above, loose matches on Subject: below -- 2020-11-11 8:15 [dpdk-dev] [PATCH 1/7] examples/fips_validation: " Ibtisam Tariq
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='CAJFAV8zXrcSbBPT8v0AP5UCCYsDjhzNaO643eg1cM2g=9-DQ2w@mail.gmail.com' \ --to=david.marchand@redhat.com \ --cc=chenbo.xia@intel.com \ --cc=cristian.dumitrescu@intel.com \ --cc=dev@dpdk.org \ --cc=ibtisam.tariq@emumba.com \ --cc=jasvinder.singh@intel.com \ --cc=john.mcnamara@intel.com \ --cc=konstantin.ananyev@intel.com \ --cc=marko.kovacevic@intel.com \ --cc=maxime.coquelin@redhat.com \ --cc=reshma.pattan@intel.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
DPDK patches and discussions This inbox may be cloned and mirrored by anyone: git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \ dev@dpdk.org public-inbox-index dev Example config snippet for mirrors. Newsgroup available over NNTP: nntp://inbox.dpdk.org/inbox.dpdk.dev AGPL code for this site: git clone https://public-inbox.org/public-inbox.git