DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: "Legacy, Allain" <Allain.Legacy@windriver.com>
Cc: Gaetan Rivet <gaetan.rivet@6wind.com>,
	"dev@dpdk.org" <dev@dpdk.org>,
	Adrien Mazarguil <adrien.mazarguil@6wind.com>,
	Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
Subject: Re: [dpdk-dev] [PATCH 1/1] net/mlx4: add port parameter
Date: Fri, 10 Mar 2017 08:34:59 -0800	[thread overview]
Message-ID: <20170310083459.6c1aeac7@xeon-e3> (raw)
In-Reply-To: <70A7408C6E1BFB41B192A929744D8523968EC82E@ALA-MBC.corp.ad.wrs.com>

On Fri, 10 Mar 2017 16:24:32 +0000
"Legacy, Allain" <Allain.Legacy@windriver.com> wrote:

> The robustness of the strtoul() could be improved with something like the following to catch non-integer characters following the port number. 
> 
>     char *end = NULL;
>     tmp = strtoull(val, &end, 0);
>     if ((val[0] == '\0') || (end == NULL) || (*end != '\0') || (errno != 0))

Extra () no necessary here.
Also errno is not set unless the return value is ULLONG_MAX. It will be last
value.

Something like:
	tmp = strtoull(val, &end, 0);
	if (!*val || !*end || (tmp == ULLONG_MAX && errno))
...

       If  endptr  is  not  NULL,  strtoul()  stores  the address of the first
       invalid character in *endptr.  If there were no  digits  at  all,  str‐
       toul()  stores  the  original value of nptr in *endptr (and returns 0).
       In particular, if *nptr is not '\0' but **endptr is '\0' on return, the
       entire string is valid.
...

RETURN VALUE
       The strtoul() function returns either the result of the conversion  or,
       if  there  was  a leading minus sign, the negation of the result of the
       conversion represented as an unsigned value, unless the original  (non‐
       negated)  value  would  overflow; in the latter case, strtoul() returns
       ULONG_MAX and sets errno to ERANGE.  Precisely the same holds for  str‐
       toull() (with ULLONG_MAX instead of ULONG_MAX).

  reply	other threads:[~2017-03-10 16:35 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-03 15:40 Gaetan Rivet
2017-03-10 16:24 ` Legacy, Allain
2017-03-10 16:34   ` Stephen Hemminger [this message]
2017-03-10 17:11   ` Gaëtan Rivet
2017-03-10 17:49     ` Gaëtan Rivet
2017-03-11 11:32     ` Legacy, Allain
2017-03-16 11:04 ` Adrien Mazarguil
2017-03-20 13:24   ` Ferruh Yigit
2017-03-20 13:56     ` Adrien Mazarguil
2017-03-27 15:08 ` Ferruh Yigit
2017-03-27 15:46   ` Gaëtan Rivet
2017-03-27 15:41 ` [dpdk-dev] [PATCH v2 " Gaetan Rivet
2017-03-27 16:42   ` Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170310083459.6c1aeac7@xeon-e3 \
    --to=stephen@networkplumber.org \
    --cc=Allain.Legacy@windriver.com \
    --cc=adrien.mazarguil@6wind.com \
    --cc=dev@dpdk.org \
    --cc=gaetan.rivet@6wind.com \
    --cc=nelio.laranjeiro@6wind.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).