[dpdk-dev] [PATCH] kvargs: trim spaces at the beginning and end of key and values

Stephen Hemminger stephen at networkplumber.org
Fri May 17 01:18:35 CEST 2019


On Thu, 16 May 2019 20:55:10 +0000
"Ergin, Mesut A" <mesut.a.ergin at intel.com> wrote:

> > -----Original Message-----
> > From: Stephen Hemminger [mailto:stephen at networkplumber.org]
> > Sent: Thursday, May 16, 2019 9:37 AM
> > To: Ergin, Mesut A <mesut.a.ergin at intel.com>
> > Cc: olivier.matz at 6wind.com; dev at dpdk.org
> > Subject: Re: [dpdk-dev] [PATCH] kvargs: trim spaces at the beginning and end of
> > key and values
> > 
> > On Wed, 15 May 2019 22:41:07 -0700
> > Mesut Ali Ergin <mesut.a.ergin at intel.com> wrote:
> >   
> > > +/* trim leading and trailing spaces */
> > > +static char *
> > > +trim_space(char *str)
> > > +{
> > > +	char *start, *end;
> > > +
> > > +	for (start = str; *start; start++) {
> > > +		if (!isspace((unsigned char) start[0]))
> > > +			break;
> > > +	}
> > > +
> > > +	for (end = start + strlen(start); end > start + 1; end--) {
> > > +		if (!isspace((unsigned char) end[-1]))
> > > +			break;
> > > +	}
> > > +  
> > 
> > Why not use existing string functions like strspn?  
> 
> Had no particular reason not to use strspn. This was in use/tested in two apps shipping already, and I took the easy route. I could modify if you think it will be better.

writing your own string handling code is often a source of bugs


More information about the dev mailing list