[PATCH] objtool/x86: Replace Non-standard Range Expression in Case

From: Progyan Bhattacharya
Date: Fri Feb 16 2018 - 09:25:27 EST


Replace range expressions with seperate individual cases, i.e. convert case 1...3: to case 1: case 2: case 3
Range expression within case statements are non-standard C code and can create issues over compiler and platform variety.

While compiling with gcc 4.8 (RHEL) I encountered this error on range expression in case statements:
error: range expressions in switch statements are non-standard [-Werror=pedantic]

Signed-off-by: Progyan Bhattacharya <progyanb@xxxxxxx>
Cc: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: Nick Desaulniers <nick.desaulniers@xxxxxxxxx>
Cc: Lukas Bulwahn <lukas.bulwahn@xxxxxxxxx>
Cc: Nicholas Mc Guire <der.herr@xxxxxxx>
Cc: linux-kernel@xxxxxxxxxxxxxxx
---
tools/objtool/arch/x86/decode.c | 35 ++++++++++++++++++++++++++++++++---
1 file changed, 32 insertions(+), 3 deletions(-)

diff --git a/tools/objtool/arch/x86/decode.c b/tools/objtool/arch/x86/decode.c
index 540a209b78ab..4fb9b1307598 100644
--- a/tools/objtool/arch/x86/decode.c
+++ b/tools/objtool/arch/x86/decode.c
@@ -143,7 +143,14 @@ int arch_decode_instruction(struct elf *elf, struct section *sec,
}
break;

- case 0x50 ... 0x57:
+ case 0x50:
+ case 0x51:
+ case 0x52:
+ case 0x53:
+ case 0x54:
+ case 0x55:
+ case 0x56:
+ case 0x57:

/* push reg */
*type = INSN_STACK;
@@ -153,7 +160,14 @@ int arch_decode_instruction(struct elf *elf, struct section *sec,

break;

- case 0x58 ... 0x5f:
+ case 0x58:
+ case 0x59:
+ case 0x5a:
+ case 0x5b:
+ case 0x5c:
+ case 0x5d:
+ case 0x5e:
+ case 0x5f:

/* pop reg */
*type = INSN_STACK;
@@ -171,7 +185,22 @@ int arch_decode_instruction(struct elf *elf, struct section *sec,
op->dest.type = OP_DEST_PUSH;
break;

- case 0x70 ... 0x7f:
+ case 0x70:
+ case 0x71:
+ case 0x72:
+ case 0x73:
+ case 0x74:
+ case 0x75:
+ case 0x76:
+ case 0x77:
+ case 0x78:
+ case 0x79:
+ case 0x7a:
+ case 0x7b:
+ case 0x7c:
+ case 0x7d:
+ case 0x7e:
+ case 0x7f:
*type = INSN_JUMP_CONDITIONAL;
break;

--
2.16.1