Skip to content

Commit

Permalink
res_alarmsystem: Eliminate label at end of compound statement.
Browse files Browse the repository at this point in the history
Avoid compiler warning in old versions of gcc.
  • Loading branch information
InterLinked1 committed Sep 21, 2024
1 parent ecb429c commit e8ce1d5
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions res/res_alarmsystem.c
Original file line number Diff line number Diff line change
Expand Up @@ -2081,7 +2081,8 @@ static int load_config(void)
if (invalid_telenumeric_id(var->value, 0)) {
ast_log(LOG_ERROR, "Invalid sensor ID '%s' (must contain only 0-9 and A-D)\n", var->value);
ast_free(s);
goto nextsensor;
s = NULL;
break;
}
ast_copy_string(s->sensor_id, var->value, sizeof(s->sensor_id));
} else if (!strcasecmp(var->name, "disarm_delay") && !ast_strlen_zero(var->value)) {
Expand All @@ -2090,14 +2091,17 @@ static int load_config(void)
ast_log(LOG_WARNING, "Unknown keyword in section '%s': %s at line %d of %s\n", cat, var->name, var->lineno, CONFIG_FILE);
}
}
if (ast_strlen_zero(s->sensor_id)) {
ast_log(LOG_ERROR, "Sensor '%s' missing sensor ID\n", cat);
ast_free(s);
return -1;
/* Using a label after this block triggers warnings in old versions of gcc about label at end of compound statement,
* so just check the pointer: */
if (s) {
if (ast_strlen_zero(s->sensor_id)) {
ast_log(LOG_ERROR, "Sensor '%s' missing sensor ID\n", cat);
ast_free(s);
return -1;
}
ast_debug(4, "Initializing alarm sensor %s\n", s->sensor_id);
AST_RWLIST_INSERT_TAIL(&c->sensors, s, entry);
}
ast_debug(4, "Initializing alarm sensor %s\n", s->sensor_id);
AST_RWLIST_INSERT_TAIL(&c->sensors, s, entry);
nextsensor:
} else if (!strcasecmp(type, "keypad")) {
struct alarm_client *c;
const char *client = ast_variable_retrieve(cfg, cat, "client");
Expand Down

0 comments on commit e8ce1d5

Please sign in to comment.