Subject: Re: disklabeling a 1.7 TB disk
To: None <>
From: Christian Biere <>
List: current-users
Date: 02/29/2004 01:11:02
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:
> > > 	more error check to strtoul().
> 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().
> > > +	u_int32_t m;							\
> > Wouldn't it be better to use uintmax_t here?
> 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
> > unsigned long isn't necessarily an alias for u_int32_t and strtoul() ha=
> > accepts negative values.
> true, but does it matter?

It matters depending on the disks and architectures you use and whether
you enjoy to be punished for typos.
> > Hmm, if it's save to assume (errno =3D=3D 0) in case of a successful st=
> > 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=
> 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?
> 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.

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?

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

Version: GnuPG v1.2.4 (NetBSD)