Skip to content

Commit

Permalink
fbmon: work around compiler bug in gcc-2.4.2
Browse files Browse the repository at this point in the history
There's some odd bug in gcc-4.2 where it miscompiles a simple loop whent
he loop counter is of type 'unsigned char' and it should count to 128.

The compiler will incorrectly decide that a trivial loop like this:

	unsigned char i, ...

	for (i = 0; i < 128; i++) {
		..

is endless, and will compile it to a single instruction that just
branches to itself.

This was triggered by the addition of '-fno-strict-overflow', and we
could play games with compiler versions and go back to '-fwrapv'
instead, but the trivial way to avoid it is to just make the loop
induction variable be an 'int' instead.

Thanks to Krzysztof Oledzki for reporting and testing and to Troy Moure
for digging through assembler differences and finding it.

Reported-and-tested-by: Krzysztof Oledzki <olel@ans.pl>
Found-by: Troy Moure <twmoure@szypr.net>
Gcc-bug-acked-by: Ian Lance Taylor <iant@google.com>
Cc: stable@kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
torvalds committed Jul 22, 2009
1 parent aea1f79 commit 3730793
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/video/fbmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,8 @@ static void fix_edid(unsigned char *edid, int fix)

static int edid_checksum(unsigned char *edid)
{
unsigned char i, csum = 0, all_null = 0;
int err = 0, fix = check_edid(edid);
unsigned char csum = 0, all_null = 0;
int i, err = 0, fix = check_edid(edid);

if (fix)
fix_edid(edid, fix);
Expand Down

0 comments on commit 3730793

Please sign in to comment.