Skip to content

Commit

Permalink
x86: Work around compiler code generation bug with -Os
Browse files Browse the repository at this point in the history
Some versions of gcc generate incorrect code for the inet_check_attr()
function, apparently due to a totally bogus index -> pointer comparison
transformation.

At least "gcc version 4.0.1 20050727 (Red Hat 4.0.1-5)" from FC4 is
affected, possibly others too.

This changes the function subtly so that the buggy gcc transformation
doesn't trigger.

Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Linus Torvalds committed Jan 15, 2006
1 parent 650eec5 commit caf5b04
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions net/ipv4/fib_frontend.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,13 +289,13 @@ static int inet_check_attr(struct rtmsg *r, struct rtattr **rta)
{
int i;

for (i=1; i<=RTA_MAX; i++) {
struct rtattr *attr = rta[i-1];
for (i=1; i<=RTA_MAX; i++, rta++) {
struct rtattr *attr = *rta;
if (attr) {
if (RTA_PAYLOAD(attr) < 4)
return -EINVAL;
if (i != RTA_MULTIPATH && i != RTA_METRICS)
rta[i-1] = (struct rtattr*)RTA_DATA(attr);
*rta = (struct rtattr*)RTA_DATA(attr);
}
}
return 0;
Expand Down

0 comments on commit caf5b04

Please sign in to comment.