From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id B12D0A046B for ; Wed, 21 Aug 2019 11:11:23 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DF5971BEEB; Wed, 21 Aug 2019 11:11:22 +0200 (CEST) Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id 653AD1BEEA for ; Wed, 21 Aug 2019 11:11:20 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Aug 2019 02:11:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,412,1559545200"; d="scan'208";a="178446851" Received: from silpixa00399779.ir.intel.com (HELO silpixa00399779.ger.corp.intel.com) ([10.237.222.100]) by fmsmga008.fm.intel.com with ESMTP; 21 Aug 2019 02:11:18 -0700 From: Harry van Haaren To: dev@dpdk.org Cc: Stephen Hemminger , Harry van Haaren Date: Wed, 21 Aug 2019 10:12:52 +0100 Message-Id: <20190821091252.39705-1-harry.van.haaren@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190820233256.27405-1-stephen@networkplumber.org> References: <20190820233256.27405-1-stephen@networkplumber.org> Subject: [dpdk-dev] [PATCH v2] service: print errors to rte log 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" From: Stephen Hemminger 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 Signed-off-by: Harry van Haaren Acked-by: Harry van Haaren --- 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