DPDK patches and discussions
 help / color / mirror / Atom feed
From: Harry van Haaren <harry.van.haaren@intel.com>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
	Harry van Haaren <harry.van.haaren@intel.com>
Subject: [dpdk-dev] [PATCH v2] service: print errors to rte log
Date: Wed, 21 Aug 2019 10:12:52 +0100	[thread overview]
Message-ID: <20190821091252.39705-1-harry.van.haaren@intel.com> (raw)
In-Reply-To: <20190820233256.27405-1-stephen@networkplumber.org>

From: Stephen Hemminger <stephen@networkplumber.org>

EAL should always use rte_log instead of putting errors to
stderr (which maybe redirected to /dev/null in a daemon).

Also checks for null before rte_free are unnecessary.
Minor code consistency improvements.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
Acked-by: Harry van Haaren <harry.van.haaren@intel.com>
---
 lib/librte_eal/common/rte_service.c | 27 ++++++++++++---------------
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/lib/librte_eal/common/rte_service.c b/lib/librte_eal/common/rte_service.c
index c3653ebae..fe0907720 100644
--- a/lib/librte_eal/common/rte_service.c
+++ b/lib/librte_eal/common/rte_service.c
@@ -70,10 +70,12 @@ static struct rte_service_spec_impl *rte_services;
 static struct core_state *lcore_states;
 static uint32_t rte_service_library_initialized;
 
-int32_t rte_service_init(void)
+int32_t
+rte_service_init(void)
 {
 	if (rte_service_library_initialized) {
-		printf("service library init() called, init flag %d\n",
+		RTE_LOG(NOTICE, EAL,
+			"service library init() called, init flag %d\n",
 			rte_service_library_initialized);
 		return -EALREADY;
 	}
@@ -82,14 +84,14 @@ int32_t rte_service_init(void)
 			sizeof(struct rte_service_spec_impl),
 			RTE_CACHE_LINE_SIZE);
 	if (!rte_services) {
-		printf("error allocating rte services array\n");
+		RTE_LOG(ERR, EAL, "error allocating rte services array\n");
 		goto fail_mem;
 	}
 
 	lcore_states = rte_calloc("rte_service_core_states", RTE_MAX_LCORE,
 			sizeof(struct core_state), RTE_CACHE_LINE_SIZE);
 	if (!lcore_states) {
-		printf("error allocating core states array\n");
+		RTE_LOG(ERR, EAL, "error allocating core states array\n");
 		goto fail_mem;
 	}
 
@@ -108,10 +110,8 @@ int32_t rte_service_init(void)
 	rte_service_library_initialized = 1;
 	return 0;
 fail_mem:
-	if (rte_services)
-		rte_free(rte_services);
-	if (lcore_states)
-		rte_free(lcore_states);
+	rte_free(rte_services);
+	rte_free(lcore_states);
 	return -ENOMEM;
 }
 
@@ -121,11 +121,8 @@ rte_service_finalize(void)
 	if (!rte_service_library_initialized)
 		return;
 
-	if (rte_services)
-		rte_free(rte_services);
-
-	if (lcore_states)
-		rte_free(lcore_states);
+	rte_free(rte_services);
+	rte_free(lcore_states);
 
 	rte_service_library_initialized = 0;
 }
@@ -397,8 +394,8 @@ rte_service_may_be_active(uint32_t id)
 	return 0;
 }
 
-int32_t rte_service_run_iter_on_app_lcore(uint32_t id,
-		uint32_t serialize_mt_unsafe)
+int32_t
+rte_service_run_iter_on_app_lcore(uint32_t id, uint32_t serialize_mt_unsafe)
 {
 	/* run service on calling core, using all-ones as the service mask */
 	if (!service_valid(id))
-- 
2.17.1


  parent reply	other threads:[~2019-08-21  9:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-20 23:32 [dpdk-dev] [PATCH] " Stephen Hemminger
2019-08-21  8:58 ` Van Haaren, Harry
2019-08-21  9:12 ` Harry van Haaren [this message]
2019-10-15 18:40   ` [dpdk-dev] [PATCH v2] " David Marchand

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=20190821091252.39705-1-harry.van.haaren@intel.com \
    --to=harry.van.haaren@intel.com \
    --cc=dev@dpdk.org \
    --cc=stephen@networkplumber.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).