[v1,4/8] option: rename name field

Message ID 5ed62946ea2ffd627c5422bb5569cb0841f88a69.1545325395.git.gaetan.rivet@6wind.com (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series Clean up rte_option |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Gaëtan Rivet Dec. 20, 2018, 5:06 p.m. UTC
  option->opt_* is redundant.
The field should also be constant.

Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
---
 lib/librte_eal/common/include/rte_option.h | 2 +-
 lib/librte_eal/common/rte_option.c         | 8 ++++----
 lib/librte_telemetry/rte_telemetry.c       | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)
  

Patch

diff --git a/lib/librte_eal/common/include/rte_option.h b/lib/librte_eal/common/include/rte_option.h
index bbcc6cec9..eea95e477 100644
--- a/lib/librte_eal/common/include/rte_option.h
+++ b/lib/librte_eal/common/include/rte_option.h
@@ -34,7 +34,7 @@  typedef int (*rte_option_cb)(void);
  */
 struct rte_option {
 	TAILQ_ENTRY(rte_option) next; /**< Next entry in the list. */
-	char *opt_str;             /**< The option name. */
+	const char *name; /**< The option name. */
 	const char *usage; /**< Option summary string. */
 	rte_option_cb cb;          /**< Function called when option is used. */
 	int enabled;               /**< Set when the option is used. */
diff --git a/lib/librte_eal/common/rte_option.c b/lib/librte_eal/common/rte_option.c
index 2ed74873b..d94363872 100644
--- a/lib/librte_eal/common/rte_option.c
+++ b/lib/librte_eal/common/rte_option.c
@@ -26,7 +26,7 @@  rte_option_parse(const char *opt)
 
 	/* Check if the option is registered */
 	TAILQ_FOREACH(option, &rte_option_list, next) {
-		if (strcmp(&opt[2], option->opt_str) == 0) {
+		if (strcmp(&opt[2], option->name) == 0) {
 			option->enabled = 1;
 			return 0;
 		}
@@ -41,9 +41,9 @@  rte_option_register(struct rte_option *opt)
 	struct rte_option *option;
 
 	TAILQ_FOREACH(option, &rte_option_list, next) {
-		if (strcmp(opt->opt_str, option->opt_str) == 0) {
+		if (strcmp(opt->name, option->name) == 0) {
 			RTE_LOG(INFO, EAL, "Option %s has already been registered.\n",
-					opt->opt_str);
+					opt->name);
 			return;
 		}
 	}
@@ -75,6 +75,6 @@  rte_option_usage(void)
 
 	printf("EAL dynamic options:\n");
 	TAILQ_FOREACH(option, &rte_option_list, next)
-		printf("  --%-*s %s\n", 17, option->opt_str, option->usage);
+		printf("  --%-*s %s\n", 17, option->name, option->usage);
 	printf("\n");
 }
diff --git a/lib/librte_telemetry/rte_telemetry.c b/lib/librte_telemetry/rte_telemetry.c
index 0ba6626c1..3ba7ae8de 100644
--- a/lib/librte_telemetry/rte_telemetry.c
+++ b/lib/librte_telemetry/rte_telemetry.c
@@ -1798,7 +1798,7 @@  rte_telemetry_json_socket_message_test(struct telemetry_impl *telemetry, int fd)
 int telemetry_log_level;
 
 static struct rte_option option = {
-	.opt_str = "telemetry",
+	.name = "telemetry",
 	.usage = "Enable telemetry backend",
 	.cb = &rte_telemetry_init,
 	.enabled = 0