DPDK patches and discussions
 help / color / mirror / Atom feed
From: Thomas Monjalon <thomas@monjalon.net>
To: anatoly.burakov@intel.com
Cc: dev@dpdk.org
Subject: [dpdk-dev] [PATCH] ipc: replace bool checks with explicit non-zero
Date: Fri,  3 May 2019 17:35:39 +0200	[thread overview]
Message-ID: <20190503153539.17993-1-thomas@monjalon.net> (raw)
Message-ID: <20190503153539.YrcLxYTQyPgBQnO46AJeDwDF_wem1GtmyvWZ1us1OvM@z> (raw)

The function check_input() was returning a bool as error code.
It is changed to return an int, semantically more correct.
While at it, make checks of validate_action_name() return
explicit as described in the coding guidelines.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 lib/librte_eal/common/eal_common_proc.c | 30 ++++++++++++-------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/lib/librte_eal/common/eal_common_proc.c b/lib/librte_eal/common/eal_common_proc.c
index d098803b1..d23728604 100644
--- a/lib/librte_eal/common/eal_common_proc.c
+++ b/lib/librte_eal/common/eal_common_proc.c
@@ -202,7 +202,7 @@ rte_mp_action_register(const char *name, rte_mp_t action)
 {
 	struct action_entry *entry;
 
-	if (validate_action_name(name))
+	if (validate_action_name(name) != 0)
 		return -1;
 
 	entry = malloc(sizeof(struct action_entry));
@@ -230,7 +230,7 @@ rte_mp_action_unregister(const char *name)
 {
 	struct action_entry *entry;
 
-	if (validate_action_name(name))
+	if (validate_action_name(name) != 0)
 		return;
 
 	pthread_mutex_lock(&mp_mutex_action);
@@ -749,50 +749,50 @@ mp_send(struct rte_mp_msg *msg, const char *peer, int type)
 	return ret;
 }
 
-static bool
+static int
 check_input(const struct rte_mp_msg *msg)
 {
 	if (msg == NULL) {
 		RTE_LOG(ERR, EAL, "Msg cannot be NULL\n");
 		rte_errno = EINVAL;
-		return false;
+		return -1;
 	}
 
-	if (validate_action_name(msg->name))
-		return false;
+	if (validate_action_name(msg->name) != 0)
+		return -1;
 
 	if (msg->len_param < 0) {
 		RTE_LOG(ERR, EAL, "Message data length is negative\n");
 		rte_errno = EINVAL;
-		return false;
+		return -1;
 	}
 
 	if (msg->num_fds < 0) {
 		RTE_LOG(ERR, EAL, "Number of fd's is negative\n");
 		rte_errno = EINVAL;
-		return false;
+		return -1;
 	}
 
 	if (msg->len_param > RTE_MP_MAX_PARAM_LEN) {
 		RTE_LOG(ERR, EAL, "Message data is too long\n");
 		rte_errno = E2BIG;
-		return false;
+		return -1;
 	}
 
 	if (msg->num_fds > RTE_MP_MAX_FD_NUM) {
 		RTE_LOG(ERR, EAL, "Cannot send more than %d FDs\n",
 			RTE_MP_MAX_FD_NUM);
 		rte_errno = E2BIG;
-		return false;
+		return -1;
 	}
 
-	return true;
+	return 0;
 }
 
 int __rte_experimental
 rte_mp_sendmsg(struct rte_mp_msg *msg)
 {
-	if (!check_input(msg))
+	if (check_input(msg) != 0)
 		return -1;
 
 	RTE_LOG(DEBUG, EAL, "sendmsg: %s\n", msg->name);
@@ -946,7 +946,7 @@ rte_mp_request_sync(struct rte_mp_msg *req, struct rte_mp_reply *reply,
 	reply->nb_received = 0;
 	reply->msgs = NULL;
 
-	if (check_input(req) == false)
+	if (check_input(req) != 0)
 		goto err;
 
 	if (internal_config.no_shconf) {
@@ -1040,7 +1040,7 @@ rte_mp_request_async(struct rte_mp_msg *req, const struct timespec *ts,
 
 	RTE_LOG(DEBUG, EAL, "request: %s\n", req->name);
 
-	if (check_input(req) == false)
+	if (check_input(req) != 0)
 		return -1;
 
 	if (internal_config.no_shconf) {
@@ -1177,7 +1177,7 @@ rte_mp_reply(struct rte_mp_msg *msg, const char *peer)
 {
 	RTE_LOG(DEBUG, EAL, "reply: %s\n", msg->name);
 
-	if (check_input(msg) == false)
+	if (check_input(msg) != 0)
 		return -1;
 
 	if (peer == NULL) {
-- 
2.21.0


             reply	other threads:[~2019-05-03 15:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-03 15:35 Thomas Monjalon [this message]
2019-05-03 15:35 ` Thomas Monjalon
2019-05-03 15:52 ` Burakov, Anatoly
2019-05-03 15:52   ` Burakov, Anatoly
2019-05-03 17:30   ` Thomas Monjalon
2019-05-03 17:30     ` 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=20190503153539.17993-1-thomas@monjalon.net \
    --to=thomas@monjalon.net \
    --cc=anatoly.burakov@intel.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).