nullability of status parameter in strtoi/u(3)

Alejandro Colomar <[email protected]> Thu, 20 Mar 2025 00:52:08 +0100
Newsgroups gmane.os.netbsd.devel.general
Message-ID <cvznjifkgadqtu3ihsk4eelfrcfr7logqqqpjet7jazda44rju@2qc4lpuj35jr>
--bx2lvtvstzxal6ko
Content-Type: text/plain; protected-headers=v1; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
From: Alejandro Colomar <[email protected]>
To: Bruno Haible <[email protected]>
Cc: [email protected], [email protected], 
	[email protected], [email protected], christos <[email protected]>, 
	=?utf-8?B?xJBvw6BuIFRy4bqnbiBDw7RuZw==?= Danh <[email protected]>, Paul Eggert <[email protected]>, 
	Eli Schwartz <[email protected]>, Guillem Jover <[email protected]>, 
	Iker Pedrosa <[email protected]>, Michael Vetter <[email protected]>, Robert Elz <[email protected]>, 
	[email protected], Sam James <[email protected]>, "Serge E. Hallyn" <[email protected]>
Subject: nullability of status parameter in strtoi/u(3)
References: <mgcfwxfmv3kpfnkkf6uj63kx5tdzl64p2zg2us4ntsu6q5xkwj@k52z5yyiywoo>
 <3237498.fEcJ0Lxnt5@nimes>
 <jx4664ishtl34eg2npdrv5fkfdiczqnlq3vjuacjrupjvh377x@gddcftzgwmfq>
 <4085563.2iPT33SAM4@nimes>
 <x34jdlyb6gf6asojjhzwpol5schyz4llk2ebrtzpb7ryje52u6@smbvzpoqcf6v>
MIME-Version: 1.0
In-Reply-To: <x34jdlyb6gf6asojjhzwpol5schyz4llk2ebrtzpb7ryje52u6@smbvzpoqcf6v>

Hi Bruno,

On Thu, Mar 20, 2025 at 12:12:10AM +0100, Alejandro Colomar wrote:
> > > > > >   -b. status =3D=3D 0 || status =3D=3D ENOTSUP || status =3D=3D=
 ERANGE
> > > > >=20
> > > > > Correct (but most likely a bug).
> > >=20
> > > Actually, now I remember that status can be NULL, in which case it's =
not
> > > reported.  This is a case where you could check for errors with a
> > > simpler expression:
> > >=20
> > > 	end !=3D str
> > >=20
> > > but (status =3D=3D 0 || status =3D=3D ENOTSUP || status =3D=3D ERANGE=
) is still a
> > > reasnoable one.
> >=20
> > Unfortunately, with a comment like this, you make things more complicat=
ed,
> > not simpler. I was hoping for an API where success can be determined by
> > looking at 'status' in all four cases, and the "simple" solution that y=
ou
> > are recommending now is:
> >   -a. look at status
> >   -b. look at end
> >   -c. look at status
> >   -d. look at status AND end.
> >=20
> > > I need to update the specification to mention that status can be NULL.
> >=20
> > Why do so? This adds text to the specification, making the specification
> > more complex (=3D> longer to understand, harder to remember). The abili=
ty
> > to pass NULL for rstatus is not a useful feature.
>=20
> Hmmm, in Debian, there's exactly one place where this happens, and it's
> a test case, so I guess it's fine if we break it.
>=20
> <https://sources.debian.org/src/mk-configure/0.37.0-2/tests/mkc_features/=
tool/test_features1.cxx/?hl=3D118#L118>
>=20
> And there are 0 such calls in NetBSD trunk:
>=20
> alx@devuan:~/src/bsd/netbsd/trunk$ find -type f \
> 	| grep '\.[ch]$' \
> 	| xargs grep -l '\<strto[iu]\>' \
> 	| xargs pcre2grep -Mn '(?s)\bstrto[iu] *\([^;]*(NULL|0)\)';
>=20
> So we could tighten the specification to require a non-null pointer.
> I would be okay with that.

I've reported this to NetBSD.  Let's see what they think about it.
<https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=3D59199>


Have a lovely night!
Alex

--=20
<https://www.alejandro-colomar.es/>

--bx2lvtvstzxal6ko
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEES7Jt9u9GbmlWADAi64mZXMKQwqkFAmfbWKEACgkQ64mZXMKQ
wqmb4hAAq0eV4cCA6jbKKtnGJWGrFb+ytI9OsT3TaikkXp4PXQoiEvvz8btX3e15
kgYhAR9Bhek1H2VfbP9wXxEhLa/Z31LSOC/Ds6cl/x6ODZ5ZdY6QiIyQr5s+2iFT
RBoLXPYDOzKOKMV4bjkrXvILl6brYZ8jEQrlfmOT+/luuPHSM3rqHHP4N7DJ3Cn/
tBZMiULwFTpfL+01OYA3XFmkOoGpEQFZOUvV9N+0SgITYNaTvXJc32fmBkhOZLTd
onS5muoEGmS9yTAagcMNTqNffy1SONSstA5C+L84rQnTfafh5fFnTUp2YC+7JjZE
DSrKfcUEgZQ3AHdqVNwUV1rmo5MY1wSqobUk7VBYAQ9yZHsGJNzGvJCJ7YAJ1bvq
sVnRtpkSCHvzziPibFQHs75wouke0XwG8xXlEXx2wYxlzC/XY3lTEtElUHgo3hav
3Jq+BWfXeENP09ZpG6AGgZZR7uEuvPhummEN2qlicCy94RGAKh1hnCyAJsw03erM
qGuSrJEEKvd6vT0ez3l427mhhsUWzOHhycRH5qJgmyTdVhWVxufhRiaSpBzSlTmh
HfIgR1GPb9YJfDT2Q2Ihq44dAU0K20jyOv4BPHEw4PL46/H1VIvf0DJhU5W5WWpZ
zd8GbtBCfsDWW0ZnSrGcaaLfJqXKGF+4DuxXKVSKn0hyJjAc55g=
=amfM
-----END PGP SIGNATURE-----

--bx2lvtvstzxal6ko--