[dpdk-dev] [PATCH v1 8/8] option: return an error when register fail

Gaetan Rivet gaetan.rivet at 6wind.com
Thu Dec 20 18:06:47 CET 2018


Make rte_option_register return a negative value when
an error occur.

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

diff --git a/lib/librte_eal/common/include/rte_option.h b/lib/librte_eal/common/include/rte_option.h
index 20be47d91..7ad65a4eb 100644
--- a/lib/librte_eal/common/include/rte_option.h
+++ b/lib/librte_eal/common/include/rte_option.h
@@ -57,8 +57,12 @@ struct rte_option {
  *
  * @param opt
  *  Structure describing the option to parse.
+ *
+ * @return
+ *  0 on success, <0 otherwise.
  */
-void __rte_experimental
+__rte_experimental
+int
 rte_option_register(struct rte_option *opt);
 
 #ifdef __cplusplus
diff --git a/lib/librte_eal/common/rte_option.c b/lib/librte_eal/common/rte_option.c
index b2c93b220..fe7f2ab4e 100644
--- a/lib/librte_eal/common/rte_option.c
+++ b/lib/librte_eal/common/rte_option.c
@@ -38,7 +38,8 @@ rte_option_parse(const char *opt)
 	return -1;
 }
 
-void __rte_experimental
+__rte_experimental
+int
 rte_option_register(struct rte_option *opt)
 {
 	struct rte_option *option;
@@ -49,7 +50,7 @@ rte_option_register(struct rte_option *opt)
 		if (strcmp(gopt->name, opt->name) == 0) {
 			RTE_LOG(ERR, EAL, "Option %s is already a common EAL option.\n",
 					opt->name);
-			return;
+			return -1;
 		}
 		gopt++;
 	}
@@ -58,11 +59,12 @@ rte_option_register(struct rte_option *opt)
 		if (strcmp(opt->name, option->name) == 0) {
 			RTE_LOG(ERR, EAL, "Option %s has already been registered.\n",
 					opt->name);
-			return;
+			return -1;
 		}
 	}
 
 	TAILQ_INSERT_HEAD(&rte_option_list, opt, next);
+	return 0;
 }
 
 void
-- 
2.19.1



More information about the dev mailing list