Skip to content

Commit

Permalink
Merge pull request #329 from OverOrion/minor-filterx-refactors
Browse files Browse the repository at this point in the history
Minor FilterX cleanups
  • Loading branch information
alltilla authored Oct 10, 2024
2 parents fb32316 + b9c5f84 commit 99f7424
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
17 changes: 10 additions & 7 deletions lib/filterx/expr-variable.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,10 @@ _pull_variable_from_message(FilterXVariableExpr *self, FilterXEvalContext *conte
return NULL;
}

FilterXObject *msg_ref;
if (log_msg_is_value_from_macro(value))
msg_ref = filterx_message_value_new(value, value_len, t);
return filterx_message_value_new(value, value_len, t);
else
msg_ref = filterx_message_value_new_borrowed(value, value_len, t);

filterx_scope_register_variable(context->scope, self->handle, msg_ref);
return msg_ref;
return filterx_message_value_new_borrowed(value, value_len, t);
}

/* NOTE: unset on a variable that only exists in the LogMessage, without making the message writable */
Expand Down Expand Up @@ -84,7 +80,14 @@ _eval(FilterXExpr *s)
}

if (!filterx_variable_handle_is_floating(self->handle))
return _pull_variable_from_message(self, context, context->msgs[0]);
{
FilterXObject *msg_ref = _pull_variable_from_message(self, context, context->msgs[0]);
if(!msg_ref)
return NULL;
filterx_scope_register_variable(context->scope, self->handle, msg_ref);
return msg_ref;
}

filterx_eval_push_error("No such variable", s, self->variable_name);
return NULL;
}
Expand Down
1 change: 0 additions & 1 deletion lib/filterx/filterx-eval.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ void filterx_eval_push_error(const gchar *message, FilterXExpr *expr, FilterXObj
void filterx_eval_push_error_info(const gchar *message, FilterXExpr *expr, gchar *info, gboolean free_info);
void filterx_eval_set_context(FilterXEvalContext *context);
FilterXEvalResult filterx_eval_exec(FilterXEvalContext *context, FilterXExpr *expr, LogMessage *msg);
void filterx_eval_sync_scope_and_message(FilterXScope *scope, LogMessage *msg);
const gchar *filterx_eval_get_last_error(void);
EVTTAG *filterx_format_last_error(void);
EVTTAG *filterx_format_last_error_location(void);
Expand Down

0 comments on commit 99f7424

Please sign in to comment.