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

@@ -83,7 +83,7 @@ static void *system_alloc(const char *name)
return system;
}
static int system_apply(const struct ast_sorcery *system_sorcery, void *obj)
static int system_apply(const struct ast_sorcery *sorcery, void *obj)
{
struct system_config *system = obj;
int min_timerb;

View File

@@ -1347,10 +1347,19 @@ static int transport_localnet_handler(const struct aco_option *opt, struct ast_v
return error;
}
static void localnet_to_vl_append(struct ast_variable **head, struct ast_ha *ha)
{
char str[MAX_OBJECT_FIELD];
const char *addr = ast_strdupa(ast_sockaddr_stringify_addr(&ha->addr));
snprintf(str, MAX_OBJECT_FIELD, "%s%s/%s", ha->sense == AST_SENSE_ALLOW ? "!" : "",
addr, ast_sockaddr_stringify_addr(&ha->netmask));
ast_variable_list_append(head, ast_variable_new("local_net", str, ""));
}
static int localnet_to_vl(const void *obj, struct ast_variable **fields)
{
const struct ast_sip_transport *transport = obj;
char str[MAX_OBJECT_FIELD];
struct ast_variable *head = NULL;
struct ast_ha *ha;
RAII_VAR(struct ast_sip_transport_state *, state, find_state_by_transport(transport), ao2_cleanup);
@@ -1360,11 +1369,7 @@ static int localnet_to_vl(const void *obj, struct ast_variable **fields)
}
for (ha = state->localnet; ha; ha = ha->next) {
const char *addr = ast_strdupa(ast_sockaddr_stringify_addr(&ha->addr));
snprintf(str, MAX_OBJECT_FIELD, "%s%s/%s", ha->sense == AST_SENSE_ALLOW ? "!" : "",
addr, ast_sockaddr_stringify_addr(&ha->netmask));
ast_variable_list_append(&head, ast_variable_new("local_net", str, ""));
localnet_to_vl_append(&head, ha);
}
if (head) {

View File

@@ -665,7 +665,7 @@ static void sip_check_transport(pj_pool_t *pool, pjsip_transport_type_e transpor
}
/*! \brief External resolver implementation for PJSIP */
static pjsip_ext_resolver resolver = {
static pjsip_ext_resolver ext_resolver = {
.resolve = sip_resolve,
};
@@ -697,7 +697,7 @@ static int sip_replace_resolver(void *data)
pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool);
/* Replace the PJSIP resolver with our own implementation */
pjsip_endpt_set_ext_resolver(ast_sip_get_pjsip_endpoint(), &resolver);
pjsip_endpt_set_ext_resolver(ast_sip_get_pjsip_endpoint(), &ext_resolver);
return 0;
}