From patchwork Tue Sep 19 10:25:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kuba Kozak X-Patchwork-Id: 28941 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 8ADA41E34; Tue, 19 Sep 2017 12:41:28 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id B0AD8101B for ; Tue, 19 Sep 2017 12:41:26 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Sep 2017 03:41:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.42,417,1500966000"; d="scan'208"; a="1173678486" Received: from unknown (HELO Sent) ([10.103.102.91]) by orsmga001.jf.intel.com with SMTP; 19 Sep 2017 03:41:22 -0700 Received: by Sent (sSMTP sendmail emulation); Tue, 19 Sep 2017 12:32:39 +0200 From: Kuba Kozak To: dev@dpdk.org Cc: bruce.richardson@intel.com, deepak.jain@intel.com, michalx.k.jastrzebski@intel.com, jacekx.piasecki@intel.com Date: Tue, 19 Sep 2017 12:25:46 +0200 Message-Id: <1505816750-19056-2-git-send-email-kubax.kozak@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1505816750-19056-1-git-send-email-kubax.kozak@intel.com> References: <1505816750-19056-1-git-send-email-kubax.kozak@intel.com> Subject: [dpdk-dev] [PATCH v5 1/5] cfgfile: remove EAL dependency 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: Jacek Piasecki This patch removes the dependency to EAL in cfgfile library. Signed-off-by: Jacek Piasecki Acked-by: Bruce Richardson --- lib/Makefile | 3 +-- lib/librte_cfgfile/Makefile | 1 + lib/librte_cfgfile/rte_cfgfile.c | 29 +++++++++++++++++------------ 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/lib/Makefile b/lib/Makefile index 86caba1..1080a95 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -32,6 +32,7 @@ include $(RTE_SDK)/mk/rte.vars.mk DIRS-y += librte_compat +DIRS-$(CONFIG_RTE_LIBRTE_CFGFILE) += librte_cfgfile DIRS-$(CONFIG_RTE_LIBRTE_EAL) += librte_eal DIRS-$(CONFIG_RTE_LIBRTE_RING) += librte_ring DEPDIRS-librte_ring := librte_eal @@ -41,8 +42,6 @@ DIRS-$(CONFIG_RTE_LIBRTE_MBUF) += librte_mbuf DEPDIRS-librte_mbuf := librte_eal librte_mempool DIRS-$(CONFIG_RTE_LIBRTE_TIMER) += librte_timer DEPDIRS-librte_timer := librte_eal -DIRS-$(CONFIG_RTE_LIBRTE_CFGFILE) += librte_cfgfile -DEPDIRS-librte_cfgfile := librte_eal DIRS-$(CONFIG_RTE_LIBRTE_CMDLINE) += librte_cmdline DEPDIRS-librte_cmdline := librte_eal DIRS-$(CONFIG_RTE_LIBRTE_ETHER) += librte_ether diff --git a/lib/librte_cfgfile/Makefile b/lib/librte_cfgfile/Makefile index 755ef11..0bee43e 100644 --- a/lib/librte_cfgfile/Makefile +++ b/lib/librte_cfgfile/Makefile @@ -38,6 +38,7 @@ LIB = librte_cfgfile.a CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS) +CFLAGS += -I$(SRCDIR)/../librte_eal/common/include EXPORT_MAP := rte_cfgfile_version.map diff --git a/lib/librte_cfgfile/rte_cfgfile.c b/lib/librte_cfgfile/rte_cfgfile.c index 2588093..9dc25cc 100644 --- a/lib/librte_cfgfile/rte_cfgfile.c +++ b/lib/librte_cfgfile/rte_cfgfile.c @@ -36,7 +36,6 @@ #include #include #include -#include #include "rte_cfgfile.h" @@ -258,19 +257,25 @@ rte_cfgfile_load_with_params(const char *filename, int flags, struct rte_cfgfile_section *sect = cfg->sections[curr_section]; - int n; + char *split[2] = {NULL}; - n = rte_strsplit(buffer, sizeof(buffer), split, 2, '='); - if (flags & CFG_FLAG_EMPTY_VALUES) { - if ((n < 1) || (n > 2)) { - printf("Error at line %d - cannot split string, n=%d\n", - lineno, n); - goto error1; - } + split[0] = buffer; + split[1] = memchr(buffer, '=', len); + + /* when delimeter not found */ + if (split[1] == NULL) { + printf("Error at line %d - cannot " + "split string\n", lineno); + goto error1; } else { - if (n != 2) { - printf("Error at line %d - cannot split string, n=%d\n", - lineno, n); + /* when delimeter found */ + *split[1] = '\0'; + split[1]++; + + if (!(flags & CFG_FLAG_EMPTY_VALUES) && + (*split[1] == '\0')) { + printf("Error at line %d - cannot " + "split string\n", lineno); goto error1; } }