Skip to contentSkip to conversation

[patch]

PATCH New Adrian Bunk 1 participant 1 message Jul 30, 2003 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 [patch]

gcc 3.3 correctly gives the following warning:

<-- snip -->

...
CC drivers/mtd/ftl.o
drivers/mtd/ftl.c: In function `scan_header':
drivers/mtd/ftl.c:191: warning: comparison is always false due to limited range
...

<-- snip -->

Looking at the code it seems gcc is correct, a 16bit number can _never_ be > 65536.

The following patch removes this comparison:

drivers/mtd/ftl.c renamed from drivers/mtd/ftl.c.old +1 -1
@@ -188,7 +188,7 @@
 	printk(KERN_NOTICE "ftl_cs: FTL header not found.\n");
 	return -ENOENT;
     }
-    if ((le16_to_cpu(header.NumEraseUnits) > 65536) || header.BlockSize != 9 ||
+    if (header.BlockSize != 9 ||
 	(header.EraseUnitSize < 10) || (header.EraseUnitSize > 31) ||
 	(header.NumTransferUnits >= le16_to_cpu(header.NumEraseUnits))) {
 	printk(KERN_NOTICE "ftl_cs: FTL header corrupt!\n");

I've tested the compilation with 2.6.0-test2 and 2.4.22-pre9.

cu
Adrian

Signature · 4 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed