DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] ipc: replace bool checks with explicit non-zero
@ 2019-05-03 15:35 Thomas Monjalon
  2019-05-03 15:35 ` Thomas Monjalon
  2019-05-03 15:52 ` Burakov, Anatoly
  0 siblings, 2 replies; 6+ messages in thread
From: Thomas Monjalon @ 2019-05-03 15:35 UTC (permalink / raw)
  To: anatoly.burakov; +Cc: dev

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [dpdk-dev] [PATCH] ipc: replace bool checks with explicit non-zero
  2019-05-03 15:35 [dpdk-dev] [PATCH] ipc: replace bool checks with explicit non-zero Thomas Monjalon
@ 2019-05-03 15:35 ` Thomas Monjalon
  2019-05-03 15:52 ` Burakov, Anatoly
  1 sibling, 0 replies; 6+ messages in thread
From: Thomas Monjalon @ 2019-05-03 15:35 UTC (permalink / raw)
  To: anatoly.burakov; +Cc: dev

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH] ipc: replace bool checks with explicit non-zero
  2019-05-03 15:35 [dpdk-dev] [PATCH] ipc: replace bool checks with explicit non-zero Thomas Monjalon
  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
  1 sibling, 2 replies; 6+ messages in thread
From: Burakov, Anatoly @ 2019-05-03 15:52 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev

On 03-May-19 4:35 PM, Thomas Monjalon wrote:
> 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>
> ---

Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>

-- 
Thanks,
Anatoly

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH] ipc: replace bool checks with explicit non-zero
  2019-05-03 15:52 ` Burakov, Anatoly
@ 2019-05-03 15:52   ` Burakov, Anatoly
  2019-05-03 17:30   ` Thomas Monjalon
  1 sibling, 0 replies; 6+ messages in thread
From: Burakov, Anatoly @ 2019-05-03 15:52 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev

On 03-May-19 4:35 PM, Thomas Monjalon wrote:
> 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>
> ---

Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>

-- 
Thanks,
Anatoly

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH] ipc: replace bool checks with explicit non-zero
  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
  1 sibling, 1 reply; 6+ messages in thread
From: Thomas Monjalon @ 2019-05-03 17:30 UTC (permalink / raw)
  To: Burakov, Anatoly; +Cc: dev

03/05/2019 17:52, Burakov, Anatoly:
> On 03-May-19 4:35 PM, Thomas Monjalon wrote:
> > 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>
> 
> Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>

Applied

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH] ipc: replace bool checks with explicit non-zero
  2019-05-03 17:30   ` Thomas Monjalon
@ 2019-05-03 17:30     ` Thomas Monjalon
  0 siblings, 0 replies; 6+ messages in thread
From: Thomas Monjalon @ 2019-05-03 17:30 UTC (permalink / raw)
  To: Burakov, Anatoly; +Cc: dev

03/05/2019 17:52, Burakov, Anatoly:
> On 03-May-19 4:35 PM, Thomas Monjalon wrote:
> > 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>
> 
> Acked-by: Anatoly Burakov <anatoly.burakov@intel.com>

Applied




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-05-03 17:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-03 15:35 [dpdk-dev] [PATCH] ipc: replace bool checks with explicit non-zero Thomas Monjalon
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

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).