Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit caf5b04c authored by Linus Torvalds's avatar Linus Torvalds
Browse files

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: default avatarLinus Torvalds <torvalds@osdl.org>
parent 650eec5e
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -289,13 +289,13 @@ static int inet_check_attr(struct rtmsg *r, struct rtattr **rta)
{
{
	int i;
	int i;


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