Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 21 Aug 2013 23:03:10 +0400
From:      Sergey Kandaurov <pluknet@freebsd.org>
To:        Andrey Chernov <ache@freebsd.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org
Subject:   Re: svn commit: r254600 - head/lib/libutil
Message-ID:  <20130821190309.GB52908@omg>
In-Reply-To: <5214F72B.7070006@freebsd.org>
References:  <201308211646.r7LGk6eV051215@svn.freebsd.org> <5214F72B.7070006@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--JwB53PgKC5A7+0Ej
Content-Type: multipart/mixed; boundary="KN5l+BnMqAQyZLvT"
Content-Disposition: inline


--KN5l+BnMqAQyZLvT
Content-Type: text/plain; charset=koi8-r
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Wed, Aug 21, 2013 at 09:21:47PM +0400, Andrey Chernov wrote:
> On 21.08.2013 20:46, Sergey Kandaurov wrote:
> >  	number =3D strtoumax(buf, &endptr, 0);
> > =20
> > +	if (number =3D=3D UINTMAX_MAX && errno =3D=3D ERANGE) {
> > +		return (-1);
> > +	}
>=20
> You need to reset errno before strtoumax() call (errno =3D 0), because any
> of previous functions may left it as ERANGE.
>=20

Thanks for pointing out.
Does the patch look good?

Index: expand_number.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- expand_number.c     (revision 254600)
+++ expand_number.c     (working copy)
@@ -53,6 +53,8 @@
        unsigned shift;
        char *endptr;
=20
+       errno =3D 0;
+
        number =3D strtoumax(buf, &endptr, 0);
=20
        if (number =3D=3D UINTMAX_MAX && errno =3D=3D ERANGE) {


--KN5l+BnMqAQyZLvT
Content-Type: text/x-diff; charset=koi8-r
Content-Disposition: attachment; filename="expand_number.diff"
Content-Transfer-Encoding: quoted-printable

Index: expand_number.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- expand_number.c	(revision 254600)
+++ expand_number.c	(working copy)
@@ -53,6 +53,8 @@
 	unsigned shift;
 	char *endptr;
=20
+	errno =3D 0;
+
 	number =3D strtoumax(buf, &endptr, 0);
=20
 	if (number =3D=3D UINTMAX_MAX && errno =3D=3D ERANGE) {

--KN5l+BnMqAQyZLvT--

--JwB53PgKC5A7+0Ej
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.20 (FreeBSD)

iQEcBAEBAgAGBQJSFQ7tAAoJED9Ol7oQYHQZzHIIAKD7AtePf4E8EH1Km53AnZMt
XPW5WxbmZleWNnLOWs+8+fd9if5zCDaa2//UlwTEO61KpeGJXIW9iGbPNAv79rWt
4zBfM1Q5lbZqaXEwNf+0+pENMTu6D5nhnPb5pEbdXm3nxT4K+ug93xy+dP11a/7A
MiCXWerPz1ic3cqaDxjdoQiWfToTf8lQlhy64lEJ5D6W1oJ4r3pUdg7cYP0mUTG9
4WQIbvbP7rv8DAH4j72fIoHjrYFtYYYIsFAMucwbGEiiqsX8y8C27KWeAAw4XrPW
0V1GerfANCN4kcyHQtNa9WQd2cFqJ7LADHO5hfPbqD5YGaIu1pv9H+Uerdf8ia8=
=F5Vq
-----END PGP SIGNATURE-----

--JwB53PgKC5A7+0Ej--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130821190309.GB52908>