Skip to content

Commit 70f8ea0

Browse files
InterLinked1jcolp
authored andcommitted
res_tonedetect: Fixes some logic issues and typos
Fixes some minor logic issues with the module: Previously, the OPT_END_FILTER flag was getting tested before options were parsed, so it could never evaluate to true (wrong ordering). Additionally, the initially parsed timeout (float) needs to be compared with 0, not the result int which is set afterwards (wrong variable). ASTERISK-29857 #close Change-Id: I0062bce3b391c15e5df7a714780eeaa96dd93d4c
1 parent 7ae8321 commit 70f8ea0

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

res/res_tonedetect.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -596,12 +596,12 @@ static int detect_write(struct ast_channel *chan, const char *cmd, char *data, c
596596
parse = ast_strdupa(data);
597597
AST_STANDARD_APP_ARGS(args, parse);
598598

599-
if (ast_test_flag(&flags, OPT_END_FILTER)) {
600-
return remove_detect(chan);
601-
}
602599
if (!ast_strlen_zero(args.options)) {
603600
ast_app_parse_options(td_opts, &flags, opt_args, args.options);
604601
}
602+
if (ast_test_flag(&flags, OPT_END_FILTER)) {
603+
return remove_detect(chan);
604+
}
605605
if (freq_parser(args.freqs, &freq1, &freq2)) {
606606
return -1;
607607
}
@@ -739,7 +739,7 @@ static int wait_exec(struct ast_channel *chan, const char *data)
739739
pbx_builtin_setvar_helper(chan, "WAITFORTONESTATUS", "ERROR");
740740
return -1;
741741
}
742-
if (!ast_strlen_zero(args.timeout) && (sscanf(args.timeout, "%30lf", &timeoutf) != 1 || timeout < 0)) {
742+
if (!ast_strlen_zero(args.timeout) && (sscanf(args.timeout, "%30lf", &timeoutf) != 1 || timeoutf < 0)) {
743743
ast_log(LOG_WARNING, "Invalid timeout: %s\n", args.timeout);
744744
pbx_builtin_setvar_helper(chan, "WAITFORTONESTATUS", "ERROR");
745745
return -1;

0 commit comments

Comments
 (0)