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 8E83DA046B for ; Wed, 21 Aug 2019 01:33:15 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BB3821BED0; Wed, 21 Aug 2019 01:33:14 +0200 (CEST) Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by dpdk.org (Postfix) with ESMTP id 0CF751BECE for ; Wed, 21 Aug 2019 01:33:11 +0200 (CEST) Received: by mail-pg1-f193.google.com with SMTP id n4so198048pgv.2 for ; Tue, 20 Aug 2019 16:33:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=dom/VX79BaNlTG88SAOw0CprRwX/vPZB4CEMb+tx5ag=; b=RbUM2K+I0Xo/11ETp0O55+QsIM5Qd4Sz/uUWuQ4LlpCCqLHUJ/wv6EeDQAb65LshyN QWJy/g3iQybAkX8JD6Mto/MZCQ6qnAuhwWiyQ3T9Io0rmElf4b6M4AZZYTv8AgCM+OMQ eBZwSGaO5VnsO8c5nzOP2YVDCQzSpRd6KONCa0ibSZUQ6iimzR8dMI77IGJCejpoLaX5 /TSE9ST7l4rnpf+SdWbp6DccJkNKR17qFpLK85ymxKtN30XwEAPCg0elq3NH+XUrx51E ccL5RvocT8ogHI6LWa6MNX6oNcecVbAgNBaEJHY+XL+Wad6pTALSI09BpKTpoZZfExup aLZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=dom/VX79BaNlTG88SAOw0CprRwX/vPZB4CEMb+tx5ag=; b=g11FMf7qBuFzVCFBZcSF6NOZBsK4mUsoRwdmhS75nDYLSN0TmHdt8+4zl1+9PYEBrn Rt0e/e/Im52/gMCXTF+lISAnbmsWgKRRY9G+hHF44ikiSX4Dxb25vCfQDac4Xr8kEiNn V9q95Aa9fIRVdEvVEyfVJRPFHoLnZ0Ry4KZL+fLy7Ie4zGrHsHLpiLr/D8e4CRQm0Q4q dnB6uBz6IfEAjIzDn5slnt51BRAxZFSm8eky1kQPVMtBgH/5pif2rUfUH5IwGyfuFuvy +JKbfbDVycSPUnGirmuPK0A0fb949ed0XyDEVuzFwJ44lXburdDOFUBe2Y/1prO+ymdA IWeg== X-Gm-Message-State: APjAAAVCbiTA6gkFMRRYVDdANpqgmRA592yPfw2E38G8m1w6/lMN2YNk /6R3eSRxTznahI0vDiL4Nh/3lQ== X-Google-Smtp-Source: APXvYqx54En7G9vLCJt0p/iOw3wA83euVn3qaP4HKGp7zv6kpj5F1vd+veI8/Ov5AH+hWm/E9DXZWQ== X-Received: by 2002:a65:534c:: with SMTP id w12mr26894460pgr.51.1566343990872; Tue, 20 Aug 2019 16:33:10 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id z189sm15692621pfb.137.2019.08.20.16.33.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2019 16:33:09 -0700 (PDT) From: Stephen Hemminger To: harry.van.haaren@intel.com Cc: dev@dpdk.org, Stephen Hemminger Date: Tue, 20 Aug 2019 16:32:56 -0700 Message-Id: <20190820233256.27405-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH] 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" 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 --- 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