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 e7320bbbf0
commit 30c0af7257
49 changed files with 324 additions and 203 deletions

View File

@@ -630,9 +630,8 @@ void pbx_substitute_variables_helper_full(struct ast_channel *c, struct varshead
/* Substitutes variables into cp2, based on string cp1, cp2 NO LONGER NEEDS TO BE ZEROED OUT!!!! */
const char *whereweare;
const char *orig_cp2 = cp2;
char *workspace = NULL;
char *ltmp = NULL;
char *var = NULL;
char ltmp[VAR_BUF_SIZE];
char var[VAR_BUF_SIZE];
*cp2 = 0; /* just in case nothing ends up there */
whereweare = cp1;
@@ -690,6 +689,7 @@ void pbx_substitute_variables_helper_full(struct ast_channel *c, struct varshead
int offset2;
int isfunction;
char *cp4;
char workspace[VAR_BUF_SIZE] = "";
/* We have a variable. Find the start and end, and determine
if we are going to have to recursively call ourselves on the
@@ -725,28 +725,17 @@ void pbx_substitute_variables_helper_full(struct ast_channel *c, struct varshead
/* Skip totally over variable string */
whereweare = vare;
if (!var)
var = ast_alloca(VAR_BUF_SIZE);
/* Store variable name expression to lookup (and truncate). */
ast_copy_string(var, vars, len + 1);
/* Substitute if necessary */
if (needsub) {
if (!ltmp) {
ltmp = ast_alloca(VAR_BUF_SIZE);
}
pbx_substitute_variables_helper_full(c, headp, var, ltmp, VAR_BUF_SIZE - 1, NULL);
vars = ltmp;
} else {
vars = var;
}
if (!workspace)
workspace = ast_alloca(VAR_BUF_SIZE);
workspace[0] = '\0';
parse_variable_name(vars, &offset, &offset2, &isfunction);
if (isfunction) {
/* Evaluate function */
@@ -820,17 +809,11 @@ void pbx_substitute_variables_helper_full(struct ast_channel *c, struct varshead
/* Skip totally over expression */
whereweare = vare;
if (!var)
var = ast_alloca(VAR_BUF_SIZE);
/* Store expression to evaluate (and truncate). */
ast_copy_string(var, vars, len + 1);
/* Substitute if necessary */
if (needsub) {
if (!ltmp) {
ltmp = ast_alloca(VAR_BUF_SIZE);
}
pbx_substitute_variables_helper_full(c, headp, var, ltmp, VAR_BUF_SIZE - 1, NULL);
vars = ltmp;
} else {