Skip to contentSkip to conversation

cmdline: prefix cmdline numeric enum

PATCH In review Stephen Hemminger 2 participants 3 messages Oct 24, 2019 – Oct 25, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cmdline: prefix cmdline numeric enum

The values in an enum are really global names and not specific to the enum in question. This can lead to namespace conflicts in applications if a common value is visible.

The DPDK cmdline API has an enum for numeric type values with names line UINT32 which could be used or defined in a user application. Change these to be prefixed with the enum name like other places in DPDK.

Lots of lines changed with no change in actual code generated.

---
 app/test-cmdline/commands.c                   |   2 +-
 app/test-pmd/bpf_cmd.c                        |   8 +-
 app/test-pmd/cmdline.c                        | 656 +++++++++---------
 app/test-pmd/cmdline_mtr.c                    |  84 +--
 app/test-pmd/cmdline_tm.c                     | 172 ++---
 app/test/test_cmdline_num.c                   |  48 +-
 doc/guides/rel_notes/release_19_11.rst        |   3 +
 examples/ethtool/ethtool-app/ethapp.c         |  18 +-
 examples/ipsec-secgw/parser.c                 |   2 +-
 examples/qos_sched/cmdline.c                  |  46 +-
 examples/quota_watermark/qwctl/commands.c     |   2 +-
 .../guest_cli/vm_power_cli_guest.c            |   2 +-
 examples/vm_power_manager/vm_power_cli.c      |   8 +-
 lib/librte_cmdline/cmdline_parse_num.c        |  40 +-
 lib/librte_cmdline/cmdline_parse_num.h        |  16 +-
 15 files changed, 555 insertions(+), 552 deletions(-)
app/test-cmdline/commands.c +1 -1
index d81da9665aff..a3d8143d372b 100644
@@ -191,7 +191,7 @@ cmd_num_parsed(void *parsed_result,
 }
 
 cmdline_parse_token_num_t cmd_num_tok =
-	TOKEN_NUM_INITIALIZER(struct cmd_num_result, num, UINT32);
+	TOKEN_NUM_INITIALIZER(struct cmd_num_result, num, CMDLINE_UINT32);
 
 cmdline_parse_inst_t cmd_num = {
 	.f = cmd_num_parsed,  /* function to call */
app/test-pmd/bpf_cmd.c +4 -4
index 830bfc13a520..465d5c46f0cb 100644
@@ -124,9 +124,9 @@ cmdline_parse_token_string_t cmd_load_bpf_dir =
 	TOKEN_STRING_INITIALIZER(struct cmd_bpf_ld_result,
 			dir, "rx#tx");
 cmdline_parse_token_num_t cmd_load_bpf_port =
-	TOKEN_NUM_INITIALIZER(struct cmd_bpf_ld_result, port, UINT8);
+	TOKEN_NUM_INITIALIZER(struct cmd_bpf_ld_result, port, CMDLINE_UINT8);
 cmdline_parse_token_num_t cmd_load_bpf_queue =
-	TOKEN_NUM_INITIALIZER(struct cmd_bpf_ld_result, queue, UINT16);
+	TOKEN_NUM_INITIALIZER(struct cmd_bpf_ld_result, queue, CMDLINE_UINT16);
 cmdline_parse_token_string_t cmd_load_bpf_flags =
 	TOKEN_STRING_INITIALIZER(struct cmd_bpf_ld_result,
 			flags, NULL);
@@ -180,9 +180,9 @@ cmdline_parse_token_string_t cmd_unload_bpf_dir =
 	TOKEN_STRING_INITIALIZER(struct cmd_bpf_unld_result,
 			dir, "rx#tx");
 cmdline_parse_token_num_t cmd_unload_bpf_port =
-	TOKEN_NUM_INITIALIZER(struct cmd_bpf_unld_result, port, UINT8);
+	TOKEN_NUM_INITIALIZER(struct cmd_bpf_unld_result, port, CMDLINE_UINT8);
 cmdline_parse_token_num_t cmd_unload_bpf_queue =
-	TOKEN_NUM_INITIALIZER(struct cmd_bpf_unld_result, queue, UINT16);
+	TOKEN_NUM_INITIALIZER(struct cmd_bpf_unld_result, queue, CMDLINE_UINT16);
 
 cmdline_parse_inst_t cmd_operate_bpf_unld_parse = {
 	.f = cmd_operate_bpf_unld_parsed,
app/test-pmd/cmdline.c +328 -328

2,303 lines not on this page · raw message

app/test-pmd/cmdline_mtr.c +42 -42

242 lines not on this page · raw message

app/test-pmd/cmdline_tm.c +86 -86

425 lines not on this page · raw message

app/test/test_cmdline_num.c +24 -24

48 lines not on this page · raw message

doc/guides/rel_notes/release_19_11.rst +3 -0
index f59a283074f6..e4377d42af44 100644

Lines of this file are not shown. View the raw message.

examples/ethtool/ethtool-app/ethapp.c +9 -9
index b6b967118e4c..0e8b2315c467 100644

Lines of this file are not shown. View the raw message.

examples/ipsec-secgw/parser.c +1 -1
index fc8c238fe5a5..b46d5184b5e0 100644

Lines of this file are not shown. View the raw message.

examples/qos_sched/cmdline.c +23 -23

46 lines not on this page · raw message

examples/quota_watermark/qwctl/commands.c +1 -1
index a1c646b9fb52..f2579519c277 100644

Lines of this file are not shown. View the raw message.

examples/vm_power_manager/guest_cli/vm_power_cli_guest.c +1 -1
index fe09b0778ac1..a914549ddcb3 100644

Lines of this file are not shown. View the raw message.

examples/vm_power_manager/vm_power_cli.c +4 -4
index 89b000d923a8..4a7fb510a40f 100644

Lines of this file are not shown. View the raw message.

lib/librte_cmdline/cmdline_parse_num.c +20 -20
index 478f181b4443..0d9f63aef797 100644

Lines of this file are not shown. View the raw message.

lib/librte_cmdline/cmdline_parse_num.h +8 -8
index 58b28cad7c41..28b04520f01e 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.20.1

Part of the diff is not shown here. View the raw message.

#1 lore raw
Quoted 9 lines · Stephen Hemminger

The values in an enum are really global names and not specific to the enum in question. This can lead to namespace conflicts in applications if a common value is visible.

The DPDK cmdline API has an enum for numeric type values with names line UINT32 which could be used or defined in a user application. Change these to be prefixed with the enum name like other places in DPDK.

Quoted 5 lines

Lots of lines changed with no change in actual code generated.

---

Duplicate of this patch from 6 months ago?
http://patches.dpdk.org/patch/52644/

/Bruce

#2 lore raw
Quoted 13 lines · On Fri, 25 Oct 2019 11:55:41 +0100 Bruce Richardson…
Quoted 12 lines · Stephen Hemminger

The values in an enum are really global names and not specific to the enum in question. This can lead to namespace conflicts in applications if a common value is visible.

The DPDK cmdline API has an enum for numeric type values with names line UINT32 which could be used or defined in a user application. Change these to be prefixed with the enum name like other places in DPDK.

Lots of lines changed with no change in actual code generated.

Quoted 7 lines
Quoted 2 lines

---

Duplicate of this patch from 6 months ago?
http://patches.dpdk.org/patch/52644/

/Bruce

Yes. one of them should go in.
Checkpatch spits out lots of noise because existing code does not conform to style.