ARM: Prefix revision number in /proc/cpuinfo
PATCH 1/1 ARM: Prefix revision number in /proc/cpuinfo
The revision field in /proc/cpuinfo is reported as hex number, so it should have a '0x' prefix to make that clear. Otherwise, parsers will take it as decimal number unless it contains a letter.
--- arch/arm/kernel/setup.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
arch/arm/kernel/setup.c +1 -1
@@ -860,7 +860,7 @@ static int c_show(struct seq_file *m, void *v)seq_puts (m,"\n" );seq_printf (m,"Hardware\t: %s\n" , machine_name); -seq_printf (m,"Revision\t: %04x\n" , system_rev); +seq_printf (m,"Revision\t: 0x%04x\n" , system_rev);seq_printf (m,"Serial\t\t: %08x%08x\n" , system_serial_high, system_serial_low);
Signature · 1 line
1.6.5.2
PATCH 1/1 ARM: Prefix revision number in /proc/cpuinfo
Quoted 3 lines
The revision field in
/proc/cpuinfois reported as hex number, so it should have a '0x' prefix to make that clear. Otherwise, parsers will take it as decimal number unless it contains a letter.
If the problem is real (I assume it is), why don't you fix all fields?
arch/arm/kernel/setup.c static int c_show(struct seq_file *m, void *v) · line 865
Quoted 4 lines
arch/arm/kernel/setup.c +1
-1-seq_printf (m,"Revision\t: %04x\n" , system_rev); +seq_printf (m,"Revision\t: 0x%04x\n" , system_rev);seq_printf (m,"Serial\t\t: %08x%08x\n" , system_serial_high, system_serial_low);
"Serial", above, is hex as well.
thanks
/alessandro
PATCH 1/1 ARM: Prefix revision number in /proc/cpuinfo
Quoted 7 lines · Alessandro Rubini
Quoted 3 lines
The revision field in
/proc/cpuinfois reported as hex number, so it should have a '0x' prefix to make that clear. Otherwise, parsers will take it as decimal number unless it contains a letter.If the problem is real (I assume it is), why don't you fix all fields?
Quoted 6 lines
arch/arm/kernel/setup.c static int c_show(struct seq_file *m, void *v) · line 865
Quoted 4 lines
arch/arm/kernel/setup.c +1
-1-seq_printf (m,"Revision\t: %04x\n" , system_rev); +seq_printf (m,"Revision\t: 0x%04x\n" , system_rev);seq_printf (m,"Serial\t\t: %08x%08x\n" , system_serial_high, system_serial_low);"Serial", above, is hex as well.
Yes, but the serial number is more likely to be taken as string, I thought. Anyway, below is a new patch.
Daniel
PATCH 1/1 ARM: Prefix revision number in /proc/cpuinfo
In reply to Daniel MackQuoted 3 lines · Daniel Mack
The revision field in
/proc/cpuinfois reported as hex number, so it should have a '0x' prefix to make that clear. Otherwise, parsers will take it as decimal number unless it contains a letter.
So what you're doing is possibly breaking existing parsers (which probably already assume it is hex) to fix buggy parsers?
PATCH 1/1 ARM: Prefix revision number in /proc/cpuinfo
Hi Russell,
Quoted 7 lines · Russell King - ARM Linux
Quoted 3 lines · Daniel Mack
The revision field in
/proc/cpuinfois reported as hex number, so it should have a '0x' prefix to make that clear. Otherwise, parsers will take it as decimal number unless it contains a letter.So what you're doing is possibly breaking existing parsers (which probably already assume it is hex) to fix buggy parsers?
I wouldn't call that fixing a buggy parser. On my board, the revision is 0x101 which was parsed as 101. You can't know it is in hex unless you look at the sources.
Daniel
PATCH 1/1 ARM: Prefix revision number in /proc/cpuinfo
Quoted 8 lines · Daniel Mack
Hi Russell,
Quoted 5 lines · Russell King - ARM Linux
Quoted 3 lines · Daniel Mack
The revision field in
/proc/cpuinfois reported as hex number, so it should have a '0x' prefix to make that clear. Otherwise, parsers will take it as decimal number unless it contains a letter.
Quoted 6 lines
Quoted 2 lines
So what you're doing is possibly breaking existing parsers (which probably already assume it is hex) to fix buggy parsers?
I wouldn't call that fixing a buggy parser. On my board, the revision is
0x101which was parsed as 101. You can't know it is in hex unless you look at the sources.
However, we export lots of stuff from the kernel in hex without an '0x' prefix.
The biggest point here, though, is that the field is already present and has been used, created about 10 years ago for NetWinder stuff. So we've about 10 years of history of it being there. Adding the '0x' prefix may break existing parsers, which is a good enough reason not to change it.
Moreover, if you try to parse the field using strtoul, you'll generally end up with it being interpreted as an _octal_ number due to the leading zeros - which should be enough of a hint that it isn't a decimal number.
If you really feel strongly about it, then the only portable way of fixing it would be to create a new entry in the file with the '0x' prefix.
PATCH 1/1 ARM: Prefix revision number in /proc/cpuinfo
Quoted 22 lines · Russell King - ARM Linux
Quoted 6 lines · Daniel Mack
Quoted 5 lines · Russell King - ARM Linux
Quoted 3 lines · Daniel Mack
The revision field in
/proc/cpuinfois reported as hex number, so it should have a '0x' prefix to make that clear. Otherwise, parsers will take it as decimal number unless it contains a letter.Quoted 6 lines
Quoted 2 lines
So what you're doing is possibly breaking existing parsers (which probably already assume it is hex) to fix buggy parsers?
I wouldn't call that fixing a buggy parser. On my board, the revision is
0x101which was parsed as 101. You can't know it is in hex unless you look at the sources.However, we export lots of stuff from the kernel in hex without an '0x' prefix.
The biggest point here, though, is that the field is already present and has been used, created about 10 years ago for NetWinder stuff. So we've about 10 years of history of it being there. Adding the '0x' prefix may break existing parsers, which is a good enough reason not to change it.
Quoted 6 lines
Moreover, if you try to parse the field using strtoul, you'll generally end up with it being interpreted as an _octal_ number due to the leading zeros - which should be enough of a hint that it isn't a decimal number.
If you really feel strongly about it, then the only portable way of fixing it would be to create a new entry in the file with the '0x' prefix.
Hmm, no. I think we will just force the parser to hex then. Not that important. It's just that all other fields in /proc/cpuinfo which are in hex _are_ prefixed indeed, but I see the risk of breaking existing parsers, so let's keep it the way it is.
Thanks,
Daniel