2003-08-18 00:46:32

by Jamie Lokier

[permalink] [raw]
Subject: [PATCH] use simple_strtoul for unsigned kernel parameters

The largest "unsigned int" value doesn't fit in a "long", on many machines.
So we should use simple_strtoul, not simple_strtol, to decode these values.

Enjoy,
-- Jamie

--- orig-2.5.75/kernel/params.c 2003-07-08 21:44:26.000000000 +0100
+++ laptop-2.5.75/kernel/params.c 2003-08-17 03:17:40.116594605 +0100
@@ -165,9 +165,9 @@
}

STANDARD_PARAM_DEF(short, short, "%hi", long, simple_strtol);
-STANDARD_PARAM_DEF(ushort, unsigned short, "%hu", long, simple_strtol);
+STANDARD_PARAM_DEF(ushort, unsigned short, "%hu", unsigned long, simple_strtoul);
STANDARD_PARAM_DEF(int, int, "%i", long, simple_strtol);
-STANDARD_PARAM_DEF(uint, unsigned int, "%u", long, simple_strtol);
+STANDARD_PARAM_DEF(uint, unsigned int, "%u", unsigned long, simple_strtoul);
STANDARD_PARAM_DEF(long, long, "%li", long, simple_strtol);
STANDARD_PARAM_DEF(ulong, unsigned long, "%lu", unsigned long, simple_strtoul);


2003-08-18 10:15:25

by Rusty Russell

[permalink] [raw]
Subject: Re: [PATCH] use simple_strtoul for unsigned kernel parameters

In message <[email protected]> you write:
> The largest "unsigned int" value doesn't fit in a "long", on many machines.
> So we should use simple_strtoul, not simple_strtol, to decode these values.

Half right. The second part is fine, the first part is redundant
AFAICT.

Rusty.

> Enjoy,
> -- Jamie
>
> --- orig-2.5.75/kernel/params.c 2003-07-08 21:44:26.000000000 +0100
> +++ laptop-2.5.75/kernel/params.c 2003-08-17 03:17:40.116594605 +0100
> @@ -165,9 +165,9 @@
> }
>
> STANDARD_PARAM_DEF(short, short, "%hi", long, simple_strtol);
> -STANDARD_PARAM_DEF(ushort, unsigned short, "%hu", long, simple_strtol);
> +STANDARD_PARAM_DEF(ushort, unsigned short, "%hu", unsigned long, simple_strtoul);
> STANDARD_PARAM_DEF(int, int, "%i", long, simple_strtol);
> -STANDARD_PARAM_DEF(uint, unsigned int, "%u", long, simple_strtol);
> +STANDARD_PARAM_DEF(uint, unsigned int, "%u", unsigned long, simple_strtoul);
> STANDARD_PARAM_DEF(long, long, "%li", long, simple_strtol);
> STANDARD_PARAM_DEF(ulong, unsigned long, "%lu", unsigned long, simple_strtoul);
>

--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

2003-08-18 12:11:00

by Jamie Lokier

[permalink] [raw]
Subject: Re: [PATCH] use simple_strtoul for unsigned kernel parameters

Rusty Russell wrote:
> In message <[email protected]> you write:
> > The largest "unsigned int" value doesn't fit in a "long", on many machines.
> > So we should use simple_strtoul, not simple_strtol, to decode these values.
>
> Half right. The second part is fine, the first part is redundant

Do you mean the first part of the comment or the first part of the patch?

Assuming you mean the patch, you're right: the unsigned short case
doesn't need to be changed. It should be anyway because it is just
the right thing to do.

-- Jamie

2003-08-18 15:20:36

by Linus Torvalds

[permalink] [raw]
Subject: Re: [PATCH] use simple_strtoul for unsigned kernel parameters


On Mon, 18 Aug 2003, Rusty Russell wrote:
>
> Half right. The second part is fine, the first part is redundant
> AFAICT.

Well, in theory short/int/long can all be the same size and thus a
"unsigned short" may not actually fit in a "long". I think that was the
case on the old 64-bit cray machines, for example ("char" was a very slow
8-bit thing, everything else was purely 64-bit).

Not likely something we want to port Linux to, admittedly.

Linus

2003-08-18 15:31:20

by Jamie Lokier

[permalink] [raw]
Subject: Re: [PATCH] use simple_strtoul for unsigned kernel parameters

Linus Torvalds wrote:
> On Mon, 18 Aug 2003, Rusty Russell wrote:
> > Half right. The second part is fine, the first part is redundant
> > AFAICT.
>
> Well, in theory short/int/long can all be the same size and thus a
> "unsigned short" may not actually fit in a "long". I think that was the
> case on the old 64-bit cray machines, for example ("char" was a very slow
> 8-bit thing, everything else was purely 64-bit).

There's the SHARC and C4x architectures, where "char" is 32 bits, the
same as "short", "int" and "long".

-- Jamie

2003-08-18 15:36:34

by Rusty Russell

[permalink] [raw]
Subject: Re: [PATCH] use simple_strtoul for unsigned kernel parameters

In message <[email protected]> you write:
> Rusty Russell wrote:
> > In message <[email protected]> you write:
> > > The largest "unsigned int" value doesn't fit in a "long", on many machines.
> > > So we should use simple_strtoul, not simple_strtol, to decode these values.
> >
> > Half right. The second part is fine, the first part is redundant
>
> Do you mean the first part of the comment or the first part of the patch?
>
> Assuming you mean the patch, you're right: the unsigned short case
> doesn't need to be changed. It should be anyway because it is just
> the right thing to do.

<shrug>. Linus took the patch. If you think it's the Right Thing,
great.

Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.

2003-08-18 16:43:53

by Alan

[permalink] [raw]
Subject: Re: [PATCH] use simple_strtoul for unsigned kernel parameters

On Llu, 2003-08-18 at 16:20, Linus Torvalds wrote:
> Well, in theory short/int/long can all be the same size and thus a
> "unsigned short" may not actually fit in a "long". I think that was the
> case on the old 64-bit cray machines, for example ("char" was a very slow
> 8-bit thing, everything else was purely 64-bit).
>
> Not likely something we want to port Linux to, admittedly.

Bear in mind we have the compiler source 8). If someone desperately
wants to run Linux (probably ucLinux) on their cray they can fix the
types too.

Things like the DEC10 (9,18,36 bit) and HLH Orion (word addressed) would
be a lot more fun but thankfully are extinct


2003-08-18 17:07:04

by John Bradford

[permalink] [raw]
Subject: Re: [PATCH] use simple_strtoul for unsigned kernel parameters

> > Well, in theory short/int/long can all be the same size and thus a
> > "unsigned short" may not actually fit in a "long". I think that was the
> > case on the old 64-bit cray machines, for example ("char" was a very slow
> > 8-bit thing, everything else was purely 64-bit).
> >
> > Not likely something we want to port Linux to, admittedly.
>
> Bear in mind we have the compiler source 8). If someone desperately
> wants to run Linux (probably ucLinux) on their cray they can fix the
> types too.

Hmmm, at least some Cray machines require three-phase power, though,
which is a problem for home use.

Do Cray boxes support virtualisation in hardware, or is it all done in
software?

> Things like the DEC10 (9,18,36 bit) and HLH Orion (word addressed) would
> be a lot more fun but thankfully are extinct

No architecture is _thankfully_ extinct :-).

John.

2003-08-18 17:16:13

by Larry McVoy

[permalink] [raw]
Subject: Re: [PATCH] use simple_strtoul for unsigned kernel parameters

On Mon, Aug 18, 2003 at 06:18:30PM +0100, John Bradford wrote:
> Hmmm, at least some Cray machines require three-phase power, though,
> which is a problem for home use.

Huh? You can get phase converters. It's a common thing to do for home
shops with metal working tools.

But who cares? Nobody is going to run a Cray in their home for more than
a few days, the power draw would get too expensive. So this is well into
"angels in the head of a pin" land.
--
---
Larry McVoy lm at bitmover.com http://www.bitmover.com/lm

2003-08-18 17:28:50

by John Bradford

[permalink] [raw]
Subject: Re: [PATCH] use simple_strtoul for unsigned kernel parameters

> > Hmmm, at least some Cray machines require three-phase power, though,
> > which is a problem for home use.
>
> Huh? You can get phase converters. It's a common thing to do for home
> shops with metal working tools.

Interesting, I didn't know you could buy phase converters...

> But who cares? Nobody is going to run a Cray in their home for more than
> a few days, the power draw would get too expensive. So this is well into
> "angels in the head of a pin" land.

Far from it - the phase converter info has re-awakened my dream of
owning a VAX 11/780, and I'm sure I'm not the only one...

John.

2003-08-18 17:40:10

by Larry McVoy

[permalink] [raw]
Subject: Re: [PATCH] use simple_strtoul for unsigned kernel parameters

On Mon, Aug 18, 2003 at 06:40:08PM +0100, John Bradford wrote:
> > But who cares? Nobody is going to run a Cray in their home for more than
> > a few days, the power draw would get too expensive. So this is well into
> > "angels in the head of a pin" land.
>
> Far from it - the phase converter info has re-awakened my dream of
> owning a VAX 11/780, and I'm sure I'm not the only one...

Great, then trundle over to comp.sys.dec and have the big fun. 10 seconds
in google groups would have found you all the info you want.
--
---
Larry McVoy lm at bitmover.com http://www.bitmover.com/lm

2003-08-18 17:48:28

by John Bradford

[permalink] [raw]
Subject: Re: [PATCH] use simple_strtoul for unsigned kernel parameters

> > > But who cares? Nobody is going to run a Cray in their home for more than
> > > a few days, the power draw would get too expensive. So this is well into
> > > "angels in the head of a pin" land.
> >
> > Far from it - the phase converter info has re-awakened my dream of
> > owning a VAX 11/780, and I'm sure I'm not the only one...
>
> Great, then trundle over to comp.sys.dec and have the big fun. 10 seconds
> in google groups would have found you all the info you want.

Good point - I obviously didn't put too much effort in before the
dream died off the first time :-/.

John.

2003-08-18 19:20:55

by Alan

[permalink] [raw]
Subject: Re: [PATCH] use simple_strtoul for unsigned kernel parameters

On Llu, 2003-08-18 at 18:15, Larry McVoy wrote:
> But who cares? Nobody is going to run a Cray in their home for more than
> a few days, the power draw would get too expensive. So this is well into
> "angels in the head of a pin" land.

If I remember rightly the ELC runs on a single phase with only one CPU
fitted