From: Stephen Hemminger <stephen@networkplumber.org>
To: harry.van.haaren@intel.com
Cc: dev@dpdk.org, Stephen Hemminger <stephen@networkplumber.org>
Subject: [dpdk-dev] [PATCH] service: print errors to rte log
Date: Tue, 20 Aug 2019 16:32:56 -0700 [thread overview]
Message-ID: <20190820233256.27405-1-stephen@networkplumber.org> (raw)
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.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
lib/librte_eal/common/rte_service.c | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/lib/librte_eal/common/rte_service.c b/lib/librte_eal/common/rte_service.c
index c3653ebae46c..aa2f8f3ef4b1 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)
{
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,16 @@ 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 +112,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 +123,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;
}
--
2.20.1
next reply other threads:[~2019-08-20 23:33 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-20 23:32 Stephen Hemminger [this message]
2019-08-21 8:58 ` Van Haaren, Harry
2019-08-21 9:12 ` [dpdk-dev] [PATCH v2] " Harry van Haaren
2019-10-15 18:40 ` 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=20190820233256.27405-1-stephen@networkplumber.org \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
--cc=harry.van.haaren@intel.com \
/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).