Check for config->options == NULL

This commit is contained in:
Vftdan 2024-08-19 11:21:51 +02:00
parent f19732d364
commit 7cdbcaf25e
8 changed files with 45 additions and 24 deletions

View File

@ -58,6 +58,7 @@ create(GraphNodeSpecification * spec, GraphNodeConfig * config, InitializationEn
has_payload = false;
const config_setting_t *setting;
if (config->options) {
if ((setting = config_setting_get_member(config->options, "namespace"))) {
has_ns = true;
source.code.ns = env_resolve_constant(env, setting);
@ -74,6 +75,17 @@ create(GraphNodeSpecification * spec, GraphNodeConfig * config, InitializationEn
has_payload = true;
source.payload = env_resolve_constant(env, setting);
}
} else {
// Prevent warning for uninitialized variable
source = (EventData) {
.code = {
.ns = 0,
.major = 0,
.minor = 0,
},
.payload = 0,
};
}
*node = (AssignGraphNode) {
.as_GraphNode = {

View File

@ -42,7 +42,6 @@ create(GraphNodeSpecification * spec, GraphNodeConfig * config, InitializationEn
int64_t initial = 0;
if (config->options) {
// FIXME check config->options for NULL in all node types
initial = env_resolve_constant(env, config_setting_get_member(config->options, "initial"));
}

View File

@ -77,7 +77,7 @@ create(GraphNodeSpecification * spec, GraphNodeConfig * config, InitializationEn
}
const char *filename = NULL;
bool should_grab = false;
if (config) {
if (config->options) {
node->namespace = env_resolve_constant(env, config_setting_get_member(config->options, "namespace"));
should_grab = env_resolve_constant(env, config_setting_get_member(config->options, "grab")) != 0;
config_setting_lookup_string(config->options, "file", &filename);

View File

@ -70,7 +70,7 @@ create(GraphNodeSpecification * spec, GraphNodeConfig * config, InitializationEn
.handle_io = handle_io,
.enabled = true,
},
.namespace = env_resolve_constant(env, config_setting_get_member(config->options, "namespace")),
.namespace = config->options ? env_resolve_constant(env, config_setting_get_member(config->options, "namespace")) : 0,
};
return &node->as_GraphNode;
}

View File

@ -30,8 +30,10 @@ handle_event(EventPositionBase * self, EventNode * event)
static GraphNode *
create(GraphNodeSpecification * spec, GraphNodeConfig * config, InitializationEnvironment * env)
{
(void) config;
(void) env;
if (!config->options) {
return NULL;
}
ModifiersGraphNode * node = T_ALLOC(1, ModifiersGraphNode);
if (!node) {
return NULL;

View File

@ -50,8 +50,10 @@ handle_event(EventPositionBase * self, EventNode * event)
static GraphNode *
create(GraphNodeSpecification * spec, GraphNodeConfig * config, InitializationEnvironment * env)
{
(void) config;
(void) env;
if (!config->options) {
return NULL;
}
ModifyPredicateGraphNode * node = T_ALLOC(1, ModifyPredicateGraphNode);
if (!node) {
return NULL;

View File

@ -28,8 +28,10 @@ handle_event(EventPositionBase * self, EventNode * event)
static GraphNode *
create(GraphNodeSpecification * spec, GraphNodeConfig * config, InitializationEnvironment * env)
{
(void) config;
(void) env;
if (!config->options) {
return NULL;
}
RouterGraphNode * node = T_ALLOC(1, RouterGraphNode);
if (!node) {
return NULL;

View File

@ -78,6 +78,10 @@ handle_event(EventPositionBase * self, EventNode * event)
static GraphNode *
create(GraphNodeSpecification * spec, GraphNodeConfig * config, InitializationEnvironment * env)
{
if (!config->options) {
return NULL;
}
UinputGraphNode * node = T_ALLOC(1, UinputGraphNode);
if (!node) {
return NULL;