DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [Bug 238] [tree-wide] enhance getopt_long usage
@ 2019-04-02  7:38 bugzilla
  2019-04-02  7:38 ` bugzilla
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: bugzilla @ 2019-04-02  7:38 UTC (permalink / raw)
  To: dev

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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [dpdk-dev] [Bug 238] [tree-wide] enhance getopt_long usage
  2019-04-02  7:38 [dpdk-dev] [Bug 238] [tree-wide] enhance getopt_long usage bugzilla
@ 2019-04-02  7:38 ` bugzilla
  2021-04-01 23:44 ` bugzilla
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: bugzilla @ 2019-04-02  7:38 UTC (permalink / raw)
  To: dev

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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [dpdk-dev] [Bug 238] [tree-wide] enhance getopt_long usage
  2019-04-02  7:38 [dpdk-dev] [Bug 238] [tree-wide] enhance getopt_long usage bugzilla
  2019-04-02  7:38 ` bugzilla
@ 2021-04-01 23:44 ` bugzilla
  2021-04-02  7:57 ` bugzilla
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: bugzilla @ 2021-04-01 23:44 UTC (permalink / raw)
  To: dev

https://bugs.dpdk.org/show_bug.cgi?id=238

Thomas Monjalon (thomas@monjalon.net) changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|CONFIRMED                   |RESOLVED
         Resolution|---                         |FIXED

--- Comment #1 from Thomas Monjalon (thomas@monjalon.net) ---
Resolved in http://git.dpdk.org/dpdk/commit/?id=270054edc9

-- 
You are receiving this mail because:
You are the assignee for the bug.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [dpdk-dev] [Bug 238] [tree-wide] enhance getopt_long usage
  2019-04-02  7:38 [dpdk-dev] [Bug 238] [tree-wide] enhance getopt_long usage bugzilla
  2019-04-02  7:38 ` bugzilla
  2021-04-01 23:44 ` bugzilla
@ 2021-04-02  7:57 ` bugzilla
  2021-04-22  8:50 ` bugzilla
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: bugzilla @ 2021-04-02  7:57 UTC (permalink / raw)
  To: dev

https://bugs.dpdk.org/show_bug.cgi?id=238

Thomas Monjalon (thomas@monjalon.net) changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |thomas@monjalon.net
             Status|RESOLVED                    |CONFIRMED
         Resolution|FIXED                       |---

-- 
You are receiving this mail because:
You are the assignee for the bug.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [dpdk-dev] [Bug 238] [tree-wide] enhance getopt_long usage
  2019-04-02  7:38 [dpdk-dev] [Bug 238] [tree-wide] enhance getopt_long usage bugzilla
                   ` (2 preceding siblings ...)
  2021-04-02  7:57 ` bugzilla
@ 2021-04-22  8:50 ` bugzilla
  2021-04-26  9:04 ` bugzilla
  2021-11-26 18:03 ` bugzilla
  5 siblings, 0 replies; 7+ messages in thread
From: bugzilla @ 2021-04-22  8:50 UTC (permalink / raw)
  To: dev

https://bugs.dpdk.org/show_bug.cgi?id=238

Thomas Monjalon (thomas@monjalon.net) changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|CONFIRMED                   |RESOLVED
         Resolution|---                         |FIXED

--- Comment #8 from Thomas Monjalon (thomas@monjalon.net) ---
Resolved in http://git.dpdk.org/dpdk/commit/?id=270054edc9

-- 
You are receiving this mail because:
You are the assignee for the bug.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [dpdk-dev] [Bug 238] [tree-wide] enhance getopt_long usage
  2019-04-02  7:38 [dpdk-dev] [Bug 238] [tree-wide] enhance getopt_long usage bugzilla
                   ` (3 preceding siblings ...)
  2021-04-22  8:50 ` bugzilla
@ 2021-04-26  9:04 ` bugzilla
  2021-11-26 18:03 ` bugzilla
  5 siblings, 0 replies; 7+ messages in thread
From: bugzilla @ 2021-04-26  9:04 UTC (permalink / raw)
  To: dev

https://bugs.dpdk.org/show_bug.cgi?id=238

David Marchand (david.marchand@redhat.com) changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |CONFIRMED
         Resolution|FIXED                       |---

-- 
You are receiving this mail because:
You are the assignee for the bug.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug 238] [tree-wide] enhance getopt_long usage
  2019-04-02  7:38 [dpdk-dev] [Bug 238] [tree-wide] enhance getopt_long usage bugzilla
                   ` (4 preceding siblings ...)
  2021-04-26  9:04 ` bugzilla
@ 2021-11-26 18:03 ` bugzilla
  5 siblings, 0 replies; 7+ messages in thread
From: bugzilla @ 2021-11-26 18:03 UTC (permalink / raw)
  To: dev

https://bugs.dpdk.org/show_bug.cgi?id=238

Thomas Monjalon (thomas@monjalon.net) changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|CONFIRMED                   |RESOLVED

--- Comment #15 from Thomas Monjalon (thomas@monjalon.net) ---
Resolved in http://git.dpdk.org/dpdk/commit/?id=270054edc9

-- 
You are receiving this mail because:
You are the assignee for the bug.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-11-26 18:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-02  7:38 [dpdk-dev] [Bug 238] [tree-wide] enhance getopt_long usage bugzilla
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

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