From 2e904141ff5046356c69bcf34f39e457ad1ea2e5 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Sun, 12 Jul 2015 18:56:15 -0500 Subject: [PATCH] Make more vm_x86 macros use braces so they work with if blah run macro MASK_REG in EmitMovEDXStack would incorrectly emit asm if 'andit' was 0. 'andit' would never be 0 though so it wasn't causing issues. Found by Coverity. --- code/qcommon/vm_x86.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/code/qcommon/vm_x86.c b/code/qcommon/vm_x86.c index 3ec42eeb..9ee26799 100644 --- a/code/qcommon/vm_x86.c +++ b/code/qcommon/vm_x86.c @@ -203,19 +203,25 @@ static void EmitRexString(byte rex, const char *string) #define MASK_REG(modrm, mask) \ - EmitString("81"); \ - EmitString((modrm)); \ - Emit4((mask)) + do { \ + EmitString("81"); \ + EmitString((modrm)); \ + Emit4((mask)); \ + } while(0) // add bl, bytes #define STACK_PUSH(bytes) \ - EmitString("80 C3"); \ - Emit1(bytes) + do { \ + EmitString("80 C3"); \ + Emit1(bytes); \ + } while(0) // sub bl, bytes #define STACK_POP(bytes) \ - EmitString("80 EB"); \ - Emit1(bytes) + do { \ + EmitString("80 EB"); \ + Emit1(bytes); \ + } while(0) static void EmitCommand(ELastCommand command) {