Skip to contentSkip to conversation

x86: realmode: use ARRAY_SIZE in test_long_jmp

PATCH In review Paolo Bonzini 2 participants 2 messages Oct 21, 2019 KVM

lore
Share & tools
lore

Paolo Bonzini

author maintainer
#0 lore raw

PATCH 1/1 x86: realmode: use ARRAY_SIZE in test_long_jmp

Make the code a little bit more robust and self-explanatory.

---
 x86/realmode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
x86/realmode.c +1 -1
index a1df515..5dbc2aa 100644
@@ -606,7 +606,7 @@ static void test_long_jmp(void)
 	u32 esp[16];
 
 	inregs = (struct regs){ 0 };
-	inregs.esp = (u32)(esp+16);
+	inregs.esp = (u32)&esp[ARRAY_SIZE(esp)];
 	MK_INSN(long_jmp, "call 1f\n\t"
 			  "jmp 2f\n\t"
 			  "1: jmp $0, $test_function\n\t"
Signature · 1 line
2.21.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 22 lines · Paolo Bonzini

Make the code a little bit more robust and self-explanatory.

---
 x86/realmode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
x86/realmode.c +1 -2
index a1df515..5dbc2aa 100644
@@ -606,7 +606,7 @@ static void test_long_jmp(void)
        u32 esp[16];
 
        inregs = (struct regs){ 0 };
-       inregs.esp = (u32)(esp+16);
+       inregs.esp = (u32)&esp[ARRAY_SIZE(esp)];
        MK_INSN(long_jmp, "call 1f\n\t"
                          "jmp 2f\n\t"
                          "1: jmp $0, $test_function\n\t"
--
Quoted 1 line

2.21.0

Definitely an improvement.