summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/app_minivm.c3
-rw-r--r--apps/app_osplookup.c10
-rw-r--r--cdr/cdr_pgsql.c3
-rw-r--r--cdr/cdr_sqlite3_custom.c3
-rw-r--r--channels/chan_alsa.c3
-rw-r--r--channels/chan_dahdi.c2
-rw-r--r--channels/chan_gtalk.c3
-rw-r--r--channels/chan_h323.c3
-rw-r--r--channels/chan_sip.c2
-rw-r--r--channels/chan_unistim.c11
-rw-r--r--channels/vcodecs.c3
-rw-r--r--codecs/codec_dahdi.c4
-rw-r--r--codecs/codec_g726.c120
-rw-r--r--codecs/codec_resample.c6
-rw-r--r--formats/format_h264.c3
-rw-r--r--funcs/func_callerid.c6
-rw-r--r--funcs/func_env.c2
-rw-r--r--funcs/func_groupcount.c2
-rw-r--r--funcs/func_odbc.c2
-rw-r--r--main/ast_expr2.fl1
-rw-r--r--main/ast_expr2f.c1
-rw-r--r--main/asterisk.c2
-rw-r--r--main/data.c4
-rw-r--r--res/res_config_ldap.c11
-rw-r--r--res/res_config_sqlite3.c2
-rw-r--r--res/res_corosync.c8
-rw-r--r--res/res_format_attr_celt.c4
-rw-r--r--res/res_format_attr_silk.c4
-rw-r--r--res/res_http_post.c3
-rw-r--r--res/res_jabber.c12
-rw-r--r--res/res_musiconhold.c7
-rw-r--r--res/res_odbc.c4
-rw-r--r--res/res_phoneprov.c2
33 files changed, 134 insertions, 122 deletions
diff --git a/apps/app_minivm.c b/apps/app_minivm.c
index cd613b67d..dcfb3629f 100644
--- a/apps/app_minivm.c
+++ b/apps/app_minivm.c
@@ -3397,7 +3397,6 @@ static int minivm_counter_func_write(struct ast_channel *chan, const char *cmd,
{
char *username, *domain, *countername, *operand;
char userpath[BUFSIZ];
- struct minivm_account *vmu;
int change = 0;
int operation = 0;
@@ -3442,7 +3441,7 @@ static int minivm_counter_func_write(struct ast_channel *chan, const char *cmd,
}
/* If we can't find account or if the account is temporary, return. */
- if (!ast_strlen_zero(username) && !(vmu = find_account(domain, username, FALSE))) {
+ if (!ast_strlen_zero(username) && !find_account(domain, username, FALSE)) {
ast_log(LOG_ERROR, "Minivm account does not exist: %s@%s\n", username, domain);
return 0;
}
diff --git a/apps/app_osplookup.c b/apps/app_osplookup.c
index ba7bb03cb..d63c6daa3 100644
--- a/apps/app_osplookup.c
+++ b/apps/app_osplookup.c
@@ -620,7 +620,7 @@ struct osp_metrics {
/* OSP Module Global Variables */
AST_MUTEX_DEFINE_STATIC(osp_lock); /* Lock of OSP provider list */
static int osp_initialized = 0; /* Init flag */
-static int osp_hardware = 0; /* Hardware accelleration flag */
+static int osp_hardware = 0; /* Hardware acceleration flag */
static int osp_security = 0; /* Using security features flag */
static struct osp_provider* osp_providers = NULL; /* OSP provider list */
static unsigned int osp_tokenformat = TOKEN_ALGO_SIGNED; /* Token format supported */
@@ -2336,7 +2336,7 @@ static int osplookup_exec(
struct ast_channel* chan,
const char * data)
{
- int res, cres;
+ int res;
const char* provider = OSP_DEF_PROVIDER;
unsigned int callidtypes = OSP_CALLID_UNDEF;
struct varshead* headp;
@@ -2504,7 +2504,7 @@ static int osplookup_exec(
}
}
- if ((cres = ast_autoservice_start(chan)) < 0) {
+ if (ast_autoservice_start(chan) < 0) {
return OSP_AST_ERROR;
}
@@ -2608,7 +2608,7 @@ static int osplookup_exec(
pbx_builtin_setvar_helper(chan, "OSPDIALSTR", buffer);
}
- if ((cres = ast_autoservice_stop(chan)) < 0) {
+ if (ast_autoservice_stop(chan) < 0) {
return OSP_AST_ERROR;
}
@@ -2982,7 +2982,7 @@ static int osp_load(int reload)
if ((cvar = ast_variable_retrieve(cfg, OSP_GENERAL_CAT, "accelerate")) && ast_true(cvar)) {
if ((error = OSPPInit(1)) != OSPC_ERR_NO_ERROR) {
- ast_log(LOG_WARNING, "OSP: Unable to enable hardware accelleration\n");
+ ast_log(LOG_WARNING, "OSP: Unable to enable hardware acceleration, error='%d'\n", error);
OSPPInit(0);
} else {
osp_hardware = 1;
diff --git a/cdr/cdr_pgsql.c b/cdr/cdr_pgsql.c
index 4f495f429..61ab2b86f 100644
--- a/cdr/cdr_pgsql.c
+++ b/cdr/cdr_pgsql.c
@@ -448,7 +448,6 @@ static int unload_module(void)
static int config_module(int reload)
{
- struct ast_variable *var;
char *pgerror;
struct columns *cur;
PGresult *result;
@@ -465,7 +464,7 @@ static int config_module(int reload)
ast_mutex_lock(&pgsql_lock);
- if (!(var = ast_variable_browse(cfg, "global"))) {
+ if (!ast_variable_browse(cfg, "global")) {
ast_config_destroy(cfg);
ast_mutex_unlock(&pgsql_lock);
ast_log(LOG_NOTICE, "cdr_pgsql configuration contains no global section, skipping module %s.\n",
diff --git a/cdr/cdr_sqlite3_custom.c b/cdr/cdr_sqlite3_custom.c
index 4351c1e69..601234604 100644
--- a/cdr/cdr_sqlite3_custom.c
+++ b/cdr/cdr_sqlite3_custom.c
@@ -156,7 +156,6 @@ static int load_config(int reload)
{
struct ast_config *cfg;
struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
- struct ast_variable *mappingvar;
const char *tmp;
if ((cfg = ast_config_load(config_file, config_flags)) == CONFIG_STATUS_FILEMISSING || cfg == CONFIG_STATUS_FILEINVALID) {
@@ -170,7 +169,7 @@ static int load_config(int reload)
free_config(1);
}
- if (!(mappingvar = ast_variable_browse(cfg, "master"))) {
+ if (!ast_variable_browse(cfg, "master")) {
/* Nothing configured */
ast_config_destroy(cfg);
return -1;
diff --git a/channels/chan_alsa.c b/channels/chan_alsa.c
index 0ebfd3f22..5079fb6ba 100644
--- a/channels/chan_alsa.c
+++ b/channels/chan_alsa.c
@@ -440,7 +440,6 @@ static struct ast_frame *alsa_read(struct ast_channel *chan)
static int left = FRAME_SIZE;
snd_pcm_state_t state;
int r = 0;
- int off = 0;
ast_mutex_lock(&alsalock);
f.frametype = AST_FRAME_NULL;
@@ -478,8 +477,6 @@ static struct ast_frame *alsa_read(struct ast_channel *chan)
snd_pcm_prepare(alsa.icard);
} else if (r < 0) {
ast_log(LOG_ERROR, "Read error: %s\n", snd_strerror(r));
- } else if (r >= 0) {
- off -= r;
}
/* Update positions */
readpos += r;
diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c
index 2e537f870..86a5f41b6 100644
--- a/channels/chan_dahdi.c
+++ b/channels/chan_dahdi.c
@@ -15282,7 +15282,7 @@ static char *dahdi_show_channels(struct ast_cli_entry *e, int cmd, struct ast_cl
{
#define FORMAT "%7s %-10.10s %-15.15s %-10.10s %-20.20s %-10.10s %-10.10s %-32.32s\n"
#define FORMAT2 "%7s %-10.10s %-15.15s %-10.10s %-20.20s %-10.10s %-10.10s %-32.32s\n"
- unsigned int targetnum = 0;
+ int targetnum = 0;
int filtertype = 0;
struct dahdi_pvt *tmp = NULL;
char tmps[20] = "";
diff --git a/channels/chan_gtalk.c b/channels/chan_gtalk.c
index e51282581..20f2589c3 100644
--- a/channels/chan_gtalk.c
+++ b/channels/chan_gtalk.c
@@ -839,7 +839,6 @@ static int gtalk_get_local_ip(struct ast_sockaddr *ourip)
struct ast_sockaddr root;
struct ast_sockaddr bindaddr_tmp;
struct ast_sockaddr *addrs;
- int addrs_cnt;
/* If bind address is not 0.0.0.0, then bindaddr is our local ip. */
ast_sockaddr_from_sin(&bindaddr_tmp, &bindaddr);
@@ -850,7 +849,7 @@ static int gtalk_get_local_ip(struct ast_sockaddr *ourip)
/* If no bind address was provided, lets see what ip we would use to connect to google.com and use that.
* If you can't resolve google.com from your network, then this module is useless for you anyway. */
- if ((addrs_cnt = ast_sockaddr_resolve(&addrs, "google.com", PARSE_PORT_FORBID, AF_INET)) > 0) {
+ if (ast_sockaddr_resolve(&addrs, "google.com", PARSE_PORT_FORBID, AF_INET) > 0) {
ast_sockaddr_copy(&root, &addrs[0]);
ast_free(addrs);
if (!ast_ouraddrfor(&root, ourip)) {
diff --git a/channels/chan_h323.c b/channels/chan_h323.c
index 5feb1e740..2dc0bdc57 100644
--- a/channels/chan_h323.c
+++ b/channels/chan_h323.c
@@ -1436,8 +1436,9 @@ static struct oh323_user *build_user(const char *name, struct ast_variable *v, s
user->options.holdHandling = 0;
/* Set default context */
ast_copy_string(user->context, default_context, sizeof(user->context));
- if (user && !found)
+ if (!found) {
ast_copy_string(user->name, name, sizeof(user->name));
+ }
#if 0 /* XXX Port channel variables functionality from chan_sip XXX */
if (user->chanvars) {
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 080dc9df8..61437187a 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -4509,7 +4509,7 @@ static int sip_sendtext(struct ast_channel *ast, const char *text)
}
if(!is_method_allowed(&dialog->allowed_methods, SIP_MESSAGE)) {
ast_debug(2, "Trying to send MESSAGE to device that does not support it.\n");
- return(0);
+ return 0;
}
debug = sip_debug_test_pvt(dialog);
diff --git a/channels/chan_unistim.c b/channels/chan_unistim.c
index 723500e45..411d8f4e7 100644
--- a/channels/chan_unistim.c
+++ b/channels/chan_unistim.c
@@ -891,8 +891,6 @@ static void send_raw_client(int size, const unsigned char *data, struct sockaddr
#ifdef DUMP_PACKET
if (unistimdebug) {
int tmp;
- char iabuf[INET_ADDRSTRLEN];
- char iabuf2[INET_ADDRSTRLEN];
ast_verb(0, "\n**> From %s sending %d bytes to %s ***\n",
ast_inet_ntoa(addr_ourip->sin_addr), (int) size,
ast_inet_ntoa(addr_to->sin_addr));
@@ -3952,12 +3950,14 @@ static char open_history(struct unistimsession *pte, char way, FILE ** f)
if (fread(&count, 1, 1, *f) != 1) {
display_last_error("Unable to read history header - display.");
fclose(*f);
+ *f = NULL;
return 0;
}
if (count > MAX_ENTRY_LOG) {
ast_log(LOG_WARNING, "Invalid count in history header of %s (%d max %d)\n", tmp,
count, MAX_ENTRY_LOG);
fclose(*f);
+ *f = NULL;
return 0;
}
return count;
@@ -4922,7 +4922,6 @@ static int unistimsock_read(int *id, int fd, short events, void *ignore)
unsigned int size_addr_from;
#ifdef DUMP_PACKET
int dw_num_bytes_rcvdd;
- char iabuf[INET_ADDRSTRLEN];
#endif
size_addr_from = sizeof(addr_from);
@@ -5369,7 +5368,11 @@ static int unistim_sendtext(struct ast_channel *ast, const char *text)
}
if (!text) {
ast_log(LOG_WARNING, "unistim_sendtext called with a null text\n");
- return 1;
+ return -1;
+ }
+
+ if (!pte) {
+ return -1;
}
size = strlen(text);
diff --git a/channels/vcodecs.c b/channels/vcodecs.c
index c667fdb13..db591cad3 100644
--- a/channels/vcodecs.c
+++ b/channels/vcodecs.c
@@ -1131,8 +1131,9 @@ static enum CodecID map_video_format(uint32_t ast_format, int rw)
struct _cm *i;
for (i = video_formats; i->ast_format != 0; i++)
- if (ast_format & i->ast_format && rw & i->rw && rw & i->rw)
+ if (ast_format & i->ast_format && rw & i->rw) {
return i->codec;
+ }
return CODEC_ID_NONE;
}
diff --git a/codecs/codec_dahdi.c b/codecs/codec_dahdi.c
index 832f856ad..442a101d1 100644
--- a/codecs/codec_dahdi.c
+++ b/codecs/codec_dahdi.c
@@ -592,7 +592,7 @@ static int find_transcoders(void)
{
struct dahdi_transcoder_info info = { 0, };
struct format_map map = { { { 0 } } };
- int fd, res;
+ int fd;
unsigned int x, y;
if ((fd = open("/dev/dahdi/transcode", O_RDWR)) < 0) {
@@ -600,7 +600,7 @@ static int find_transcoders(void)
return 0;
}
- for (info.tcnum = 0; !(res = ioctl(fd, DAHDI_TC_GETINFO, &info)); info.tcnum++) {
+ for (info.tcnum = 0; !ioctl(fd, DAHDI_TC_GETINFO, &info); info.tcnum++) {
ast_verb(2, "Found transcoder '%s'.\n", info.name);
/* Complex codecs need to support signed linear. If the
diff --git a/codecs/codec_g726.c b/codecs/codec_g726.c
index d92b9b642..72e77f955 100644
--- a/codecs/codec_g726.c
+++ b/codecs/codec_g726.c
@@ -165,7 +165,7 @@ static int quan(int val, int *table, int size)
for (i = 0; i < size && val >= *table; ++i, ++table)
;
- return (i);
+ return i;
}
#ifdef NOT_BLI /* faster non-identical version */
@@ -248,22 +248,22 @@ static int predictor_pole(struct g726_state *state_ptr)
*/
static int step_size(struct g726_state *state_ptr)
{
- int y;
- int dif;
- int al;
-
- if (state_ptr->ap >= 256)
- return (state_ptr->yu);
- else {
- y = state_ptr->yl >> 6;
- dif = state_ptr->yu - y;
- al = state_ptr->ap >> 2;
- if (dif > 0)
- y += (dif * al) >> 6;
- else if (dif < 0)
- y += (dif * al + 0x3F) >> 6;
- return (y);
+ int y, dif, al;
+
+ if (state_ptr->ap >= 256) {
+ return state_ptr->yu;
}
+
+ y = state_ptr->yl >> 6;
+ dif = state_ptr->yu - y;
+ al = state_ptr->ap >> 2;
+
+ if (dif > 0) {
+ y += (dif * al) >> 6;
+ } else if (dif < 0) {
+ y += (dif * al + 0x3F) >> 6;
+ }
+ return y;
}
/*
@@ -295,8 +295,9 @@ static int quantize(
*/
dqm = abs(d);
exp = ilog2(dqm);
- if (exp < 0)
+ if (exp < 0) {
exp = 0;
+ }
mant = ((dqm << 7) >> exp) & 0x7F; /* Fractional portion. */
dl = (exp << 7) | mant;
@@ -313,12 +314,13 @@ static int quantize(
* Obtain codword i for 'd'.
*/
i = quan(dln, table, size);
- if (d < 0) /* take 1's complement of i */
+ if (d < 0) { /* take 1's complement of i */
return ((size << 1) + 1 - i);
- else if (i == 0) /* take 1's complement of 0 */
+ } else if (i == 0) { /* take 1's complement of 0 */
return ((size << 1) + 1); /* new in 1988 */
- else
- return (i);
+ } else {
+ return i;
+ }
}
/*
@@ -401,13 +403,13 @@ static void update(
thr1 = (32 + ylfrac) << ylint; /* threshold */
thr2 = (ylint > 9) ? 31 << 10 : thr1; /* limit thr2 to 31 << 10 */
dqthr = (thr2 + (thr2 >> 1)) >> 1; /* dqthr = 0.75 * thr2 */
- if (state_ptr->td == 0) /* signal supposed voice */
+ if (state_ptr->td == 0) { /* signal supposed voice */
tr = 0;
- else if (mag <= dqthr) /* supposed data, but small mag */
+ } else if (mag <= dqthr) { /* supposed data, but small mag */
tr = 0; /* treated as voice */
- else /* signal is data (modem) */
+ } else { /* signal is data (modem) */
tr = 1;
-
+ }
/*
* Quantizer scale factor adaptation.
*/
@@ -417,10 +419,11 @@ static void update(
state_ptr->yu = y + ((wi - y) >> 5);
/* LIMB */
- if (state_ptr->yu < 544) /* 544 <= yu <= 5120 */
+ if (state_ptr->yu < 544) { /* 544 <= yu <= 5120 */
state_ptr->yu = 544;
- else if (state_ptr->yu > 5120)
+ } else if (state_ptr->yu > 5120) {
state_ptr->yu = 5120;
+ }
/* FILTE & DELAY */
/* update steady state step size multiplier */
@@ -445,27 +448,30 @@ static void update(
a2p = state_ptr->a[1] - (state_ptr->a[1] >> 7);
if (dqsez != 0) {
fa1 = (pks1) ? state_ptr->a[0] : -state_ptr->a[0];
- if (fa1 < -8191) /* a2p = function of fa1 */
+ if (fa1 < -8191) { /* a2p = function of fa1 */
a2p -= 0x100;
- else if (fa1 > 8191)
+ } else if (fa1 > 8191) {
a2p += 0xFF;
- else
+ } else {
a2p += fa1 >> 5;
+ }
- if (pk0 ^ state_ptr->pk[1])
+ if (pk0 ^ state_ptr->pk[1]) {
/* LIMC */
- if (a2p <= -12160)
+ if (a2p <= -12160) {
a2p = -12288;
- else if (a2p >= 12416)
+ } else if (a2p >= 12416) {
a2p = 12288;
- else
+ } else {
a2p -= 0x80;
- else if (a2p <= -12416)
+ }
+ } else if (a2p <= -12416) {
a2p = -12288;
- else if (a2p >= 12160)
+ } else if (a2p >= 12160) {
a2p = 12288;
- else
+ } else {
a2p += 0x80;
+ }
}
/* TRIGB & DELAY */
@@ -482,23 +488,25 @@ static void update(
}
/* LIMD */
a1ul = 15360 - a2p;
- if (state_ptr->a[0] < -a1ul)
+ if (state_ptr->a[0] < -a1ul) {
state_ptr->a[0] = -a1ul;
- else if (state_ptr->a[0] > a1ul)
+ } else if (state_ptr->a[0] > a1ul) {
state_ptr->a[0] = a1ul;
+ }
/* UPB : update predictor zeros b[6] */
for (cnt = 0; cnt < 6; cnt++) {
- if (code_size == 5) /* for 40Kbps G.723 */
+ if (code_size == 5) { /* for 40Kbps G.723 */
state_ptr->b[cnt] -= state_ptr->b[cnt] >> 9;
- else /* for G.721 and 24Kbps G.723 */
+ } else { /* for G.721 and 24Kbps G.723 */
state_ptr->b[cnt] -= state_ptr->b[cnt] >> 8;
- if (mag)
- { /* XOR */
- if ((dq ^ state_ptr->dq[cnt]) >= 0)
+ }
+ if (mag) { /* XOR */
+ if ((dq ^ state_ptr->dq[cnt]) >= 0) {
state_ptr->b[cnt] += 128;
- else
+ } else {
state_ptr->b[cnt] -= 128;
+ }
}
}
}
@@ -542,12 +550,13 @@ static void update(
state_ptr->pk[0] = pk0;
/* TONE */
- if (tr == 1) /* this sample has been treated as data */
+ if (tr == 1) { /* this sample has been treated as data */
state_ptr->td = 0; /* next one will be treated as voice */
- else if (a2p < -11776) /* small sample-to-sample correlation */
+ } else if (a2p < -11776) { /* small sample-to-sample correlation */
state_ptr->td = 1; /* signal may be data */
- else /* signal is voice */
+ } else { /* signal is voice */
state_ptr->td = 0;
+ }
/*
* Adaptation speed control.
@@ -555,17 +564,18 @@ static void update(
state_ptr->dms += (fi - state_ptr->dms) >> 5; /* FILTA */
state_ptr->dml += (((fi << 2) - state_ptr->dml) >> 7); /* FILTB */
- if (tr == 1)
+ if (tr == 1) {
state_ptr->ap = 256;
- else if (y < 1536) /* SUBTC */
+ } else if (y < 1536) { /* SUBTC */
state_ptr->ap += (0x200 - state_ptr->ap) >> 4;
- else if (state_ptr->td == 1)
+ } else if (state_ptr->td == 1) {
state_ptr->ap += (0x200 - state_ptr->ap) >> 4;
- else if (abs((state_ptr->dms << 2) - state_ptr->dml) >=
- (state_ptr->dml >> 3))
+ } else if (abs((state_ptr->dms << 2) - state_ptr->dml) >=
+ (state_ptr->dml >> 3)) {
state_ptr->ap += (0x200 - state_ptr->ap) >> 4;
- else
+ } else {
state_ptr->ap += (-state_ptr->ap) >> 4;
+ }
}
/*
@@ -667,7 +677,7 @@ static int g726_encode(int sl, struct g726_state *state_ptr)
update(4, y, _witab[i] << 5, _fitab[i], dq, sr, dqsez, state_ptr);
- return (i);
+ return i;
}
/*
diff --git a/codecs/codec_resample.c b/codecs/codec_resample.c
index e2a24223e..7e3bfcb45 100644
--- a/codecs/codec_resample.c
+++ b/codecs/codec_resample.c
@@ -138,6 +138,12 @@ static int load_module(void)
}
}
+ /* in case ast_register_translator() failed, we call unload_module() and
+ ast_unregister_translator won't fail.*/
+ if (res) {
+ unload_module();
+ return AST_MODULE_LOAD_FAILURE;
+ }
return AST_MODULE_LOAD_SUCCESS;
}
diff --git a/formats/format_h264.c b/formats/format_h264.c
index 25ba54a77..e12601045 100644
--- a/formats/format_h264.c
+++ b/formats/format_h264.c
@@ -49,8 +49,7 @@ struct h264_desc {
static int h264_open(struct ast_filestream *s)
{
unsigned int ts;
- int res;
- if ((res = fread(&ts, 1, sizeof(ts), s->f)) < sizeof(ts)) {
+ if (fread(&ts, 1, sizeof(ts), s->f) < sizeof(ts)) {
ast_log(LOG_WARNING, "Empty file!\n");
return -1;
}
diff --git a/funcs/func_callerid.c b/funcs/func_callerid.c
index 8e8335221..067628353 100644
--- a/funcs/func_callerid.c
+++ b/funcs/func_callerid.c
@@ -869,7 +869,6 @@ static int callerpres_write(struct ast_channel *chan, const char *cmd, char *dat
*/
static int callerid_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
{
- enum ID_FIELD_STATUS status;
char *parms;
struct ast_party_members member;
AST_DECLARE_APP_ARGS(args,
@@ -914,6 +913,7 @@ static int callerid_read(struct ast_channel *chan, const char *cmd, char *data,
ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data);
}
} else {
+ enum ID_FIELD_STATUS status;
ast_channel_lock(chan);
if (member.argc == 1 && !strcasecmp("rdnis", member.argv[0])) {
@@ -1181,7 +1181,6 @@ static int connectedline_read(struct ast_channel *chan, const char *cmd, char *d
{
struct ast_party_members member;
char *read_what;
- enum ID_FIELD_STATUS status;
/* Ensure that the buffer is empty */
*buf = 0;
@@ -1202,6 +1201,7 @@ static int connectedline_read(struct ast_channel *chan, const char *cmd, char *d
if (member.argc == 1 && !strcasecmp("source", member.argv[0])) {
ast_copy_string(buf, ast_connected_line_source_name(ast_channel_connected(chan)->source), len);
} else {
+ enum ID_FIELD_STATUS status;
status = party_id_read(buf, len, member.argc, member.argv, &ast_channel_connected(chan)->id);
switch (status) {
case ID_FIELD_VALID:
@@ -1233,7 +1233,6 @@ static int connectedline_read(struct ast_channel *chan, const char *cmd, char *d
static int connectedline_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
{
struct ast_party_connected_line connected;
- enum ID_FIELD_STATUS status;
char *val;
char *parms;
void (*set_it)(struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update);
@@ -1296,6 +1295,7 @@ static int connectedline_write(struct ast_channel *chan, const char *cmd, char *
set_it(chan, &connected, NULL);
}
} else {
+ enum ID_FIELD_STATUS status;
status = party_id_write(&connected.id, member.argc, member.argv, value);
switch (status) {
case ID_FIELD_VALID:
diff --git a/funcs/func_env.c b/funcs/func_env.c
index 2e10fc228..e849816c3 100644
--- a/funcs/func_env.c
+++ b/funcs/func_env.c
@@ -600,7 +600,7 @@ static int file_read(struct ast_channel *chan, const char *cmd, char *data, stru
ast_log(LOG_ERROR, "Cannot seek to offset %" PRId64 ": %s\n", i, strerror(errno));
}
end = fread(fbuf, 1, sizeof(fbuf), ff);
- for (pos = end < sizeof(fbuf) ? fbuf + end - 1 : fbuf + sizeof(fbuf) - 1; pos > fbuf - 1; pos--) {
+ for (pos = (end < sizeof(fbuf) ? fbuf + end - 1 : fbuf + sizeof(fbuf) - 1); pos > fbuf - 1; pos--) {
LINE_COUNTER(pos, format, count);
if (length < 0 && count * -1 == length) {
diff --git a/funcs/func_groupcount.c b/funcs/func_groupcount.c
index 255a28d69..95ee0cde6 100644
--- a/funcs/func_groupcount.c
+++ b/funcs/func_groupcount.c
@@ -146,7 +146,6 @@ static int group_match_count_function_read(struct ast_channel *chan,
const char *cmd, char *data, char *buf,
size_t len)
{
- int count;
char group[80] = "";
char category[80] = "";
@@ -154,6 +153,7 @@ static int group_match_count_function_read(struct ast_channel *chan,
sizeof(category));
if (!ast_strlen_zero(group)) {
+ int count;
count = ast_app_group_match_get_count(group, category);
snprintf(buf, len, "%d", count);
return 0;
diff --git a/funcs/func_odbc.c b/funcs/func_odbc.c
index f86f7608a..1ee9771ad 100644
--- a/funcs/func_odbc.c
+++ b/funcs/func_odbc.c
@@ -714,9 +714,9 @@ end_acf_read:
pbx_builtin_setvar_helper(chan, "ODBCSTATUS", status);
pbx_builtin_setvar_helper(chan, "~ODBCFIELDS~", ast_str_buffer(colnames));
if (resultset) {
- int uid;
struct ast_datastore *odbc_store;
if (multirow) {
+ int uid;
uid = ast_atomic_fetchadd_int(&resultcount, +1) + 1;
snprintf(buf, len, "%d", uid);
} else {
diff --git a/main/ast_expr2.fl b/main/ast_expr2.fl
index 5c7e6a549..e10dde200 100644
--- a/main/ast_expr2.fl
+++ b/main/ast_expr2.fl
@@ -309,7 +309,6 @@ int ast_str_expr(struct ast_str **str, ssize_t maxlen, struct ast_channel *chan,
ast_str_set(str, maxlen, "0");
} else {
if (io.val->type == AST_EXPR_number) {
- int res_length;
ast_str_set(str, maxlen, FP___PRINTF, io.val->u.i);
} else if (io.val->u.s) {
ast_str_set(str, maxlen, "%s", io.val->u.s);
diff --git a/main/ast_expr2f.c b/main/ast_expr2f.c
index c4cce6cf3..675f06b56 100644
--- a/main/ast_expr2f.c
+++ b/main/ast_expr2f.c
@@ -2448,7 +2448,6 @@ int ast_str_expr(struct ast_str **str, ssize_t maxlen, struct ast_channel *chan,
ast_str_set(str, maxlen, "0");
} else {
if (io.val->type == AST_EXPR_number) {
- int res_length;
ast_str_set(str, maxlen, FP___PRINTF, io.val->u.i);
} else if (io.val->u.s) {
ast_str_set(str, maxlen, "%s", io.val->u.s);
diff --git a/main/asterisk.c b/main/asterisk.c
index 5f6449c92..902a285bf 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -3598,7 +3598,7 @@ int main(int argc, char *argv[])
break; /* XXX Should we exit() here? XXX */
}
- fd2 = (l.rlim_cur > sizeof(readers) * 8 ? sizeof(readers) * 8 : l.rlim_cur) - 1;
+ fd2 = ((l.rlim_cur > sizeof(readers) * 8) ? sizeof(readers) * 8 : l.rlim_cur) - 1;
if (dup2(fd, fd2) < 0) {
ast_log(LOG_WARNING, "Cannot open maximum file descriptor %d at boot? %s\n", fd2, strerror(errno));
close(fd);
diff --git a/main/data.c b/main/data.c
index 98f1c336c..e2194b7f0 100644
--- a/main/data.c
+++ b/main/data.c
@@ -696,7 +696,7 @@ static struct ast_data_search *data_search_alloc(const char *name)
res->children = ao2_container_alloc(NUM_DATA_SEARCH_BUCKETS, data_search_hash,
data_search_cmp);
- if (!res) {
+ if (!res->children) {
ao2_ref(res, -1);
return NULL;
}
@@ -1653,7 +1653,7 @@ static struct data_filter *data_filter_alloc(const char *name)
res->children = ao2_container_alloc(NUM_DATA_FILTER_BUCKETS, data_filter_hash,
data_filter_cmp);
- if (!res) {
+ if (!res->children) {
ao2_ref(res, -1);
return NULL;
}
diff --git a/res/res_config_ldap.c b/res/res_config_ldap.c
index 554f4f5d4..159d2ab80 100644
--- a/res/res_config_ldap.c
+++ b/res/res_config_ldap.c
@@ -1092,11 +1092,6 @@ static struct ast_config *config_ldap(const char *basedn, const char *table_name
struct ast_variable *var_metric = variable_named(*p, "var_metric");
struct ast_variable *dn = variable_named(*p, "dn");
- ast_debug(3, "category: %s\n", category->value);
- ast_debug(3, "var_name: %s\n", var_name->value);
- ast_debug(3, "var_val: %s\n", var_val->value);
- ast_debug(3, "cat_metric: %s\n", cat_metric->value);
-
if (!category) {
ast_log(LOG_ERROR, "No category name in entry '%s' for file '%s'.\n",
(dn ? dn->value : "?"), file);
@@ -1122,6 +1117,12 @@ static struct ast_config *config_ldap(const char *basedn, const char *table_name
categories[vars_count].var_metric = atoi(var_metric->value);
vars_count++;
}
+
+ ast_debug(3, "category: %s\n", category->value);
+ ast_debug(3, "var_name: %s\n", var_name->value);
+ ast_debug(3, "var_val: %s\n", var_val->value);
+ ast_debug(3, "cat_metric: %s\n", cat_metric->value);
+
}
qsort(categories, vars_count, sizeof(*categories), compare_categories);
diff --git a/res/res_config_sqlite3.c b/res/res_config_sqlite3.c
index 7e5b2e9f8..17b641dfb 100644
--- a/res/res_config_sqlite3.c
+++ b/res/res_config_sqlite3.c
@@ -961,7 +961,7 @@ static int handle_missing_column(struct realtime_sqlite3_db *db, const char *tab
return -1;
}
- if (!(res = realtime_sqlite3_execute_handle(db, sql, NULL, NULL, 1) < 0 ? -1 : 0)) {
+ if (!(res = (realtime_sqlite3_execute_handle(db, sql, NULL, NULL, 1) < 0 ? -1 : 0))) {
ast_log(LOG_NOTICE, "Creating column '%s' type %s for table %s\n", column, sqltype, table);
}
diff --git a/res/res_corosync.c b/res/res_corosync.c
index 9ce44103d..d1c95f9ec 100644
--- a/res/res_corosync.c
+++ b/res/res_corosync.c
@@ -497,12 +497,12 @@ static void cleanup_module(void)
dispatch_thread.alert_pipe[1] = -1;
}
- if (cpg_handle && (cs_err = cpg_finalize(cpg_handle) != CS_OK)) {
+ if (cpg_handle && (cs_err = cpg_finalize(cpg_handle)) != CS_OK) {
ast_log(LOG_ERROR, "Failed to finalize cpg (%d)\n", (int) cs_err);
}
cpg_handle = 0;
- if (cfg_handle && (cs_err = corosync_cfg_finalize(cfg_handle) != CS_OK)) {
+ if (cfg_handle && (cs_err = corosync_cfg_finalize(cfg_handle)) != CS_OK) {
ast_log(LOG_ERROR, "Failed to finalize cfg (%d)\n", (int) cs_err);
}
cfg_handle = 0;
@@ -514,12 +514,12 @@ static int load_module(void)
enum ast_module_load_result res = AST_MODULE_LOAD_FAILURE;
struct cpg_name name;
- if ((cs_err = corosync_cfg_initialize(&cfg_handle, &cfg_callbacks) != CS_OK)) {
+ if ((cs_err = corosync_cfg_initialize(&cfg_handle, &cfg_callbacks)) != CS_OK) {
ast_log(LOG_ERROR, "Failed to initialize cfg (%d)\n", (int) cs_err);
return AST_MODULE_LOAD_DECLINE;
}
- if ((cs_err = cpg_initialize(&cpg_handle, &cpg_callbacks) != CS_OK)) {
+ if ((cs_err = cpg_initialize(&cpg_handle, &cpg_callbacks)) != CS_OK) {
ast_log(LOG_ERROR, "Failed to initialize cpg (%d)\n", (int) cs_err);
goto failed;
}
diff --git a/res/res_format_attr_celt.c b/res/res_format_attr_celt.c
index 821b0bf3e..bd38b29e2 100644
--- a/res/res_format_attr_celt.c
+++ b/res/res_format_attr_celt.c
@@ -72,8 +72,8 @@ static int celt_get_val(const struct ast_format_attr *fattr, int key, void *resu
*val = attr->framesize;
break;
default:
- return -1;
ast_log(LOG_WARNING, "unknown attribute type %d\n", key);
+ return -1;
}
return 0;
}
@@ -104,8 +104,8 @@ static int celt_isset(const struct ast_format_attr *fattr, va_list ap)
}
break;
default:
- return -1;
ast_log(LOG_WARNING, "unknown attribute type %d\n", key);
+ return -1;
}
}
return 0;
diff --git a/res/res_format_attr_silk.c b/res/res_format_attr_silk.c
index 2d3c91b86..4f9bae739 100644
--- a/res/res_format_attr_silk.c
+++ b/res/res_format_attr_silk.c
@@ -80,8 +80,8 @@ static int silk_get_val(const struct ast_format_attr *fattr, int key, void *resu
*val = attr->packetloss_percentage;
break;
default:
- return -1;
ast_log(LOG_WARNING, "unknown attribute type %d\n", key);
+ return -1;
}
return 0;
}
@@ -122,8 +122,8 @@ static int silk_isset(const struct ast_format_attr *fattr, va_list ap)
}
break;
default:
- return -1;
ast_log(LOG_WARNING, "unknown attribute type %d\n", key);
+ return -1;
}
}
return 0;
diff --git a/res/res_http_post.c b/res/res_http_post.c
index 3dde6484d..c05c228e1 100644
--- a/res/res_http_post.c
+++ b/res/res_http_post.c
@@ -319,7 +319,6 @@ static int http_post_callback(struct ast_tcptls_session_instance *ser, const str
int content_len = 0;
struct ast_str *post_dir;
GMimeMessage *message;
- int message_count = 0;
char * boundary_marker = NULL;
if (method != AST_HTTP_POST) {
@@ -409,7 +408,7 @@ static int http_post_callback(struct ast_tcptls_session_instance *ser, const str
return -1;
}
- if (!(message_count = process_message(message, ast_str_buffer(post_dir)))) {
+ if (!process_message(message, ast_str_buffer(post_dir))) {
ast_log(LOG_ERROR, "Invalid MIME data, found no parts!\n");
g_object_unref(message);
ast_http_error(ser, 400, "Bad Request", "The was an error parsing the request.");
diff --git a/res/res_jabber.c b/res/res_jabber.c
index b808e51ba..a68864f22 100644
--- a/res/res_jabber.c
+++ b/res/res_jabber.c
@@ -1282,7 +1282,6 @@ static int aji_start_tls(struct aji_client *client)
*/
static int aji_tls_handshake(struct aji_client *client)
{
- int ret;
int sock;
ast_debug(1, "Starting TLS handshake\n");
@@ -1300,12 +1299,12 @@ static int aji_tls_handshake(struct aji_client *client)
/* Enforce TLS on our XMPP connection */
sock = iks_fd(client->p);
- if (!(ret = SSL_set_fd(client->ssl_session, sock))) {
+ if (!SSL_set_fd(client->ssl_session, sock)) {
return IKS_NET_TLSFAIL;
}
/* Perform SSL handshake */
- if (!(ret = SSL_connect(client->ssl_session))) {
+ if (!SSL_connect(client->ssl_session)) {
return IKS_NET_TLSFAIL;
}
@@ -1313,7 +1312,7 @@ static int aji_tls_handshake(struct aji_client *client)
client->stream_flags |= SECURE;
/* Sent over the established TLS connection */
- if ((ret = aji_send_header(client, client->jid->server)) != IKS_OK) {
+ if (aji_send_header(client, client->jid->server) != IKS_OK) {
return IKS_NET_TLSFAIL;
}
@@ -1661,8 +1660,8 @@ static int aji_act_hook(void *data, int type, iks *node)
ASTOBJ_UNREF(client, ast_aji_client_destroy);
return IKS_HOOK;
}
-#endif
break;
+#endif
}
if (!client->usesasl) {
iks_filter_add_rule(client->f, aji_client_connect, client, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_SUBTYPE, IKS_TYPE_RESULT, IKS_RULE_ID, client->mid, IKS_RULE_DONE);
@@ -1877,7 +1876,6 @@ static int aji_register_query_handler(void *data, ikspak *pak)
{
struct aji_client *client = ASTOBJ_REF((struct aji_client *) data);
struct aji_buddy *buddy = NULL;
- char *node = NULL;
iks *iq = NULL, *query = NULL;
client = (struct aji_client *) data;
@@ -1910,7 +1908,7 @@ static int aji_register_query_handler(void *data, ikspak *pak)
iks_delete(error);
iks_delete(notacceptable);
- } else if (!(node = iks_find_attrib(pak->query, "node"))) {
+ } else if (!iks_find_attrib(pak->query, "node")) {
iks *instructions = NULL;
char *explain = "Welcome to Asterisk - the Open Source PBX.\n";
iq = iks_new("iq");
diff --git a/res/res_musiconhold.c b/res/res_musiconhold.c
index 639c3b05f..7d5c96922 100644
--- a/res/res_musiconhold.c
+++ b/res/res_musiconhold.c
@@ -1099,16 +1099,19 @@ static int moh_scan_files(struct mohclass *class) {
return -1;
}
- for (i = 0; i < class->total_files; i++)
+ for (i = 0; i < class->total_files; i++) {
ast_free(class->filearray[i]);
-
+ }
class->total_files = 0;
+
if (!getcwd(path, sizeof(path))) {
ast_log(LOG_WARNING, "getcwd() failed: %s\n", strerror(errno));
+ closedir(files_DIR);
return -1;
}
if (chdir(dir_path) < 0) {
ast_log(LOG_WARNING, "chdir() failed: %s\n", strerror(errno));
+ closedir(files_DIR);
return -1;
}
while ((files_dirent = readdir(files_DIR))) {
diff --git a/res/res_odbc.c b/res/res_odbc.c
index 1a4b77662..5aaff57f1 100644
--- a/res/res_odbc.c
+++ b/res/res_odbc.c
@@ -1492,7 +1492,7 @@ static odbc_status odbc_obj_disconnect(struct odbc_obj *obj)
}
}
- if ((res = SQLFreeHandle(SQL_HANDLE_DBC, con) == SQL_SUCCESS)) {
+ if ((res = SQLFreeHandle(SQL_HANDLE_DBC, con)) == SQL_SUCCESS) {
ast_debug(1, "Database handle %p deallocated\n", con);
} else {
SQLGetDiagRec(SQL_HANDLE_DBC, con, 1, state, &err, msg, 100, &mlen);
@@ -1546,7 +1546,7 @@ static odbc_status odbc_obj_connect(struct odbc_obj *obj)
SQLGetDiagRec(SQL_HANDLE_DBC, con, 1, state, &err, msg, 100, &mlen);
obj->parent->last_negative_connect = ast_tvnow();
ast_log(LOG_WARNING, "res_odbc: Error SQLConnect=%d errno=%d %s\n", res, (int)err, msg);
- if ((res = SQLFreeHandle(SQL_HANDLE_DBC, con) != SQL_SUCCESS)) {
+ if ((res = SQLFreeHandle(SQL_HANDLE_DBC, con)) != SQL_SUCCESS) {
SQLGetDiagRec(SQL_HANDLE_DBC, con, 1, state, &err, msg, 100, &mlen);
ast_log(LOG_WARNING, "Unable to deallocate database handle %p? %d errno=%d %s\n", con, res, (int)err, msg);
}
diff --git a/res/res_phoneprov.c b/res/res_phoneprov.c
index c6dc009ea..4ae7efe8f 100644
--- a/res/res_phoneprov.c
+++ b/res/res_phoneprov.c
@@ -1002,7 +1002,7 @@ static int set_config(void)
}
if (!(user = build_user(mac, profile))) {
- ast_log(LOG_WARNING, "Could not create user for '%s' - skipping\n", user->macaddress);
+ ast_log(LOG_WARNING, "Could not create user for '%s' - skipping\n", mac);
continue;
}