diff mbox series

examples/l2fwd: fix l2fwd long options parse issue

Message ID 20210610010159.1813398-1-sunchenglian@loongson.cn (mailing list archive)
State Superseded
Delegated to: David Marchand
Headers show
Series examples/l2fwd: fix l2fwd long options parse issue | expand

Checks

Context Check Description
ci/Intel-compilation warning apply issues
ci/intel-Testing success Testing PASS
ci/iol-testing fail Testing issues
ci/github-robot success github build: passed
ci/iol-abi-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/checkpatch warning coding style issues

Commit Message

SunChengLian June 10, 2021, 1:01 a.m. UTC
Readd other long options case in l2fwd_parse_args function
to ensure all long options will work well.

Fixes: fa19eb20d2126d8bc63acc8f336a353dfaf8c354 ("examples/l2fwd: add forwarding port mapping option")
Cc: stable@dpdk.org

Signed-off-by: SunChengLian <sunchenglian@loongson.cn>
---
 examples/l2fwd/main.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

David Marchand June 11, 2021, 7:01 a.m. UTC | #1
On Thu, Jun 10, 2021 at 3:02 AM SunChengLian <sunchenglian@loongson.cn> wrote:
>
> Readd other long options case in l2fwd_parse_args function
> to ensure all long options will work well.

Please, be more explicit about the thing you want to fix.

I understand --no-mac-updating is broken.
You want to fix this long option.
Is this correct?


The Fixes: should follow the common format.
I recommend setting this alias in your config so that you only need to
call "git fixline $sha1":
$ git config alias.fixline "log -1 --abbrev=12 --format='Fixes: %h
(\"%s\")%nCc: %ae'"

So here, it should be:
Fixes: fa19eb20d212 ("examples/l2fwd: add forwarding port mapping option")


And I recommend aligning this example with others.
Iow do something like:

diff --git a/examples/l2fwd/main.c b/examples/l2fwd/main.c
index 32d405e65a..06cf8e1f14 100644
--- a/examples/l2fwd/main.c
+++ b/examples/l2fwd/main.c
@@ -433,13 +433,14 @@ enum {

        /* first long only option value must be >= 256, so that we won't
         * conflict with short options */
-       CMD_LINE_OPT_MIN_NUM = 256,
+       CMD_LINE_OPT_MAC_UPDATING_NUM = 256,
+       CMD_LINE_OPT_NO_MAC_UPDATING_NUM,
        CMD_LINE_OPT_PORTMAP_NUM,
 };

 static const struct option lgopts[] = {
-       { CMD_LINE_OPT_MAC_UPDATING, no_argument, &mac_updating, 1},
-       { CMD_LINE_OPT_NO_MAC_UPDATING, no_argument, &mac_updating, 0},
+       { CMD_LINE_OPT_MAC_UPDATING, no_argument, 0,
CMD_LINE_OPT_MAC_UPDATING_NUM},
+       { CMD_LINE_OPT_NO_MAC_UPDATING, no_argument, 0,
CMD_LINE_OPT_NO_MAC_UPDATING_NUM},
        { CMD_LINE_OPT_PORTMAP_CONFIG, 1, 0, CMD_LINE_OPT_PORTMAP_NUM},
        {NULL, 0, 0, 0}
 };
@@ -492,6 +493,14 @@ l2fwd_parse_args(int argc, char **argv)
                        break;

                /* long options */
+               case CMD_LINE_OPT_MAC_UPDATING_NUM:
+                       mac_updating = 1;
+                       break;
+
+               case CMD_LINE_OPT_NO_MAC_UPDATING_NUM:
+                       mac_updating = 0;
+                       break;
+
                case CMD_LINE_OPT_PORTMAP_NUM:
                        ret = l2fwd_parse_port_pair_config(optarg);
                        if (ret) {


In a followup patch, the "mac-updating" option can be removed since
the associated mac_updating variable is set to 1 by default.
diff mbox series

Patch

diff --git a/examples/l2fwd/main.c b/examples/l2fwd/main.c
index ffb67bb901..3215ec3806 100644
--- a/examples/l2fwd/main.c
+++ b/examples/l2fwd/main.c
@@ -502,6 +502,9 @@  l2fwd_parse_args(int argc, char **argv)
 			}
 			break;
 
+		case 0:
+			break;
+
 		default:
 			l2fwd_usage(prgname);
 			return -1;