From: Mathieu Desnoyers Date: Fri, 13 Jul 2012 20:21:34 +0000 (-0400) Subject: Validate registers, no need to initialize to 0 X-Git-Tag: v2.1.0-rc1~39 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=225b6640cf81f528f6662b502a5cb631e12f0eca;p=lttng-ust.git Validate registers, no need to initialize to 0 Signed-off-by: Mathieu Desnoyers --- diff --git a/liblttng-ust/lttng-filter.c b/liblttng-ust/lttng-filter.c index a695f1cd..6d64924b 100644 --- a/liblttng-ust/lttng-filter.c +++ b/liblttng-ust/lttng-filter.c @@ -68,6 +68,7 @@ enum reg_type { REG_S64, REG_DOUBLE, REG_STRING, + REG_TYPE_UNKNOWN, }; /* Validation registers */ @@ -239,16 +240,6 @@ int lttng_filter_interpret_bytecode(void *filter_data, int ret = -EINVAL; int retval = 0; struct reg reg[NR_REG]; - int i; - - for (i = 0; i < NR_REG; i++) { - reg[i].type = REG_S64; - reg[i].v = 0; - reg[i].d = 0.0; - reg[i].str = NULL; - reg[i].seq_len = 0; - reg[i].literal = 0; - } start_pc = &bytecode->data[0]; for (pc = next_pc = start_pc; pc - start_pc < bytecode->len; @@ -820,7 +811,7 @@ int lttng_filter_validate_bytecode(struct bytecode_runtime *bytecode) int i; for (i = 0; i < NR_REG; i++) { - reg[i].type = REG_S64; + reg[i].type = REG_TYPE_UNKNOWN; reg[i].literal = 0; } @@ -955,8 +946,11 @@ int lttng_filter_validate_bytecode(struct bytecode_runtime *bytecode) { struct logical_op *insn = (struct logical_op *) pc; - if (unlikely(reg[REG_R0].type == REG_STRING)) { - ERR("Logical operator 'and' can only be applied to numeric and floating point registers\n"); + if (unlikely(reg[REG_R0].type == REG_TYPE_UNKNOWN + || reg[REG_R0].type == REG_TYPE_UNKNOWN + || reg[REG_R0].type == REG_STRING + || reg[REG_R1].type == REG_STRING)) { + ERR("Logical comparator can only be applied to numeric and floating point registers\n"); ret = -EINVAL; goto end; }