* [PATCH] search_one_table()
@ 2001-11-13 22:32 Per Persson
2001-11-13 22:42 ` Brian Gerst
2001-11-13 23:02 ` Robert Love
0 siblings, 2 replies; 3+ messages in thread
From: Per Persson @ 2001-11-13 22:32 UTC (permalink / raw)
To: linux-kernel
I found that gcc doesn't manage to do this rewrite itself. My micro-patch
saves a few bytes. Also the code becomes a little bit cleaner (IMHO).
Probably the same change could (and should) be made for the other
architectures too.
Per Persson
per.persson@gnosjo.pp.se
--- arch/i386/mm/extable.c.orig Mon Nov 12 00:13:52 2001
+++ arch/i386/mm/extable.c Tue Nov 13 17:39:42 2001
@@ -19,7 +19,7 @@
const struct exception_table_entry *mid;
long diff;
- mid = (last - first) / 2 + first;
+ mid = (last + first) / 2
diff = mid->insn - value;
if (diff == 0)
return mid->fixup;
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] search_one_table()
2001-11-13 22:32 [PATCH] search_one_table() Per Persson
@ 2001-11-13 22:42 ` Brian Gerst
2001-11-13 23:02 ` Robert Love
1 sibling, 0 replies; 3+ messages in thread
From: Brian Gerst @ 2001-11-13 22:42 UTC (permalink / raw)
To: Per Persson; +Cc: linux-kernel
Per Persson wrote:
>
> I found that gcc doesn't manage to do this rewrite itself. My micro-patch
> saves a few bytes. Also the code becomes a little bit cleaner (IMHO).
>
> Probably the same change could (and should) be made for the other
> architectures too.
>
> Per Persson
> per.persson@gnosjo.pp.se
>
> --- arch/i386/mm/extable.c.orig Mon Nov 12 00:13:52 2001
> +++ arch/i386/mm/extable.c Tue Nov 13 17:39:42 2001
> @@ -19,7 +19,7 @@
> const struct exception_table_entry *mid;
> long diff;
>
> - mid = (last - first) / 2 + first;
> + mid = (last + first) / 2
> diff = mid->insn - value;
> if (diff == 0)
> return mid->fixup;
>
This change will not work because of lost high bits due to overflow.
Remember that kernel addresses are in the 0xc0000000-0xffffffff range.
--
Brian Gerst
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] search_one_table()
2001-11-13 22:32 [PATCH] search_one_table() Per Persson
2001-11-13 22:42 ` Brian Gerst
@ 2001-11-13 23:02 ` Robert Love
1 sibling, 0 replies; 3+ messages in thread
From: Robert Love @ 2001-11-13 23:02 UTC (permalink / raw)
To: Per Persson; +Cc: linux-kernel
On Tue, 2001-11-13 at 17:32, Per Persson wrote:
> - mid = (last - first) / 2 + first;
> + mid = (last + first) / 2
Ehh, maybe its my scientific computer side talking, but your change will
overflow. Adding two addresses can certainly return an address larger
than 0xffffffff, so you see formulas like the above.
Robert Love
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2001-11-13 23:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-11-13 22:32 [PATCH] search_one_table() Per Persson
2001-11-13 22:42 ` Brian Gerst
2001-11-13 23:02 ` Robert Love
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox