Skip to content

Commit e8ce1d5

Browse files
committed
res_alarmsystem: Eliminate label at end of compound statement.
Avoid compiler warning in old versions of gcc.
1 parent ecb429c commit e8ce1d5

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

res/res_alarmsystem.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2081,7 +2081,8 @@ static int load_config(void)
20812081
if (invalid_telenumeric_id(var->value, 0)) {
20822082
ast_log(LOG_ERROR, "Invalid sensor ID '%s' (must contain only 0-9 and A-D)\n", var->value);
20832083
ast_free(s);
2084-
goto nextsensor;
2084+
s = NULL;
2085+
break;
20852086
}
20862087
ast_copy_string(s->sensor_id, var->value, sizeof(s->sensor_id));
20872088
} else if (!strcasecmp(var->name, "disarm_delay") && !ast_strlen_zero(var->value)) {
@@ -2090,14 +2091,17 @@ static int load_config(void)
20902091
ast_log(LOG_WARNING, "Unknown keyword in section '%s': %s at line %d of %s\n", cat, var->name, var->lineno, CONFIG_FILE);
20912092
}
20922093
}
2093-
if (ast_strlen_zero(s->sensor_id)) {
2094-
ast_log(LOG_ERROR, "Sensor '%s' missing sensor ID\n", cat);
2095-
ast_free(s);
2096-
return -1;
2094+
/* Using a label after this block triggers warnings in old versions of gcc about label at end of compound statement,
2095+
* so just check the pointer: */
2096+
if (s) {
2097+
if (ast_strlen_zero(s->sensor_id)) {
2098+
ast_log(LOG_ERROR, "Sensor '%s' missing sensor ID\n", cat);
2099+
ast_free(s);
2100+
return -1;
2101+
}
2102+
ast_debug(4, "Initializing alarm sensor %s\n", s->sensor_id);
2103+
AST_RWLIST_INSERT_TAIL(&c->sensors, s, entry);
20972104
}
2098-
ast_debug(4, "Initializing alarm sensor %s\n", s->sensor_id);
2099-
AST_RWLIST_INSERT_TAIL(&c->sensors, s, entry);
2100-
nextsensor:
21012105
} else if (!strcasecmp(type, "keypad")) {
21022106
struct alarm_client *c;
21032107
const char *client = ast_variable_retrieve(cfg, cat, "client");

0 commit comments

Comments
 (0)