DPDK patches and discussions
 help / color / mirror / Atom feed
From: Gaetan Rivet <gaetan.rivet@6wind.com>
To: dev@dpdk.org
Cc: Gaetan Rivet <gaetan.rivet@6wind.com>
Subject: [dpdk-dev] [PATCH v1 8/8] option: return an error when register fail
Date: Thu, 20 Dec 2018 18:06:47 +0100	[thread overview]
Message-ID: <4a38da694ec265a04da45810aa1ea64ae9fa4e8a.1545325395.git.gaetan.rivet@6wind.com> (raw)
In-Reply-To: <cover.1545325395.git.gaetan.rivet@6wind.com>

Make rte_option_register return a negative value when
an error occur.

Signed-off-by: Gaetan Rivet <gaetan.rivet@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

  parent reply	other threads:[~2018-12-20 17:07 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-20 17:06 [dpdk-dev] [PATCH v1 0/8] Clean up rte_option Gaetan Rivet
2018-12-20 17:06 ` [dpdk-dev] [PATCH v1 1/8] option: use bare option string as name Gaetan Rivet
2018-12-20 17:06 ` [dpdk-dev] [PATCH v1 2/8] option: do not use static iterator Gaetan Rivet
2018-12-20 17:06 ` [dpdk-dev] [PATCH v1 3/8] option: add usage string Gaetan Rivet
2018-12-20 17:06 ` [dpdk-dev] [PATCH v1 4/8] option: rename name field Gaetan Rivet
2018-12-20 17:06 ` [dpdk-dev] [PATCH v1 5/8] option: check against common option on register Gaetan Rivet
2018-12-20 17:06 ` [dpdk-dev] [PATCH v1 6/8] option: fix log level of error in register Gaetan Rivet
2018-12-20 17:06 ` [dpdk-dev] [PATCH v1 7/8] option: improve library documentation Gaetan Rivet
2018-12-20 17:06 ` Gaetan Rivet [this message]
2019-01-15  1:23 ` [dpdk-dev] [PATCH v1 0/8] Clean up rte_option Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4a38da694ec265a04da45810aa1ea64ae9fa4e8a.1545325395.git.gaetan.rivet@6wind.com \
    --to=gaetan.rivet@6wind.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).