[PATCH 1/3] x86 mpx: change return type of get_reg_offset()

From: Dave Hansen
Date: Tue Nov 18 2014 - 13:24:24 EST



From: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>

get_reg_offset() used to return the register contents themselves
instead of the register offset. When it did that, it was an
unsigned long. I changed it to return an integer _offset_
instead of the register. But, I neglected to change the return
type of the function or the variables in which we store the
result of the call.

This fixes up the code to clear up the warnings from the smatch
bot:

New smatch warnings:
arch/x86/mm/mpx.c:178 mpx_get_addr_ref() warn: unsigned 'addr_offset' is never less than zero.
arch/x86/mm/mpx.c:184 mpx_get_addr_ref() warn: unsigned 'base_offset' is never less than zero.
arch/x86/mm/mpx.c:188 mpx_get_addr_ref() warn: unsigned 'indx_offset' is never less than zero.
arch/x86/mm/mpx.c:196 mpx_get_addr_ref() warn: unsigned 'addr_offset' is never less than zero.

Signed-off-by: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>
Cc: x86@xxxxxxxxxx
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
---

b/arch/x86/mm/mpx.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)

diff -puN arch/x86/mm/mpx.c~mpx_get_addr_ref-as-int arch/x86/mm/mpx.c
--- a/arch/x86/mm/mpx.c~mpx_get_addr_ref-as-int 2014-11-18 09:14:18.630053592 -0800
+++ b/arch/x86/mm/mpx.c 2014-11-18 09:14:18.633053728 -0800
@@ -102,8 +102,8 @@ enum reg_type {
REG_TYPE_BASE,
};

-static unsigned long get_reg_offset(struct insn *insn, struct pt_regs *regs,
- enum reg_type type)
+static int get_reg_offset(struct insn *insn, struct pt_regs *regs,
+ enum reg_type type)
{
int regno = 0;

@@ -174,9 +174,8 @@ static unsigned long get_reg_offset(stru
*/
static void __user *mpx_get_addr_ref(struct insn *insn, struct pt_regs *regs)
{
- unsigned long addr, addr_offset;
- unsigned long base, base_offset;
- unsigned long indx, indx_offset;
+ unsigned long addr, base, indx;
+ int addr_offset, base_offset, indx_offset;
insn_byte_t sib;

insn_get_modrm(insn);
_
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/