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

@@ -101,7 +101,7 @@ struct ast_ari_response {
/*! Corresponding text for the response code */
const char *response_text; /* Shouldn't http.c handle this? */
/*! Flag to indicate that no further response is needed */
int no_response:1;
unsigned int no_response:1;
};
/*!

View File

@@ -133,8 +133,8 @@ struct ast_calendar {
int timeframe; /*!< Span (in mins) of calendar data to pull with each request */
pthread_t thread; /*!< The thread that the calendar is loaded/updated in */
ast_cond_t unload;
int unloading:1;
int pending_deletion:1;
unsigned int unloading:1;
unsigned int pending_deletion:1;
struct ao2_container *events; /*!< The events that are known at this time */
};

View File

@@ -18,6 +18,9 @@
* \brief Internal channel functions for channel.c to use
*/
#ifndef ASTERISK_CHANNEL_INTERNAL_H
#define ASTERISK_CHANNEL_INTERNAL_H
#define ast_channel_internal_alloc(destructor, assignedid, requestor) __ast_channel_internal_alloc(destructor, assignedid, requestor, __FILE__, __LINE__, __PRETTY_FUNCTION__)
struct ast_channel *__ast_channel_internal_alloc(void (*destructor)(void *obj), const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *file, int line, const char *function);
void ast_channel_internal_finalize(struct ast_channel *chan);
@@ -33,3 +36,5 @@ void ast_channel_internal_set_stream_topology_change_source(
struct ast_channel *chan, void *change_source);
void ast_channel_internal_swap_stream_topology(struct ast_channel *chan1,
struct ast_channel *chan2);
#endif /* ASTERISK_CHANNEL_INTERNAL_H */

View File

@@ -168,7 +168,7 @@ struct aco_file {
struct aco_info {
const char *module; /*!< The name of the module whose config is being processed */
int hidden:1; /*!< If enabled, this config item is hidden from users */
unsigned int hidden:1; /*!< If enabled, this config item is hidden from users */
aco_pre_apply_config pre_apply_config; /*!< A callback called after processing, but before changes are applied */
aco_post_apply_config post_apply_config;/*!< A callback called after changes are applied */
aco_snapshot_alloc snapshot_alloc; /*!< Allocate an object to hold all global configs and item containers */

View File

@@ -23,6 +23,9 @@
* \author Joshua Colp <jcolp@digium.com>
*/
#ifndef _ASTERISK_DNS_INTERNAL_H
#define _ASTERISK_DNS_INTERNAL_H
/*! \brief For AST_VECTOR */
#include "asterisk/vector.h"
@@ -293,3 +296,5 @@ int dns_parse_string(char *cur, uint8_t *size, char **val);
* \note The query must be released upon completion or cancellation using ao2_ref
*/
struct ast_dns_query *dns_query_alloc(const char *name, int rr_type, int rr_class, ast_dns_resolve_callback callback, void *data);
#endif /* _ASTERISK_DNS_INTERNAL_H */

View File

@@ -17,6 +17,7 @@
*/
#ifndef MAX_FORWARDS_H
#define MAX_FORWARDS_H
struct ast_channel;

View File

@@ -23,6 +23,9 @@
* \author Jonathan Rose <jrose@digium.com>
*/
#ifndef ASTERISK_MIX_MONITOR_H
#define ASTERISK_MIX_MONITOR_H
/*!
* \brief Start a mixmonitor on a channel.
* \since 12.0.0
@@ -103,3 +106,5 @@ int ast_start_mixmonitor(struct ast_channel *chan, const char *filename, const c
* \retval non-zero on failure
*/
int ast_stop_mixmonitor(struct ast_channel *chan, const char *mixmon_id);
#endif /* ASTERISK_MIX_MONITOR_H */

View File

@@ -23,6 +23,9 @@
* \author Jonathan Rose <jrose@digium.com>
*/
#ifndef ASTERISK_PARKING_H
#define ASTERISK_PARKING_H
#include "asterisk/stringfields.h"
#include "asterisk/bridge.h"
@@ -294,3 +297,5 @@ int ast_parking_unregister_bridge_features(const char *module_name);
* \retval 1 if there is a parking provider regsistered
*/
int ast_parking_provider_registered(void);
#endif /* ASTERISK_PARKING_H */

View File

@@ -30,6 +30,9 @@
* This constant is useful to check against when trying to determine
* if printing XML succeeded or failed.
*/
#ifndef ASTERISK_PJSIP_PRESENCE_XML_H
#define ASTERISK_PJSIP_PRESENCE_XML_H
#define AST_PJSIP_XML_PROLOG_LEN 39
/*!
@@ -115,3 +118,5 @@ pj_xml_node *ast_sip_presence_xml_create_node(pj_pool_t *pool,
void ast_sip_presence_xml_find_node_attr(pj_pool_t* pool,
pj_xml_node *parent, const char *node_name, const char *attr_name,
pj_xml_node **node, pj_xml_attr **attr);
#endif /* ASTERISK_PJSIP_PRESENCE_XML_H */

View File

@@ -22,6 +22,9 @@
* Samples were truncated at 160 and 320 bytes.
*/
#ifndef ASTERISK_SLIN_H
#define ASTERISK_SLIN_H
static uint16_t ex_slin8[] = {
0x0002, 0xfffc, 0x0000, 0xfffe, 0x0000, 0xfffa, 0x002a, 0x007a,
0x003a, 0xffbe, 0xff76, 0xff84, 0x0016, 0x007e, 0x0096, 0x00d2,
@@ -91,3 +94,5 @@ static inline struct ast_frame *slin16_sample(void)
return &f;
}
#endif /* ASTERISK_SLIN_H */