various files - fix some alerts raised by lgtm code analysis

This patch fixes several issues reported by the lgtm code analysis tool:

https://lgtm.com/projects/g/asterisk/asterisk

Not all reported issues were addressed in this patch. This patch mostly fixes
confirmed reported errors, potential problematic code points, and a few other
"low hanging" warnings or recommendations found in core supported modules.
These include, but are not limited to the following:

* innapropriate stack allocation in loops
* buffer overflows
* variable declaration "hiding" another variable declaration
* comparisons results that are always the same
* ambiguously signed bit-field members
* missing header guards

Change-Id: Id4a881686605d26c94ab5409bc70fcc21efacc25
This commit is contained in:
Kevin Harwell
2019-10-23 12:36:17 -05:00
committed by George Joseph
parent 990a91b44a
commit bdd785d31c
49 changed files with 324 additions and 203 deletions

View File

@@ -173,7 +173,10 @@ static int s_streamwait3(const say_args_t *a, const char *fn)
static int do_say(say_args_t *a, const char *s, const char *options, int depth)
{
struct ast_variable *v;
char *lang, *x, *rule = NULL;
char *lang;
char *x;
char *rule = NULL;
char *rule_head = NULL;
int ret = 0;
struct varshead head = { .first = NULL, .last = NULL };
struct ast_var_t *n;
@@ -195,7 +198,7 @@ static int do_say(say_args_t *a, const char *s, const char *options, int depth)
for (;;) {
for (v = ast_variable_browse(say_cfg, lang); v ; v = v->next) {
if (ast_extension_match(v->name, s)) {
rule = ast_strdupa(v->value);
rule_head = rule = ast_strdup(v->value);
break;
}
}
@@ -220,6 +223,7 @@ static int do_say(say_args_t *a, const char *s, const char *options, int depth)
n = ast_var_assign("SAY", s);
if (!n) {
ast_log(LOG_ERROR, "Memory allocation error in do_say\n");
ast_free(rule_head);
return -1;
}
AST_LIST_INSERT_HEAD(&head, n, entries);
@@ -281,6 +285,7 @@ static int do_say(say_args_t *a, const char *s, const char *options, int depth)
}
}
ast_var_delete(n);
ast_free(rule_head);
return ret;
}