Skip to contentSkip to conversation

mpparse.c:231: warning: comparison is always false

PATCH In review Jarek Poplawski 5 participants 14 messages Sep 13, 2006 – Sep 16, 2006 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mpparse.c:231: warning: comparison is always false

Hello,

Probably after 2.6.18-rc6-git1 there is this cc warning:
"arch/i386/kernel/mpparse.c:231: warning: comparison is always false due to limited range of data type". Maybe this patch will be helpful.

Jarek P.

arch/i386/kernel/mpparse.c +2 -0
diff -Nurp linux-2.6.18-rc6-git4-/arch/i386/kernel/mpparse.c linux-2.6.18-rc6-git4/arch/i386/kernel/mpparse.c
@@ -228,12 +228,14 @@ static void __init MP_bus_info (struct m
 
 	mpc_oem_bus_info(m, str, translation_table[mpc_record]);
 
+#if 0xFF >= MAX_MP_BUSSES
 	if (m->mpc_busid >= MAX_MP_BUSSES) {
 		printk(KERN_WARNING "MP table busid value (%d) for bustype %s "
 			" is too large, max. supported is %d\n",
 			m->mpc_busid, str, MAX_MP_BUSSES - 1);
 		return;
 	}
+#endif
 
 	if (strncmp(str, BUSTYPE_ISA, sizeof(BUSTYPE_ISA)-1) == 0) {
 		mp_bus_id_to_type[m->mpc_busid] = MP_BUS_ISA;
#1 lore raw
Quoted 10 lines · Jarek Poplawski

Probably after 2.6.18-rc6-git1 there is this cc warning:
"arch/i386/kernel/mpparse.c:231: warning: comparison is always false due to limited range of data type". Maybe this patch will be helpful.

diff -Nurp linux-2.6.18-rc6-git4-/arch/i386/kernel/mpparse.c linux-2.6.18-rc6-git4/arch/i386/kernel/mpparse.c

arch/i386/kernel/mpparse.c +0 -0
@@ -228,12 +228,14 @@ static void __init MP_bus_info (struct m
 

arch/i386/kernel/mpparse.c static void __init MP_bus_info (struct m · line 238

Quoted 10 lines
arch/i386/kernel/mpparse.c +2 -0
 	mpc_oem_bus_info(m, str, translation_table[mpc_record]);
 
+#if 0xFF >= MAX_MP_BUSSES
 	if (m->mpc_busid >= MAX_MP_BUSSES) {
 		printk(KERN_WARNING "MP table busid value (%d) for bustype %s "
 			" is too large, max. supported is %d\n",
 			m->mpc_busid, str, MAX_MP_BUSSES - 1);
 		return;
 	}
+#endif

mpc_busid is a uchar. I don't see how this can ever be > 0xff, yet mach-summit and mach-generic have MAX_MP_BUSSES set to 260.

I don't see how this can possibly work.

Dave

#2 lore raw
Quoted 1 line · Dave Jones

On Wed, Sep 13, 2006 at 08:50:10AM +0200, Jarek Poplawski wrote:

...

Quoted 12 lines

arch/i386/kernel/mpparse.c static void __init MP_bus_info (struct m · line 238

Quoted 8 lines
arch/i386/kernel/mpparse.c +2 -0
+#if 0xFF >= MAX_MP_BUSSES
 	if (m->mpc_busid >= MAX_MP_BUSSES) {
 		printk(KERN_WARNING "MP table busid value (%d) for bustype %s "
 			" is too large, max. supported is %d\n",
 			m->mpc_busid, str, MAX_MP_BUSSES - 1);
 		return;
 	}
+#endif

mpc_busid is a uchar. I don't see how this can ever be > 0xff, yet mach-summit and mach-generic have MAX_MP_BUSSES set to 260.

Quoted 4 lines

I don't see how this can possibly work.

Dave

0xFF >= 260 is false so the block is not compiled and the warning is gone (+ several bytes of useless code).

Jarek P.

#3 lore raw
Quoted 12 lines · Jarek Poplawski
Quoted 1 line · Dave Jones

On Wed, Sep 13, 2006 at 08:50:10AM +0200, Jarek Poplawski wrote:

...

Quoted 9 lines
Quoted 8 lines
arch/i386/kernel/mpparse.c +2 -0
+#if 0xFF >= MAX_MP_BUSSES
 	if (m->mpc_busid >= MAX_MP_BUSSES) {
 		printk(KERN_WARNING "MP table busid value (%d) for bustype %s "
 			" is too large, max. supported is %d\n",
 			m->mpc_busid, str, MAX_MP_BUSSES - 1);
 		return;
 	}
+#endif
Quoted 7 lines
Quoted 4 lines

mpc_busid is a uchar. I don't see how this can ever be > 0xff, yet mach-summit and mach-generic have MAX_MP_BUSSES set to 260.

I don't see how this can possibly work.

0xFF >= 260 is false so the block is not compiled and the warning is gone (+ several bytes of useless code).

Yes, I understand your patch. What I don't understand is why summit/generic have this set so high in the first place.

Dave

#4 lore raw

On Thu, Sep 14, 2006 at 02:35:42AM -0400, Dave Jones wrote:
...

Quoted 2 lines

Yes, I understand your patch. What I don't understand is why summit/generic have this set so high in the first place.

Sorry for misunderstanding your understanding...
I simply tried to understand another question (how this warning could be tolerated for all those gits?).

Jarek P.

#5 lore raw
In reply to Dave Jones
Quoted 6 lines · Dave Jones
Quoted 5 lines · Jarek Poplawski

Probably after 2.6.18-rc6-git1 there is this cc warning:
"arch/i386/kernel/mpparse.c:231: warning: comparison is always false due to limited range of data type". Maybe this patch will be helpful.

It's already fixed.

-Andi

#6 lore raw
Quoted 11 lines · Andi Kleen
Quoted 6 lines · Dave Jones
Quoted 5 lines · Jarek Poplawski

Probably after 2.6.18-rc6-git1 there is this cc warning:
"arch/i386/kernel/mpparse.c:231: warning: comparison is always false due to limited range of data type". Maybe this patch will be helpful.

It's already fixed.

-Andi

Still looks busted to me in 2.6.18rc7

Dave

#9 lore raw
In reply to a message not in the archive
Quoted 15 lines · Andrew Morton
Quoted 7 lines · On Wed, 13 Sep 2006 08:50:10 +0200 Jarek Poplawski <[email protected]> wrote:

Hello,

Probably after 2.6.18-rc6-git1 there is this cc warning:
"arch/i386/kernel/mpparse.c:231: warning: comparison is always false due to limited range of data type". Maybe this patch will be helpful.

Thanks. Andi has already queued a similar patch.

Andi, you might as well scoot that upstream, otherwise we'll get lots of emails about it.

...

Quoted 2 lines

arch/i386/kernel/mpparse.c static void __init MP_bus_info (struct m · line 232

Quoted 2 lines
arch/i386/kernel/mpparse.c +1 -0
+#if 0xFF >= MAX_MP_BUSSES
 	if (m->mpc_busid >= MAX_MP_BUSSES) {

As a matter of fact today I think my patch is wrong.

I don't know how Andi has fixed it, but after rethinking the question of Dave Jones I see it's fixing the result instead of the source of a problem (char or not char).

So it's more serious problem just for really serious guys like you.

Thanks for response,

Jarek P.

#10 lore raw
Quoted 14 lines · On Fri, 15 Sep 2006 10:11:23 +0200 Jarek Poplawski <[email protected]> wrote:
Quoted 13 lines · Andrew Morton
Quoted 7 lines · On Wed, 13 Sep 2006 08:50:10 +0200 Jarek Poplawski <[email protected]> wrote:

Hello,

Probably after 2.6.18-rc6-git1 there is this cc warning:
"arch/i386/kernel/mpparse.c:231: warning: comparison is always false due to limited range of data type". Maybe this patch will be helpful.

Thanks. Andi has already queued a similar patch.

Quoted 7 lines
Quoted 2 lines

Andi, you might as well scoot that upstream, otherwise we'll get lots of emails about it.

...

Quoted 2 lines

arch/i386/kernel/mpparse.c static void __init MP_bus_info (struct m · line 232

Quoted 2 lines
arch/i386/kernel/mpparse.c +1 -0
+#if 0xFF >= MAX_MP_BUSSES
 	if (m->mpc_busid >= MAX_MP_BUSSES) {

As a matter of fact today I think my patch is wrong.

No, I think it's OK. Well, you had an off-by-one...

Quoted 1 line

I don't know how Andi has fixed it,

Same thing. (He has `#if MAX_MP_BUSSES < 256').

Quoted 3 lines

but after rethinking
the question of Dave Jones I see it's fixing the result instead of the source of a problem (char or not char).

The mpc_busid field is set to eight-bits by BIOS; there's nothing we can do about that...

#7 lore raw
In reply to Dave Jones
Quoted 8 lines · Dave Jones
Quoted 7 lines · Andi Kleen
Quoted 5 lines · Dave Jones
Quoted 4 lines · Jarek Poplawski

Probably after 2.6.18-rc6-git1 there is this cc warning:
"arch/i386/kernel/mpparse.c:231: warning: comparison is always false due to limited range of data type". Maybe this patch will be helpful.

Quoted 5 lines
Quoted 3 lines

It's already fixed.

-Andi

Still looks busted to me in 2.6.18rc7

Fixed in the queued for 2.6.19 tree. I didn't consider it important enough to move up.

-Andi

#11 lore raw
In reply to Andrew Morton
Quoted 3 lines · Andrew Morton
Quoted 1 line · On Fri, 15 Sep 2006 10:11:23 +0200 Jarek Poplawski <[email protected]> wrote:

As a matter of fact today I think my patch is wrong.

...

Quoted 1 line

No, I think it's OK. Well, you had an off-by-one...

just like the source:

Quoted 2 lines
arch/i386/kernel/mpparse.c +1 -0
+#if 0xFF >= MAX_MP_BUSSES
 	if (m->mpc_busid >= MAX_MP_BUSSES) {

...

Quoted 6 lines
Quoted 3 lines

but after rethinking
the question of Dave Jones I see it's fixing the result instead of the source of a problem (char or not char).

The mpc_busid field is set to eight-bits by BIOS; there's nothing we can do about that...

So IMHO maybe: if we can know this only by BIOS it should be eight-bits - if there is another way to get this: shouln't you add second constant? Now it's unlogical for me (and it induces this strange #ifs in the code instead of headers).

Jarek P.

#12 lore raw
In reply to Andrew Morton
Quoted 9 lines · Andrew Morton
Quoted 8 lines
Quoted 4 lines

Thanks. Andi has already queued a similar patch.

Andi, you might as well scoot that upstream, otherwise we'll get lots of emails about it.

...

Quoted 2 lines

arch/i386/kernel/mpparse.c static void __init MP_bus_info (struct m · line 232

Quoted 2 lines
arch/i386/kernel/mpparse.c +1 -0
+#if 0xFF >= MAX_MP_BUSSES
 	if (m->mpc_busid >= MAX_MP_BUSSES) {

I don't know how Andi has fixed it,

Same thing. (He has `#if MAX_MP_BUSSES < 256').

How can this be the right the right thing to do ?
It should *never* be >=256. mach-summit/mach-generic need fixing to be 255, not this ridiculous band-aid. Where did 260 come from anyway?

Dave

#13 lore raw
Quoted 7 lines · On Fri, 15 Sep 2006 11:23:49 -0400 Dave Jones <[email protected]> wrote:
Quoted 5 lines · Andrew Morton
Quoted 5 lines
Quoted 4 lines

Thanks. Andi has already queued a similar patch.

Andi, you might as well scoot that upstream, otherwise we'll get lots of emails about it.

...

Quoted 9 lines
Quoted 4 lines
Quoted 3 lines
Quoted 2 lines

Review

Quoted 2 lines
(quoted diff) +1 -0
+#if 0xFF >= MAX_MP_BUSSES
 	if (m->mpc_busid >= MAX_MP_BUSSES) {

I don't know how Andi has fixed it,

Same thing. (He has `#if MAX_MP_BUSSES < 256').

How can this be the right the right thing to do ?
It should *never* be >=256. mach-summit/mach-generic need fixing to be 255, not this ridiculous band-aid. Where did 260 come from anyway?

commit f0bacaf5cec4e677a00b5ab06d95664d03a30f7a

Author: akpm <akpm>
Date:   Mon Apr 12 20:06:32 2004 +0000

[PATCH] summmit: increase MAX_MP_BUSSES

From: James Cleverdon <[email protected]>

Bump up MAX_MP_BUSSES for summit/generic subarch to cope with big IBM x440 systems.

BKrev: 407af6c8l8rvwRmEU-JHTS98MurIZA

include/asm-i386/mach-generic/mach_mpspec.h +3 -1
index ef10cd2..fbb6a40 100644
@@ -8,6 +8,8 @@ #define MAX_APICS 256
 
 #define MAX_IRQ_SOURCES 256
 
-#define MAX_MP_BUSSES 32
+/* Summit or generic (i.e. installer) kernels need lots of bus entries. */
+/* Maximum 256 PCI busses, plus 1 ISA bus in each of 4 cabinets. */
+#define MAX_MP_BUSSES 260
 
 #endif /* __ASM_MACH_MPSPEC_H */
include/asm-i386/mach-summit/mach_mpspec.h +2 -1
index ef10cd2..bc8f717 100644
@@ -8,6 +8,7 @@ #define MAX_APICS 256
 
 #define MAX_IRQ_SOURCES 256
 
-#define MAX_MP_BUSSES 32
+/* Maximum 256 PCI busses, plus 1 ISA bus in each of 4 cabinets. */
+#define MAX_MP_BUSSES 260
 
 #endif /* __ASM_MACH_MPSPEC_H */
#14 lore raw
Quoted 24 lines · Andrew Morton
Quoted 7 lines · On Fri, 15 Sep 2006 11:23:49 -0400 Dave Jones <[email protected]> wrote:
Quoted 5 lines · Andrew Morton
Quoted 5 lines
Quoted 4 lines

Thanks. Andi has already queued a similar patch.

Andi, you might as well scoot that upstream, otherwise we'll get lots of emails about it.

...

Quoted 9 lines
Quoted 4 lines
Quoted 3 lines
Quoted 2 lines

Review

Quoted 2 lines
(quoted diff) +1 -0
+#if 0xFF >= MAX_MP_BUSSES
 	if (m->mpc_busid >= MAX_MP_BUSSES) {

I don't know how Andi has fixed it,

Same thing. (He has `#if MAX_MP_BUSSES < 256').

How can this be the right the right thing to do ?
It should *never* be >=256. mach-summit/mach-generic need fixing to be 255, not this ridiculous band-aid. Where did 260 come from anyway?

commit f0bacaf5cec4e677a00b5ab06d95664d03a30f7a

Author: akpm <akpm>
Date:   Mon Apr 12 20:06:32 2004 +0000
Quoted 6 lines

[PATCH] summmit: increase MAX_MP_BUSSES

From: James Cleverdon <[email protected]>

Bump up MAX_MP_BUSSES for summit/generic subarch to cope with big IBM x440 systems.

The 260 is because ACPI can create larger busses and the summit boxes only run with ACPI anyways.

-Andi