On Mon, 31 Jul 2006 17:51:22 +0200, Franck Bui-Huu <vagabon.xyz@gmail.com>
wrote:
> while you're at it, (union mips_instruction *) cast is useless and "func"
> local too. Just write
>
> union mips_instruction *ip = info->func;
>
> is more readable, IMHO.
Indeed. Revised.
Subject: [PATCH] make get_frame_info() more readable.
Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
index 8709a46..cd99bc8 100644
--- a/arch/mips/kernel/process.c
+++ b/arch/mips/kernel/process.c
@@ -284,20 +284,18 @@ static int mfinfo_num;
static int get_frame_info(struct mips_frame_info *info)
{
int i;
- void *func = info->func;
- union mips_instruction *ip = (union mips_instruction *)func;
+ union mips_instruction *ip = info->func;
+ int max_insns =
+ min(128UL, info->func_size / sizeof(union mips_instruction));
info->pc_offset = -1;
info->frame_size = 0;
- for (i = 0; i < 128; i++, ip++) {
+ for (i = 0; i < max_insns; i++, ip++) {
/* if jal, jalr, jr, stop. */
if (ip->j_format.opcode == jal_op ||
(ip->r_format.opcode == spec_op &&
(ip->r_format.func == jalr_op ||
ip->r_format.func == jr_op)))
break;
-
- if (info->func_size && i >= info->func_size / 4)
- break;
if (
#ifdef CONFIG_32BIT
ip->i_format.opcode == addiu_op &&
|