[asterisk-commits] mjordan: trunk r433751 - in /trunk: ./ apps/ channels/ channels/sip/ main/ res/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Mar 29 21:45:33 CDT 2015


Author: mjordan
Date: Sun Mar 29 21:45:29 2015
New Revision: 433751

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=433751
Log:
clang compiler warnings: Fix -Wabsolute-value warnings

This patch fixes several warnings caught by clang - in this case, usage of the
abs function on non-integer values. This patch uses labs and fabs, as
appropriate, in the various affected files.

Review: https://reviewboard.asterisk.org/r/4525

ASTERISK-24917
Reported by: dkdegroot
patches:
  rb4525.patch submitted by dkdegroot (License 6600)
........

Merged revisions 433749 from http://svn.asterisk.org/svn/asterisk/branches/11
........

Merged revisions 433750 from http://svn.asterisk.org/svn/asterisk/branches/13

Modified:
    trunk/   (props changed)
    trunk/apps/app_queue.c
    trunk/channels/chan_iax2.c
    trunk/channels/sip/dialplan_functions.c
    trunk/main/jitterbuf.c
    trunk/res/res_calendar.c
    trunk/res/res_rtp_asterisk.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-13-merged' - no diff available.

Modified: trunk/apps/app_queue.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_queue.c?view=diff&rev=433751&r1=433750&r2=433751
==============================================================================
--- trunk/apps/app_queue.c (original)
+++ trunk/apps/app_queue.c Sun Mar 29 21:45:29 2015
@@ -3724,7 +3724,8 @@
 
 static int say_position(struct queue_ent *qe, int ringing)
 {
-	int res = 0, avgholdmins, avgholdsecs, announceposition = 0;
+	int res = 0, announceposition = 0;
+	long avgholdmins, avgholdsecs;
 	int say_thanks = 1;
 	time_t now;
 
@@ -3798,23 +3799,23 @@
 		}
 	}
 	/* Round hold time to nearest minute */
-	avgholdmins = abs(((qe->parent->holdtime + 30) - (now - qe->start)) / 60);
+	avgholdmins = labs(((qe->parent->holdtime + 30) - (now - qe->start)) / 60);
 
 	/* If they have specified a rounding then round the seconds as well */
 	if (qe->parent->roundingseconds) {
-		avgholdsecs = (abs(((qe->parent->holdtime + 30) - (now - qe->start))) - 60 * avgholdmins) / qe->parent->roundingseconds;
+		avgholdsecs = (labs(((qe->parent->holdtime + 30) - (now - qe->start))) - 60 * avgholdmins) / qe->parent->roundingseconds;
 		avgholdsecs *= qe->parent->roundingseconds;
 	} else {
 		avgholdsecs = 0;
 	}
 
-	ast_verb(3, "Hold time for %s is %d minute(s) %d seconds\n", qe->parent->name, avgholdmins, avgholdsecs);
+	ast_verb(3, "Hold time for %s is %ld minute(s) %ld seconds\n", qe->parent->name, avgholdmins, avgholdsecs);
 
 	/* If the hold time is >1 min, if it's enabled, and if it's not
 	   supposed to be only once and we have already said it, say it */
-    if ((avgholdmins+avgholdsecs) > 0 && qe->parent->announceholdtime &&
-        ((qe->parent->announceholdtime == ANNOUNCEHOLDTIME_ONCE && !qe->last_pos) ||
-        !(qe->parent->announceholdtime == ANNOUNCEHOLDTIME_ONCE))) {
+	if ((avgholdmins+avgholdsecs) > 0 && qe->parent->announceholdtime &&
+		((qe->parent->announceholdtime == ANNOUNCEHOLDTIME_ONCE && !qe->last_pos) ||
+		!(qe->parent->announceholdtime == ANNOUNCEHOLDTIME_ONCE))) {
 		res = play_file(qe->chan, qe->parent->sound_holdtime);
 		if (res) {
 			goto playout;
@@ -6618,11 +6619,11 @@
 				}
 				if (!res2 && qe->parent->reportholdtime) {
 					if (!play_file(peer, qe->parent->sound_reporthold)) {
-						int holdtime, holdtimesecs;
+						long holdtime, holdtimesecs;
 
 						time(&now);
-						holdtime = abs((now - qe->start) / 60);
-						holdtimesecs = abs((now - qe->start) % 60);
+						holdtime = labs((now - qe->start) / 60);
+						holdtimesecs = labs((now - qe->start) % 60);
 						if (holdtime > 0) {
 							ast_say_number(peer, holdtime, AST_DIGIT_ANY, ast_channel_language(peer), NULL);
 							if (play_file(peer, qe->parent->sound_minutes) < 0) {

Modified: trunk/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_iax2.c?view=diff&rev=433751&r1=433750&r2=433751
==============================================================================
--- trunk/channels/chan_iax2.c (original)
+++ trunk/channels/chan_iax2.c Sun Mar 29 21:45:29 2015
@@ -5986,7 +5986,7 @@
 	ms = ast_tvdiff_ms(*now, tpeer->txtrunktime);
 	/* Predict from last value */
 	pred = tpeer->lastsent + sampms;
-	if (abs(ms - pred) < MAX_TIMESTAMP_SKEW)
+	if (labs(ms - pred) < MAX_TIMESTAMP_SKEW)
 		ms = pred;
 
 	/* We never send the same timestamp twice, so fudge a little if we must */
@@ -6059,7 +6059,8 @@
 			ms = 0;
 		if (voice) {
 			/* On a voice frame, use predicted values if appropriate */
-			if (p->notsilenttx && abs(ms - p->nextpred) <= MAX_TIMESTAMP_SKEW) {
+			adjust = (ms - p->nextpred);
+			if (p->notsilenttx && abs(adjust) <= MAX_TIMESTAMP_SKEW) {
 				/* Adjust our txcore, keeping voice and non-voice synchronized */
 				/* AN EXPLANATION:
 				   When we send voice, we usually send "calculated" timestamps worked out
@@ -6078,7 +6079,6 @@
 				   changing at all.  But if a consistent different starts to develop it
 				   will be eliminated over the course of 10 frames (200-300msecs)
 				*/
-				adjust = (ms - p->nextpred);
 				if (adjust < 0)
 					p->offset = ast_tvsub(p->offset, ast_samp2tv(abs(adjust), 10000));
 				else if (adjust > 0)
@@ -6100,9 +6100,9 @@
 				* silent periods are multiples of
 				* frame size too) */
 
-				if (iaxdebug && abs(ms - p->nextpred) > MAX_TIMESTAMP_SKEW )
+				if (iaxdebug && abs(adjust) > MAX_TIMESTAMP_SKEW )
 					ast_debug(1, "predicted timestamp skew (%d) > max (%d), using real ts instead.\n",
-						abs(ms - p->nextpred), MAX_TIMESTAMP_SKEW);
+						abs(adjust), MAX_TIMESTAMP_SKEW);
 
 				if (f->samples >= rate) /* check to make sure we don't core dump */
 				{
@@ -6128,11 +6128,12 @@
 		} else {
 			/* On a dataframe, use last value + 3 (to accomodate jitter buffer shrinking) if appropriate unless
 			   it's a genuine frame */
+			adjust = (ms - p->lastsent);
 			if (genuine) {
 				/* genuine (IAX LAGRQ etc) must keep their clock-based stamps */
 				if (ms <= p->lastsent)
 					ms = p->lastsent + 3;
-			} else if (abs(ms - p->lastsent) <= MAX_TIMESTAMP_SKEW) {
+			} else if (abs(adjust) <= MAX_TIMESTAMP_SKEW) {
 				/* non-genuine frames (!?) (DTMF, CONTROL) should be pulled into the predicted stream stamps */
 				ms = p->lastsent + 3;
 			}

Modified: trunk/channels/sip/dialplan_functions.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/sip/dialplan_functions.c?view=diff&rev=433751&r1=433750&r2=433751
==============================================================================
--- trunk/channels/sip/dialplan_functions.c (original)
+++ trunk/channels/sip/dialplan_functions.c Sun Mar 29 21:45:29 2015
@@ -386,7 +386,7 @@
 			for (j = 1.0; j < 10.0; j += 0.3) {
 				*lookup[i].d8 = j;
 				ast_str_substitute_variables(&buffer, 0, chan, ast_str_buffer(varstr));
-				if (sscanf(ast_str_buffer(buffer), "%lf", &cmpdbl) != 1 || fabs(j - cmpdbl > .05)) {
+				if (sscanf(ast_str_buffer(buffer), "%lf", &cmpdbl) != 1 || abs(j - cmpdbl > .05)) {
 					res = AST_TEST_FAIL;
 					ast_test_status_update(test, "%s != %f != %s\n", ast_str_buffer(varstr), j, ast_str_buffer(buffer));
 					break;

Modified: trunk/main/jitterbuf.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/jitterbuf.c?view=diff&rev=433751&r1=433750&r2=433751
==============================================================================
--- trunk/main/jitterbuf.c (original)
+++ trunk/main/jitterbuf.c Sun Mar 29 21:45:29 2015
@@ -139,7 +139,7 @@
 
 	/* check for drastic change in delay */
 	if (jb->info.conf.resync_threshold != -1) {
-		if (abs(*delay - jb->info.last_delay) > threshold) {
+		if (labs(*delay - jb->info.last_delay) > threshold) {
 			jb->info.cnt_delay_discont++;
 			/* resync the jitterbuffer on 3 consecutive discontinuities,
 			 * or immediately if a control frame */

Modified: trunk/res/res_calendar.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_calendar.c?view=diff&rev=433751&r1=433750&r2=433751
==============================================================================
--- trunk/res/res_calendar.c (original)
+++ trunk/res/res_calendar.c Sun Mar 29 21:45:29 2015
@@ -1106,8 +1106,8 @@
 static int add_event_to_list(struct eventlist *events, struct ast_calendar_event *event, time_t start, time_t end)
 {
 	struct evententry *entry, *iter;
-	int event_startdiff = abs(start - event->start);
-	int event_enddiff = abs(end - event->end);
+	long event_startdiff = labs(start - event->start);
+	long event_enddiff = labs(end - event->end);
 	int i = 0;
 
 	if (!(entry = ast_calloc(1, sizeof(*entry)))) {
@@ -1120,16 +1120,16 @@
 
 	if (start == end) {
 		AST_LIST_TRAVERSE_SAFE_BEGIN(events, iter, list) {
-			int startdiff = abs(iter->event->start - start);
-
-			ast_debug(10, "Comparing %s with startdiff %d to %s with startdiff %d\n", event->summary, event_startdiff, iter->event->summary, startdiff);
+			long startdiff = labs(iter->event->start - start);
+
+			ast_debug(10, "Comparing %s with startdiff %ld to %s with startdiff %ld\n", event->summary, event_startdiff, iter->event->summary, startdiff);
 			++i;
 			if (startdiff > event_startdiff) {
 				AST_LIST_INSERT_BEFORE_CURRENT(entry, list);
 				return i;
 			}
 			if (startdiff == event_startdiff) {
-				int enddiff = abs(iter->event->end - end);
+				long enddiff = labs(iter->event->end - end);
 
 				if (enddiff > event_enddiff) {
 					AST_LIST_INSERT_BEFORE_CURRENT(entry, list);

Modified: trunk/res/res_rtp_asterisk.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_rtp_asterisk.c?view=diff&rev=433751&r1=433750&r2=433751
==============================================================================
--- trunk/res/res_rtp_asterisk.c (original)
+++ trunk/res/res_rtp_asterisk.c Sun Mar 29 21:45:29 2015
@@ -3147,10 +3147,10 @@
 		if (ast_tvzero(frame->delivery)) {
 			/* If this isn't an absolute delivery time, Check if it is close to our prediction,
 			   and if so, go with our prediction */
-			if (abs(rtp->lastts - pred) < MAX_TIMESTAMP_SKEW) {
+			if (abs((int)rtp->lastts - pred) < MAX_TIMESTAMP_SKEW) {
 				rtp->lastts = pred;
 			} else {
-				ast_debug(3, "Difference is %d, ms is %u\n", abs(rtp->lastts - pred), ms);
+				ast_debug(3, "Difference is %d, ms is %u\n", abs((int)rtp->lastts - pred), ms);
 				mark = 1;
 			}
 		}
@@ -3161,11 +3161,11 @@
 		rtp->lastts = rtp->lastts + ms * 90;
 		/* If it's close to our prediction, go for it */
 		if (ast_tvzero(frame->delivery)) {
-			if (abs(rtp->lastts - pred) < 7200) {
+			if (abs((int)rtp->lastts - pred) < 7200) {
 				rtp->lastts = pred;
 				rtp->lastovidtimestamp += frame->samples;
 			} else {
-				ast_debug(3, "Difference is %d, ms is %u (%u), pred/ts/samples %u/%d/%d\n", abs(rtp->lastts - pred), ms, ms * 90, rtp->lastts, pred, frame->samples);
+				ast_debug(3, "Difference is %d, ms is %u (%u), pred/ts/samples %u/%d/%d\n", abs((int)rtp->lastts - pred), ms, ms * 90, rtp->lastts, pred, frame->samples);
 				rtp->lastovidtimestamp = rtp->lastts;
 			}
 		}
@@ -3175,11 +3175,11 @@
 		rtp->lastts = rtp->lastts + ms;
 		/* If it's close to our prediction, go for it */
 		if (ast_tvzero(frame->delivery)) {
-			if (abs(rtp->lastts - pred) < 7200) {
+			if (abs((int)rtp->lastts - pred) < 7200) {
 				rtp->lastts = pred;
 				rtp->lastotexttimestamp += frame->samples;
 			} else {
-				ast_debug(3, "Difference is %d, ms is %u, pred/ts/samples %u/%d/%d\n", abs(rtp->lastts - pred), ms, rtp->lastts, pred, frame->samples);
+				ast_debug(3, "Difference is %d, ms is %u, pred/ts/samples %u/%d/%d\n", abs((int)rtp->lastts - pred), ms, rtp->lastts, pred, frame->samples);
 				rtp->lastotexttimestamp = rtp->lastts;
 			}
 		}




More information about the asterisk-commits mailing list