From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 04A414CC5 for ; Fri, 30 Jun 2017 11:44:38 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Jun 2017 02:44:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,285,1496127600"; d="scan'208";a="1146433504" Received: from bricha3-mobl3.ger.corp.intel.com ([10.237.221.28]) by orsmga001.jf.intel.com with SMTP; 30 Jun 2017 02:44:35 -0700 Received: by (sSMTP sendmail emulation); Fri, 30 Jun 2017 10:44:35 +0100 Date: Fri, 30 Jun 2017 10:44:34 +0100 From: Bruce Richardson To: Jacek Piasecki Cc: dev@dpdk.org, deepak.k.jain@intel.com Message-ID: <20170630094434.GA14776@bricha3-MOBL3.ger.corp.intel.com> References: <1498474759-102089-2-git-send-email-jacekx.piasecki@intel.com> <1498559210-104084-1-git-send-email-jacekx.piasecki@intel.com> <1498559210-104084-2-git-send-email-jacekx.piasecki@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1498559210-104084-2-git-send-email-jacekx.piasecki@intel.com> Organization: Intel Research and =?iso-8859-1?Q?De=ACvel?= =?iso-8859-1?Q?opment?= Ireland Ltd. User-Agent: Mutt/1.8.1 (2017-04-11) Subject: Re: [dpdk-dev] [PATCH v3 1/4] 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: , X-List-Received-Date: Fri, 30 Jun 2017 09:44:39 -0000 On Tue, Jun 27, 2017 at 12:26:47PM +0200, Jacek Piasecki wrote: > This patch removes the dependency to EAL in cfgfile library. > > Signed-off-by: Jacek Piasecki > --- > lib/librte_cfgfile/Makefile | 1 + > lib/librte_cfgfile/rte_cfgfile.c | 29 +++++++++++++++++------------ > 2 files changed, 18 insertions(+), 12 deletions(-) > > 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 b54a523..c6ae3e3 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; This check for NULL is not needed, as earlier in the function we find the following: if (buffer[0] != '[' && memchr(buffer, '=', len) == NULL) continue; which means that there must be an "=" in buffer by the time we get to this line. > } else { FYI, you don't need an else after a goto. Save indentation where we can! :-) /Bruce