#include <string.h>
#include <inttypes.h>
#include <limits.h>
+#include <usterr-signal-safe.h>
#include "filter-bytecode.h"
#define NR_REG 2
for (pc = next_pc = start_pc; pc - start_pc < bytecode->len;
pc = next_pc) {
if (unlikely(pc >= start_pc + bytecode->len)) {
- fprintf(stderr, "[error] filter bytecode overflow\n");
+ ERR("filter bytecode overflow\n");
ret = -EINVAL;
goto end;
}
switch (*(filter_opcode_t *) pc) {
case FILTER_OP_UNKNOWN:
default:
- fprintf(stderr, "[error] unknown bytecode op %u\n",
+ ERR("unknown bytecode op %u\n",
(unsigned int) *(filter_opcode_t *) pc);
ret = -EINVAL;
goto end;
case FILTER_OP_BIN_AND:
case FILTER_OP_BIN_OR:
case FILTER_OP_BIN_XOR:
- fprintf(stderr, "[error] unsupported bytecode op %u\n",
+ ERR("unsupported bytecode op %u\n",
(unsigned int) *(filter_opcode_t *) pc);
ret = -EINVAL;
goto end;
{
if (unlikely((reg[REG_R0].type == REG_STRING && reg[REG_R1].type != REG_STRING)
|| (reg[REG_R0].type != REG_STRING && reg[REG_R1].type == REG_STRING))) {
- fprintf(stderr, "[error] type mismatch for '==' binary operator\n");
+ ERR("type mismatch for '==' binary operator\n");
ret = -EINVAL;
goto end;
}
switch (reg[REG_R0].type) {
default:
- fprintf(stderr, "[error] unknown register type\n");
+ ERR("unknown register type\n");
ret = -EINVAL;
goto end;
case REG_S64:
switch (reg[REG_R1].type) {
default:
- fprintf(stderr, "[error] unknown register type\n");
+ ERR("unknown register type\n");
ret = -EINVAL;
goto end;
case REG_DOUBLE:
switch (reg[REG_R1].type) {
default:
- fprintf(stderr, "[error] unknown register type\n");
+ ERR("unknown register type\n");
ret = -EINVAL;
goto end;
{
if (unlikely((reg[REG_R0].type == REG_STRING && reg[REG_R1].type != REG_STRING)
|| (reg[REG_R0].type != REG_STRING && reg[REG_R1].type == REG_STRING))) {
- fprintf(stderr, "[error] type mismatch for '!=' binary operator\n");
+ ERR("type mismatch for '!=' binary operator\n");
ret = -EINVAL;
goto end;
}
switch (reg[REG_R0].type) {
default:
- fprintf(stderr, "[error] unknown register type\n");
+ ERR("unknown register type\n");
ret = -EINVAL;
goto end;
case REG_S64:
switch (reg[REG_R1].type) {
default:
- fprintf(stderr, "[error] unknown register type\n");
+ ERR("unknown register type\n");
ret = -EINVAL;
goto end;
case REG_DOUBLE:
switch (reg[REG_R1].type) {
default:
- fprintf(stderr, "[error] unknown register type\n");
+ ERR("unknown register type\n");
ret = -EINVAL;
goto end;
{
if (unlikely((reg[REG_R0].type == REG_STRING && reg[REG_R1].type != REG_STRING)
|| (reg[REG_R0].type != REG_STRING && reg[REG_R1].type == REG_STRING))) {
- fprintf(stderr, "[error] type mismatch for '>' binary operator\n");
+ ERR("type mismatch for '>' binary operator\n");
ret = -EINVAL;
goto end;
}
switch (reg[REG_R0].type) {
default:
- fprintf(stderr, "[error] unknown register type\n");
+ ERR("unknown register type\n");
ret = -EINVAL;
goto end;
case REG_S64:
switch (reg[REG_R1].type) {
default:
- fprintf(stderr, "[error] unknown register type\n");
+ ERR("unknown register type\n");
ret = -EINVAL;
goto end;
case REG_DOUBLE:
switch (reg[REG_R1].type) {
default:
- fprintf(stderr, "[error] unknown register type\n");
+ ERR("unknown register type\n");
ret = -EINVAL;
goto end;
{
if (unlikely((reg[REG_R0].type == REG_STRING && reg[REG_R1].type != REG_STRING)
|| (reg[REG_R0].type != REG_STRING && reg[REG_R1].type == REG_STRING))) {
- fprintf(stderr, "[error] type mismatch for '<' binary operator\n");
+ ERR("type mismatch for '<' binary operator\n");
ret = -EINVAL;
goto end;
}
switch (reg[REG_R0].type) {
default:
- fprintf(stderr, "[error] unknown register type\n");
+ ERR("unknown register type\n");
ret = -EINVAL;
goto end;
case REG_S64:
switch (reg[REG_R1].type) {
default:
- fprintf(stderr, "[error] unknown register type\n");
+ ERR("unknown register type\n");
ret = -EINVAL;
goto end;
case REG_DOUBLE:
switch (reg[REG_R1].type) {
default:
- fprintf(stderr, "[error] unknown register type\n");
+ ERR("unknown register type\n");
ret = -EINVAL;
goto end;
{
if (unlikely((reg[REG_R0].type == REG_STRING && reg[REG_R1].type != REG_STRING)
|| (reg[REG_R0].type != REG_STRING && reg[REG_R1].type == REG_STRING))) {
- fprintf(stderr, "[error] type mismatch for '>=' binary operator\n");
+ ERR("type mismatch for '>=' binary operator\n");
ret = -EINVAL;
goto end;
}
switch (reg[REG_R0].type) {
default:
- fprintf(stderr, "[error] unknown register type\n");
+ ERR("unknown register type\n");
ret = -EINVAL;
goto end;
case REG_S64:
switch (reg[REG_R1].type) {
default:
- fprintf(stderr, "[error] unknown register type\n");
+ ERR("unknown register type\n");
ret = -EINVAL;
goto end;
case REG_DOUBLE:
switch (reg[REG_R1].type) {
default:
- fprintf(stderr, "[error] unknown register type\n");
+ ERR("unknown register type\n");
ret = -EINVAL;
goto end;
{
if (unlikely((reg[REG_R0].type == REG_STRING && reg[REG_R1].type != REG_STRING)
|| (reg[REG_R0].type != REG_STRING && reg[REG_R1].type == REG_STRING))) {
- fprintf(stderr, "[error] type mismatch for '<=' binary operator\n");
+ ERR("type mismatch for '<=' binary operator\n");
ret = -EINVAL;
goto end;
}
switch (reg[REG_R0].type) {
default:
- fprintf(stderr, "[error] unknown register type\n");
+ ERR("unknown register type\n");
ret = -EINVAL;
goto end;
case REG_S64:
switch (reg[REG_R1].type) {
default:
- fprintf(stderr, "[error] unknown register type\n");
+ ERR("unknown register type\n");
ret = -EINVAL;
goto end;
case REG_DOUBLE:
switch (reg[REG_R1].type) {
default:
- fprintf(stderr, "[error] unknown register type\n");
+ ERR("unknown register type\n");
ret = -EINVAL;
goto end;
struct unary_op *insn = (struct unary_op *) pc;
if (unlikely(insn->reg >= REG_ERROR)) {
- fprintf(stderr, "[error] invalid register %u\n",
+ ERR("invalid register %u\n",
(unsigned int) insn->reg);
ret = -EINVAL;
goto end;
}
switch (reg[insn->reg].type) {
default:
- fprintf(stderr, "[error] unknown register type\n");
+ ERR("unknown register type\n");
ret = -EINVAL;
goto end;
case REG_STRING:
- fprintf(stderr, "[error] Unary plus can only be applied to numeric or floating point registers\n");
+ ERR("Unary plus can only be applied to numeric or floating point registers\n");
ret = -EINVAL;
goto end;
case REG_S64:
struct unary_op *insn = (struct unary_op *) pc;
if (unlikely(insn->reg >= REG_ERROR)) {
- fprintf(stderr, "[error] invalid register %u\n",
+ ERR("invalid register %u\n",
(unsigned int) insn->reg);
ret = -EINVAL;
goto end;
}
switch (reg[insn->reg].type) {
default:
- fprintf(stderr, "[error] unknown register type\n");
+ ERR("unknown register type\n");
ret = -EINVAL;
goto end;
case REG_STRING:
- fprintf(stderr, "[error] Unary minus can only be applied to numeric or floating point registers\n");
+ ERR("Unary minus can only be applied to numeric or floating point registers\n");
ret = -EINVAL;
goto end;
case REG_S64:
struct unary_op *insn = (struct unary_op *) pc;
if (unlikely(insn->reg >= REG_ERROR)) {
- fprintf(stderr, "[error] invalid register %u\n",
+ ERR("invalid register %u\n",
(unsigned int) insn->reg);
ret = -EINVAL;
goto end;
}
switch (reg[insn->reg].type) {
default:
- fprintf(stderr, "[error] unknown register type\n");
+ ERR("unknown register type\n");
ret = -EINVAL;
goto end;
case REG_STRING:
- fprintf(stderr, "[error] Unary not can only be applied to numeric or floating point registers\n");
+ ERR("Unary not can only be applied to numeric or floating point registers\n");
ret = -EINVAL;
goto end;
case REG_S64:
break;
}
if (unlikely(reg[insn->reg].type != REG_S64)) {
- fprintf(stderr, "[error] Unary not can only be applied to numeric register\n");
+ ERR("Unary not can only be applied to numeric register\n");
ret = -EINVAL;
goto end;
}
struct logical_op *insn = (struct logical_op *) pc;
if (unlikely(reg[REG_R0].type == REG_STRING)) {
- fprintf(stderr, "[error] Logical operator 'and' can only be applied to numeric and floating point registers\n");
+ ERR("Logical operator 'and' can only be applied to numeric and floating point registers\n");
ret = -EINVAL;
goto end;
}
(unsigned int) insn->skip_offset);
next_pc = start_pc + insn->skip_offset;
if (unlikely(next_pc <= pc)) {
- fprintf(stderr, "[error] Loops are not allowed in bytecode\n");
+ ERR("Loops are not allowed in bytecode\n");
ret = -EINVAL;
goto end;
}
struct logical_op *insn = (struct logical_op *) pc;
if (unlikely(reg[REG_R0].type == REG_STRING)) {
- fprintf(stderr, "[error] Logical operator 'or' can only be applied to numeric and floating point registers\n");
+ ERR("Logical operator 'or' can only be applied to numeric and floating point registers\n");
ret = -EINVAL;
goto end;
}
(unsigned int) insn->skip_offset);
next_pc = start_pc + insn->skip_offset;
if (unlikely(next_pc <= pc)) {
- fprintf(stderr, "[error] Loops are not allowed in bytecode\n");
+ ERR("Loops are not allowed in bytecode\n");
ret = -EINVAL;
goto end;
}
struct field_ref *ref = (struct field_ref *) insn->data;
if (unlikely(insn->reg >= REG_ERROR)) {
- fprintf(stderr, "[error] invalid register %u\n",
+ ERR("invalid register %u\n",
(unsigned int) insn->reg);
ret = -EINVAL;
goto end;
switch (ref->type) {
case FIELD_REF_UNKNOWN:
default:
- fprintf(stderr, "[error] unknown field ref type\n");
+ ERR("unknown field ref type\n");
ret = -EINVAL;
goto end;
struct load_op *insn = (struct load_op *) pc;
if (unlikely(insn->reg >= REG_ERROR)) {
- fprintf(stderr, "[error] invalid register %u\n",
+ ERR("invalid register %u\n",
(unsigned int) insn->reg);
ret = -EINVAL;
goto end;
struct load_op *insn = (struct load_op *) pc;
if (unlikely(insn->reg >= REG_ERROR)) {
- fprintf(stderr, "[error] invalid register %u\n",
+ ERR("invalid register %u\n",
(unsigned int) insn->reg);
ret = -EINVAL;
goto end;
struct load_op *insn = (struct load_op *) pc;
if (unlikely(insn->reg >= REG_ERROR)) {
- fprintf(stderr, "[error] invalid register %u\n",
+ ERR("invalid register %u\n",
(unsigned int) insn->reg);
ret = -EINVAL;
goto end;