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

@@ -1504,7 +1504,7 @@ static int __ast_play_and_record(struct ast_channel *chan, const char *playfile,
char comment[256];
int x, fmtcnt = 1, res = -1, outmsg = 0;
struct ast_filestream *others[AST_MAX_FORMATS];
char *sfmt[AST_MAX_FORMATS];
const char *sfmt[AST_MAX_FORMATS];
char *stringp = NULL;
time_t start, end;
struct ast_dsp *sildet = NULL; /* silence detector dsp */
@@ -1579,7 +1579,12 @@ static int __ast_play_and_record(struct ast_channel *chan, const char *playfile,
ast_log(LOG_WARNING, "Please increase AST_MAX_FORMATS in file.h\n");
break;
}
sfmt[fmtcnt++] = ast_strdupa(fmt);
/*
* Storage for 'fmt' is on the stack and held by 'fmts', which is maintained for
* the rest of this function. So okay to not duplicate 'fmt' here, but only keep
* a pointer to it.
*/
sfmt[fmtcnt++] = fmt;
}
end = start = time(NULL); /* pre-initialize end to be same as start in case we never get into loop */