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

@@ -607,13 +607,14 @@ static void build_profile(const char *name, struct ast_variable *v)
if (!strcasecmp(v->name, "mime_type")) {
ast_string_field_set(profile, default_mime_type, v->value);
} else if (!strcasecmp(v->name, "setvar")) {
char *value_copy = ast_strdupa(v->value);
char value_copy[strlen(v->value) + 1];
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(varname);
AST_APP_ARG(varval);
);
strcpy(value_copy, v->value); /* safe */
AST_NONSTANDARD_APP_ARGS(args, value_copy, '=');
do {
if (ast_strlen_zero(args.varname) || ast_strlen_zero(args.varval))
@@ -629,7 +630,7 @@ static void build_profile(const char *name, struct ast_variable *v)
} else {
struct phoneprov_file *pp_file;
char *file_extension;
char *value_copy = ast_strdupa(v->value);
char value_copy[strlen(v->value) + 1];
AST_DECLARE_APP_ARGS(args,
AST_APP_ARG(filename);
@@ -644,6 +645,7 @@ static void build_profile(const char *name, struct ast_variable *v)
if ((file_extension = strrchr(pp_file->format, '.')))
file_extension++;
strcpy(value_copy, v->value); /* safe */
AST_STANDARD_APP_ARGS(args, value_copy);
/* Mime type order of preference