Skip to content

Commit

Permalink
lib/filterx: extract FilterXScope's variable validation logic
Browse files Browse the repository at this point in the history
Signed-off-by: Szilard Parrag <[email protected]>
  • Loading branch information
OverOrion committed Oct 16, 2024
1 parent 04f6478 commit 55fabac
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions lib/filterx/filterx-scope.c
Original file line number Diff line number Diff line change
Expand Up @@ -176,15 +176,23 @@ filterx_scope_map_variable_to_handle(const gchar *name, FilterXVariableType type
return (FilterXVariableHandle) nv_handle | FILTERX_HANDLE_FLOATING_BIT;
}

static gboolean
filterx_scope_validate_variable(FilterXScope *self, FilterXVariable *variable)
{
if (filterx_variable_handle_is_floating(variable->handle) &&
!variable->declared && variable->generation != self->generation)
return FALSE;
return TRUE;
}

FilterXVariable *
filterx_scope_lookup_variable(FilterXScope *self, FilterXVariableHandle handle)
{
FilterXVariable *v;

if (filterx_scope_lookup_variable_without_validation(self, handle, &v))
{
if (filterx_variable_handle_is_floating(handle) &&
!v->declared && v->generation != self->generation)
if (!filterx_scope_validate_variable(self, v))
return NULL;
return v;
}
Expand Down Expand Up @@ -265,8 +273,7 @@ filterx_scope_foreach_variable(FilterXScope *self, FilterXScopeForeachFunc func,
if (!variable->value)
continue;

if (filterx_variable_handle_is_floating(variable->handle) &&
!variable->declared && variable->generation != self->generation)
if (!filterx_scope_validate_variable(self, variable))
continue;

if (!func(variable, user_data))
Expand Down

0 comments on commit 55fabac

Please sign in to comment.