Subject: Re: disklabeling a 1.7 TB disk
To: None <current-users@netbsd.org>
From: Christian Biere <christianbiere@gmx.de>
List: current-users
Date: 02/29/2004 01:11:02
--MW5yreqqjyrRcusr
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

David Laight wrote:
> On Sat, Feb 28, 2004 at 11:59:23PM +0100, Christian Biere wrote:
> > Jun-ichiro itojun Hagino wrote:
=20
> > > 	more error check to strtoul().
=20
> Not really worth the effort.....

What effort? You only see effort here because such crap as atoi() and
atol() exist. If you use your favorite stroul() wrapper there's not
any more effort as atoi().
=20
> > > +	u_int32_t m;							\
=20
> > Wouldn't it be better to use uintmax_t here?
=20
> The values are being written into fields defined as u_int32_t....

So too large values should be ignored for the benefit of saving CPU
cycles?
=20
> > unsigned long isn't necessarily an alias for u_int32_t and strtoul() ha=
ppily
> > accepts negative values.
=20
> true, but does it matter?

It matters depending on the disks and architectures you use and whether
you enjoy to be punished for typos.
=20
> > Hmm, if it's save to assume (errno =3D=3D 0) in case of a successful st=
rtoul()
> > you might want to shorten the other checks to "errno" instead of
> > "errno =3D=3D ERANGE". Otherwise, I'd change this to "errno !=3D ERANGE=
".
=20
> Or if you are willing to say '*cp && ptr', why not '!*ptr && !errno' ?

Well, because it would allow "" as input. Also strtoul(ptr, &ptr, 10) looks
to me. Nowhere is specified what happens to *endptr between entering
strtoul() and before setting it to the final value. Wouldn't it be
perfectly valid to set it to NULL at the begin?
=20
> In any case the point of teh fix was to allow numbers between 2^31 and
> 2^32-1 to be input, not to fix the error checking.

Well, if you want to fix the same old problem everytime it slaps you
in the face, rather than once and for all that's fine as well.

--=20
Christian
=20
As you can see, this a signature. It's not related to the contents of the
mail in any way. But you probably won't listen to me anyway, will you?

--MW5yreqqjyrRcusr
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (NetBSD)

iD8DBQFAQS4W0KQix3oyIMcRAtHdAKC+VT/MUQZLRAng3CQpgrQiqJ/rawCbBlep
ErfqyhOv/4UZLgzyoUT9614=
=gY+Q
-----END PGP SIGNATURE-----

--MW5yreqqjyrRcusr--