From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 0B9B6A0AC5 for ; Fri, 3 May 2019 17:36:03 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8D0B85F13; Fri, 3 May 2019 17:36:01 +0200 (CEST) Received: from out5-smtp.messagingengine.com (out5-smtp.messagingengine.com [66.111.4.29]) by dpdk.org (Postfix) with ESMTP id AC9392C6A for ; Fri, 3 May 2019 17:36:00 +0200 (CEST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 4269E20D84; Fri, 3 May 2019 11:36:00 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Fri, 03 May 2019 11:36:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=monjalon.net; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=mesmtp; bh=FH+r3n4+Pqtp2oIu4MFtobW z/w6pR3zDNfGXIWGOvL4=; b=JSDYPdEGg5G8pOXwXclyktAObP9Igz29WbnZmij CCwtCrieVopTJkQOjeOWRy0e56g9KxDhx9EK6WcxA8C+bIF0qno1HU0QBZFx3EDE FkhOWtoa8kETHEwhQxfcnExleiQfL/ECc2OP7ErhLKPYTlcF3U/WCrTv/GBDi3Ij Ol2I= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=FH+r3n4+Pqtp2oIu4 MFtobWz/w6pR3zDNfGXIWGOvL4=; b=eOj5EHKJ+Am9m0rqoqBjeVRRmbWGTri+f BYDlNbgpUU1ZTJDJpDYMHebXkpEWc0GhBLdCCqIAWKGS45y5W3qST2kf2QkHLbqy Vr03cCBtPWwuEuttrbVNlZ+oTDouHr5gvEoEc0Nm/BgytiBbpq0aS3VjaY2HjOGx B3ZXYkVFxj8WQ/SuQ4qWE5CTsBR+niQAwd7n7nOKq2q4IiQSLmdxLMaQnJ3LuHHf 8V9/fTjP3LKUspk2HNIDZWbCZBx9S/rFldeOy5gExKWIXXYNsWuvASEjbjVCDM4H okJYZPG3f7kUITSJXz86xBkU8v9fWSW7JPVmnIyyNZsQezBIzeb6g== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrjedugdelhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffoggfgsedtkeertdertd dtnecuhfhrohhmpefvhhhomhgrshcuofhonhhjrghlohhnuceothhhohhmrghssehmohhn jhgrlhhonhdrnhgvtheqnecukfhppeejjedrudefgedrvddtfedrudekgeenucfrrghrrg hmpehmrghilhhfrhhomhepthhhohhmrghssehmohhnjhgrlhhonhdrnhgvthenucevlhhu shhtvghrufhiiigvpedt X-ME-Proxy: Received: from xps.monjalon.net (184.203.134.77.rev.sfr.net [77.134.203.184]) by mail.messagingengine.com (Postfix) with ESMTPA id 2D635103D9; Fri, 3 May 2019 11:35:59 -0400 (EDT) From: Thomas Monjalon To: anatoly.burakov@intel.com Cc: dev@dpdk.org Date: Fri, 3 May 2019 17:35:39 +0200 Message-Id: <20190503153539.17993-1-thomas@monjalon.net> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] ipc: replace bool checks with explicit non-zero X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Content-Type: text/plain; charset="UTF-8" Message-ID: <20190503153539.YrcLxYTQyPgBQnO46AJeDwDF_wem1GtmyvWZ1us1OvM@z> 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 --- 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