From: Linus Torvalds Date: Sun, 15 Jan 2006 06:08:28 +0000 (-0800) Subject: x86: Work around compiler code generation bug with -Os X-Git-Tag: MMI-PSA29.97-13-9~52833 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=caf5b04c82f05c65843b2d7189845d6c3df5a41e;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git x86: Work around compiler code generation bug with -Os 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 --- diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c index 5b25fc0d980c..4e3d3811dea2 100644 --- a/net/ipv4/fib_frontend.c +++ b/net/ipv4/fib_frontend.c @@ -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;