From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f180.google.com (mail-pf0-f180.google.com [209.85.192.180]) by dpdk.org (Postfix) with ESMTP id 246462C01 for ; Fri, 10 Mar 2017 17:35:02 +0100 (CET) Received: by mail-pf0-f180.google.com with SMTP id j5so43683241pfb.2 for ; Fri, 10 Mar 2017 08:35:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lKDOuDggL3y1kSmU/oC9YAFVh7jQWECdwjTjIWdGcM8=; b=jCIeVUAg640Yw1NJDMyyHARTIe/P0Xwqti3u30OEhEId5tYM/++wrWdpGAgdlhkhQA cuzkTX2ycZM2h49iFJsGWXP1EO023uH5uEJIJyGWEqaqGI2ln8XN2yt67gr6n5HwHt8m rERU3fq8iikxzjXtlr6ZSPNoFuM6oykyMlLqwf/+to8L1a8LVaNFPFaYIXKausNzzSm3 C92NAPOf0C3BD4S0zCK3ufUai4AyTj5YLIumiq2YMRx4bjK88O/5aZIMf/BQwHKBo0NM s0QAHkXJNX0iEbHWeSiC2mEX7AeTJwvKTwleTu9eg9myXMldcaJhFDbWoydX4LdzK5Zv FQ5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=lKDOuDggL3y1kSmU/oC9YAFVh7jQWECdwjTjIWdGcM8=; b=haLWr2d653MbqQI7Sipa7WEPf1e7ram9J4rsHqpsT+/m+QnSVh3wptEVoTzMW7NmUc T1wrN0cZDlx7KvggyU6u+U2E2r6dZoYJvDrhGPIapmooHpfZSBWe+MqxeHObo7KL4Qd+ 2jQBib4q9nMDCzBQ3JipGDw9c3a60LarjPNtSSBu2BQl5q9w5Uh/rSXOAQPsHLGG2orY wPsc9BU5HKY3e/wPODnKmk4+tU7R2T+X/YKf1GnTAfAuSmsQpq+qS/6iTPoH75Ag14lL +HM+HoD2whsrW/uzLwtYi4+brio4mFaGNoDLjiMU9UIBl7woIk7B2tNxYT5Y2+sALIdY 1vDQ== X-Gm-Message-State: AMke39mor8ojkpCRVoErpVDwyAHsrQ7A/2wv1QALwQgxs/akWIRybf3TPLkNcioBOtis7w== X-Received: by 10.98.5.2 with SMTP id 2mr22418061pff.77.1489163701310; Fri, 10 Mar 2017 08:35:01 -0800 (PST) Received: from xeon-e3 (204-195-18-65.wavecable.com. [204.195.18.65]) by smtp.gmail.com with ESMTPSA id a16sm19757582pgd.62.2017.03.10.08.35.00 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 10 Mar 2017 08:35:01 -0800 (PST) Date: Fri, 10 Mar 2017 08:34:59 -0800 From: Stephen Hemminger To: "Legacy, Allain" Cc: Gaetan Rivet , "dev@dpdk.org" , Adrien Mazarguil , Nelio Laranjeiro Message-ID: <20170310083459.6c1aeac7@xeon-e3> In-Reply-To: <70A7408C6E1BFB41B192A929744D8523968EC82E@ALA-MBC.corp.ad.wrs.com> References: <70A7408C6E1BFB41B192A929744D8523968EC82E@ALA-MBC.corp.ad.wrs.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [dpdk-dev] [PATCH 1/1] net/mlx4: add port parameter 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, 10 Mar 2017 16:35:02 -0000 On Fri, 10 Mar 2017 16:24:32 +0000 "Legacy, Allain" wrote: > The robustness of the strtoul() could be improved with something like the= following to catch non-integer characters following the port number.=20 >=20 > char *end =3D NULL; > tmp =3D strtoull(val, &end, 0); > if ((val[0] =3D=3D '\0') || (end =3D=3D NULL) || (*end !=3D '\0') || = (errno !=3D 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 =3D strtoull(val, &end, 0); if (!*val || !*end || (tmp =3D=3D ULLONG_MAX && errno)) ... If endptr is not NULL, strtoul() stores the address of the fi= rst invalid character in *endptr. If there were no digits at all, s= tr=E2=80=90 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 (n= on=E2=80=90 negated) value would overflow; in the latter case, strtoul() retu= rns ULONG_MAX and sets errno to ERANGE. Precisely the same holds for s= tr=E2=80=90 toull() (with ULLONG_MAX instead of ULONG_MAX).