From 589ebb1802a3cbd324bf0b61707cb383b0e490de Mon Sep 17 00:00:00 2001 From: Ruben Ayrapetyan Date: Tue, 18 Aug 2015 12:39:22 +0300 Subject: [PATCH] Remove comparison of unused instruction operands fields (the fields could be uninitialized). Related issue: #585 JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com --- tests/unit/test-parser.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tests/unit/test-parser.cpp b/tests/unit/test-parser.cpp index ba7431839..73ca21e02 100644 --- a/tests/unit/test-parser.cpp +++ b/tests/unit/test-parser.cpp @@ -23,10 +23,24 @@ static bool instrs_equal (const vm_instr_t *instrs1, vm_instr_t *instrs2, uint16_t size) { + static const uint8_t instr_fields_num[] = + { +#define VM_OP_0(opcode_name, opcode_name_uppercase) \ + 1, +#define VM_OP_1(opcode_name, opcode_name_uppercase, arg1, arg1_type) \ + 2, +#define VM_OP_2(opcode_name, opcode_name_uppercase, arg1, arg1_type, arg2, arg2_type) \ + 3, +#define VM_OP_3(opcode_name, opcode_name_uppercase, arg1, arg1_type, arg2, arg2_type, arg3, arg3_type) \ + 4, + +#include "vm-opcodes.inc.h" + }; + uint16_t i; for (i = 0; i < size; i++) { - if (memcmp (&instrs1[i], &instrs2[i], sizeof (vm_instr_t)) != 0) + if (memcmp (&instrs1[i], &instrs2[i], instr_fields_num[instrs1[i].op_idx] * sizeof (idx_t)) != 0) { return false; }