[svn-commits] wdoekes: trunk r362307 - in /trunk: apps/ cdr/ channels/ codecs/ formats/ fun...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Apr 17 13:57:45 CDT 2012


Author: wdoekes
Date: Tue Apr 17 13:57:40 2012
New Revision: 362307

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=362307
Log:
Avoid cppcheck warnings; removing unused vars and a bit of cleanup.

Patch by: junky
Review: https://reviewboard.asterisk.org/r/1743/

Modified:
    trunk/apps/app_minivm.c
    trunk/apps/app_osplookup.c
    trunk/cdr/cdr_pgsql.c
    trunk/cdr/cdr_sqlite3_custom.c
    trunk/channels/chan_alsa.c
    trunk/channels/chan_dahdi.c
    trunk/channels/chan_gtalk.c
    trunk/channels/chan_h323.c
    trunk/channels/chan_sip.c
    trunk/channels/chan_unistim.c
    trunk/channels/vcodecs.c
    trunk/codecs/codec_dahdi.c
    trunk/codecs/codec_g726.c
    trunk/codecs/codec_resample.c
    trunk/formats/format_h264.c
    trunk/funcs/func_callerid.c
    trunk/funcs/func_env.c
    trunk/funcs/func_groupcount.c
    trunk/funcs/func_odbc.c
    trunk/main/ast_expr2.fl
    trunk/main/ast_expr2f.c
    trunk/main/asterisk.c
    trunk/main/data.c
    trunk/res/res_config_ldap.c
    trunk/res/res_config_sqlite3.c
    trunk/res/res_corosync.c
    trunk/res/res_format_attr_celt.c
    trunk/res/res_format_attr_silk.c
    trunk/res/res_http_post.c
    trunk/res/res_jabber.c
    trunk/res/res_musiconhold.c
    trunk/res/res_odbc.c
    trunk/res/res_phoneprov.c

Modified: trunk/apps/app_minivm.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_minivm.c?view=diff&rev=362307&r1=362306&r2=362307
==============================================================================
--- trunk/apps/app_minivm.c (original)
+++ trunk/apps/app_minivm.c Tue Apr 17 13:57:40 2012
@@ -3397,7 +3397,6 @@
 {
 	char *username, *domain, *countername, *operand;
 	char userpath[BUFSIZ];
-	struct minivm_account *vmu;
 	int change = 0;
 	int operation = 0;
 
@@ -3442,7 +3441,7 @@
 	}
 
 	/* 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;
 	}

Modified: trunk/apps/app_osplookup.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_osplookup.c?view=diff&rev=362307&r1=362306&r2=362307
==============================================================================
--- trunk/apps/app_osplookup.c (original)
+++ trunk/apps/app_osplookup.c Tue Apr 17 13:57:40 2012
@@ -620,7 +620,7 @@
 /* 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 @@
 	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 @@
 		}
 	}
 
-	if ((cres = ast_autoservice_start(chan)) < 0) {
+	if (ast_autoservice_start(chan) < 0) {
 		return OSP_AST_ERROR;
 	}
 
@@ -2608,7 +2608,7 @@
 		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 @@
 
 		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;

Modified: trunk/cdr/cdr_pgsql.c
URL: http://svnview.digium.com/svn/asterisk/trunk/cdr/cdr_pgsql.c?view=diff&rev=362307&r1=362306&r2=362307
==============================================================================
--- trunk/cdr/cdr_pgsql.c (original)
+++ trunk/cdr/cdr_pgsql.c Tue Apr 17 13:57:40 2012
@@ -448,7 +448,6 @@
 
 static int config_module(int reload)
 {
-	struct ast_variable *var;
 	char *pgerror;
 	struct columns *cur;
 	PGresult *result;
@@ -465,7 +464,7 @@
 
 	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",

Modified: trunk/cdr/cdr_sqlite3_custom.c
URL: http://svnview.digium.com/svn/asterisk/trunk/cdr/cdr_sqlite3_custom.c?view=diff&rev=362307&r1=362306&r2=362307
==============================================================================
--- trunk/cdr/cdr_sqlite3_custom.c (original)
+++ trunk/cdr/cdr_sqlite3_custom.c Tue Apr 17 13:57:40 2012
@@ -156,7 +156,6 @@
 {
 	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 @@
 		free_config(1);
 	}
 
-	if (!(mappingvar = ast_variable_browse(cfg, "master"))) {
+	if (!ast_variable_browse(cfg, "master")) {
 		/* Nothing configured */
 		ast_config_destroy(cfg);
 		return -1;

Modified: trunk/channels/chan_alsa.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_alsa.c?view=diff&rev=362307&r1=362306&r2=362307
==============================================================================
--- trunk/channels/chan_alsa.c (original)
+++ trunk/channels/chan_alsa.c Tue Apr 17 13:57:40 2012
@@ -440,7 +440,6 @@
 	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 @@
 		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;

Modified: trunk/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_dahdi.c?view=diff&rev=362307&r1=362306&r2=362307
==============================================================================
--- trunk/channels/chan_dahdi.c (original)
+++ trunk/channels/chan_dahdi.c Tue Apr 17 13:57:40 2012
@@ -15282,7 +15282,7 @@
 {
 #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] = "";

Modified: trunk/channels/chan_gtalk.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_gtalk.c?view=diff&rev=362307&r1=362306&r2=362307
==============================================================================
--- trunk/channels/chan_gtalk.c (original)
+++ trunk/channels/chan_gtalk.c Tue Apr 17 13:57:40 2012
@@ -839,7 +839,6 @@
 	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 @@
 
 	/* 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)) {

Modified: trunk/channels/chan_h323.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_h323.c?view=diff&rev=362307&r1=362306&r2=362307
==============================================================================
--- trunk/channels/chan_h323.c (original)
+++ trunk/channels/chan_h323.c Tue Apr 17 13:57:40 2012
@@ -1436,8 +1436,9 @@
 	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) {

Modified: trunk/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_sip.c?view=diff&rev=362307&r1=362306&r2=362307
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Tue Apr 17 13:57:40 2012
@@ -4509,7 +4509,7 @@
 	}
 	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);

Modified: trunk/channels/chan_unistim.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_unistim.c?view=diff&rev=362307&r1=362306&r2=362307
==============================================================================
--- trunk/channels/chan_unistim.c (original)
+++ trunk/channels/chan_unistim.c Tue Apr 17 13:57:40 2012
@@ -891,8 +891,6 @@
 #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 @@
 	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 @@
 	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 @@
 	}
 	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);

Modified: trunk/channels/vcodecs.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/vcodecs.c?view=diff&rev=362307&r1=362306&r2=362307
==============================================================================
--- trunk/channels/vcodecs.c (original)
+++ trunk/channels/vcodecs.c Tue Apr 17 13:57:40 2012
@@ -1131,8 +1131,9 @@
 	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;
 }
 

Modified: trunk/codecs/codec_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/trunk/codecs/codec_dahdi.c?view=diff&rev=362307&r1=362306&r2=362307
==============================================================================
--- trunk/codecs/codec_dahdi.c (original)
+++ trunk/codecs/codec_dahdi.c Tue Apr 17 13:57:40 2012
@@ -592,7 +592,7 @@
 {
 	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 @@
 		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

Modified: trunk/codecs/codec_g726.c
URL: http://svnview.digium.com/svn/asterisk/trunk/codecs/codec_g726.c?view=diff&rev=362307&r1=362306&r2=362307
==============================================================================
--- trunk/codecs/codec_g726.c (original)
+++ trunk/codecs/codec_g726.c Tue Apr 17 13:57:40 2012
@@ -165,7 +165,7 @@
 
 	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 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 @@
 	 */
 	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 @@
 	 * 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 @@
 	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 @@
 	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 @@
 		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 @@
 		}
 		/* 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 @@
 	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 @@
 	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 @@
 
 	update(4, y, _witab[i] << 5, _fitab[i], dq, sr, dqsez, state_ptr);
 
-	return (i);
+	return i;
 }
 
 /*

Modified: trunk/codecs/codec_resample.c
URL: http://svnview.digium.com/svn/asterisk/trunk/codecs/codec_resample.c?view=diff&rev=362307&r1=362306&r2=362307
==============================================================================
--- trunk/codecs/codec_resample.c (original)
+++ trunk/codecs/codec_resample.c Tue Apr 17 13:57:40 2012
@@ -138,6 +138,12 @@
 		}
 
 	}
+	/* 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;
 }

Modified: trunk/formats/format_h264.c
URL: http://svnview.digium.com/svn/asterisk/trunk/formats/format_h264.c?view=diff&rev=362307&r1=362306&r2=362307
==============================================================================
--- trunk/formats/format_h264.c (original)
+++ trunk/formats/format_h264.c Tue Apr 17 13:57:40 2012
@@ -49,8 +49,7 @@
 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;
 	}

Modified: trunk/funcs/func_callerid.c
URL: http://svnview.digium.com/svn/asterisk/trunk/funcs/func_callerid.c?view=diff&rev=362307&r1=362306&r2=362307
==============================================================================
--- trunk/funcs/func_callerid.c (original)
+++ trunk/funcs/func_callerid.c Tue Apr 17 13:57:40 2012
@@ -869,7 +869,6 @@
  */
 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 @@
 			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 @@
 {
 	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 @@
 	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_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 @@
 			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:

Modified: trunk/funcs/func_env.c
URL: http://svnview.digium.com/svn/asterisk/trunk/funcs/func_env.c?view=diff&rev=362307&r1=362306&r2=362307
==============================================================================
--- trunk/funcs/func_env.c (original)
+++ trunk/funcs/func_env.c Tue Apr 17 13:57:40 2012
@@ -600,7 +600,7 @@
 				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) {

Modified: trunk/funcs/func_groupcount.c
URL: http://svnview.digium.com/svn/asterisk/trunk/funcs/func_groupcount.c?view=diff&rev=362307&r1=362306&r2=362307
==============================================================================
--- trunk/funcs/func_groupcount.c (original)
+++ trunk/funcs/func_groupcount.c Tue Apr 17 13:57:40 2012
@@ -146,7 +146,6 @@
 					   const char *cmd, char *data, char *buf,
 					   size_t len)
 {
-	int count;
 	char group[80] = "";
 	char category[80] = "";
 
@@ -154,6 +153,7 @@
 				  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;

Modified: trunk/funcs/func_odbc.c
URL: http://svnview.digium.com/svn/asterisk/trunk/funcs/func_odbc.c?view=diff&rev=362307&r1=362306&r2=362307
==============================================================================
--- trunk/funcs/func_odbc.c (original)
+++ trunk/funcs/func_odbc.c Tue Apr 17 13:57:40 2012
@@ -714,9 +714,9 @@
 		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 {

Modified: trunk/main/ast_expr2.fl
URL: http://svnview.digium.com/svn/asterisk/trunk/main/ast_expr2.fl?view=diff&rev=362307&r1=362306&r2=362307
==============================================================================
--- trunk/main/ast_expr2.fl (original)
+++ trunk/main/ast_expr2.fl Tue Apr 17 13:57:40 2012
@@ -309,7 +309,6 @@
 		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);

Modified: trunk/main/ast_expr2f.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/ast_expr2f.c?view=diff&rev=362307&r1=362306&r2=362307
==============================================================================
--- trunk/main/ast_expr2f.c (original)
+++ trunk/main/ast_expr2f.c Tue Apr 17 13:57:40 2012
@@ -2448,7 +2448,6 @@
 		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);

Modified: trunk/main/asterisk.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/asterisk.c?view=diff&rev=362307&r1=362306&r2=362307
==============================================================================
--- trunk/main/asterisk.c (original)
+++ trunk/main/asterisk.c Tue Apr 17 13:57:40 2012
@@ -3598,7 +3598,7 @@
 			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);

Modified: trunk/main/data.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/data.c?view=diff&rev=362307&r1=362306&r2=362307
==============================================================================
--- trunk/main/data.c (original)
+++ trunk/main/data.c Tue Apr 17 13:57:40 2012
@@ -696,7 +696,7 @@
 	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 @@
 	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;
 	}

Modified: trunk/res/res_config_ldap.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_config_ldap.c?view=diff&rev=362307&r1=362306&r2=362307
==============================================================================
--- trunk/res/res_config_ldap.c (original)
+++ trunk/res/res_config_ldap.c Tue Apr 17 13:57:40 2012
@@ -1092,11 +1092,6 @@
 		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 @@
 			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);

Modified: trunk/res/res_config_sqlite3.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_config_sqlite3.c?view=diff&rev=362307&r1=362306&r2=362307
==============================================================================
--- trunk/res/res_config_sqlite3.c (original)
+++ trunk/res/res_config_sqlite3.c Tue Apr 17 13:57:40 2012
@@ -961,7 +961,7 @@
 		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);
 	}
 

Modified: trunk/res/res_corosync.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_corosync.c?view=diff&rev=362307&r1=362306&r2=362307
==============================================================================
--- trunk/res/res_corosync.c (original)
+++ trunk/res/res_corosync.c Tue Apr 17 13:57:40 2012
@@ -497,12 +497,12 @@
 		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 @@
 	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;
 	}

Modified: trunk/res/res_format_attr_celt.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_format_attr_celt.c?view=diff&rev=362307&r1=362306&r2=362307
==============================================================================
--- trunk/res/res_format_attr_celt.c (original)
+++ trunk/res/res_format_attr_celt.c Tue Apr 17 13:57:40 2012
@@ -72,8 +72,8 @@
 		*val = attr->framesize;
 		break;
 	default:
+		ast_log(LOG_WARNING, "unknown attribute type %d\n", key);
 		return -1;
-		ast_log(LOG_WARNING, "unknown attribute type %d\n", key);
 	}
 	return 0;
 }
@@ -104,8 +104,8 @@
 			}
 			break;
 		default:
+			ast_log(LOG_WARNING, "unknown attribute type %d\n", key);
 			return -1;
-			ast_log(LOG_WARNING, "unknown attribute type %d\n", key);
 		}
 	}
 	return 0;

Modified: trunk/res/res_format_attr_silk.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_format_attr_silk.c?view=diff&rev=362307&r1=362306&r2=362307
==============================================================================
--- trunk/res/res_format_attr_silk.c (original)
+++ trunk/res/res_format_attr_silk.c Tue Apr 17 13:57:40 2012
@@ -80,8 +80,8 @@
 		*val = attr->packetloss_percentage;
 		break;
 	default:
+		ast_log(LOG_WARNING, "unknown attribute type %d\n", key);
 		return -1;
-		ast_log(LOG_WARNING, "unknown attribute type %d\n", key);
 	}
 	return 0;
 }
@@ -122,8 +122,8 @@
 			}
 			break;
 		default:
+			ast_log(LOG_WARNING, "unknown attribute type %d\n", key);
 			return -1;
-			ast_log(LOG_WARNING, "unknown attribute type %d\n", key);
 		}
 	}
 	return 0;

Modified: trunk/res/res_http_post.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_http_post.c?view=diff&rev=362307&r1=362306&r2=362307
==============================================================================
--- trunk/res/res_http_post.c (original)
+++ trunk/res/res_http_post.c Tue Apr 17 13:57:40 2012
@@ -319,7 +319,6 @@
 	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 @@
 		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.");

Modified: trunk/res/res_jabber.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_jabber.c?view=diff&rev=362307&r1=362306&r2=362307
==============================================================================
--- trunk/res/res_jabber.c (original)
+++ trunk/res/res_jabber.c Tue Apr 17 13:57:40 2012
@@ -1282,7 +1282,6 @@
  */
 static int aji_tls_handshake(struct aji_client *client)
 {
-	int ret;
 	int sock;
 
 	ast_debug(1, "Starting TLS handshake\n");
@@ -1300,12 +1299,12 @@
 
 	/* 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 @@
 	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 @@
 					ASTOBJ_UNREF(client, ast_aji_client_destroy);
 					return IKS_HOOK;
 				}
+				break;
 #endif
-				break;
 			}
 			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 @@
 {
 	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 @@
 
 		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");

Modified: trunk/res/res_musiconhold.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_musiconhold.c?view=diff&rev=362307&r1=362306&r2=362307
==============================================================================
--- trunk/res/res_musiconhold.c (original)
+++ trunk/res/res_musiconhold.c Tue Apr 17 13:57:40 2012
@@ -1099,16 +1099,19 @@
 		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))) {

Modified: trunk/res/res_odbc.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_odbc.c?view=diff&rev=362307&r1=362306&r2=362307
==============================================================================
--- trunk/res/res_odbc.c (original)
+++ trunk/res/res_odbc.c Tue Apr 17 13:57:40 2012
@@ -1492,7 +1492,7 @@
 		}
 	}
 
-	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 @@
 		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);
 		}

Modified: trunk/res/res_phoneprov.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_phoneprov.c?view=diff&rev=362307&r1=362306&r2=362307
==============================================================================
--- trunk/res/res_phoneprov.c (original)
+++ trunk/res/res_phoneprov.c Tue Apr 17 13:57:40 2012
@@ -1002,7 +1002,7 @@
 			}
 
 			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;
 			}
 




More information about the svn-commits mailing list