Author: mjordan Date: Sun Mar 29 21:44:21 2015 New Revision: 433749 URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=433749 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) Modified: branches/11/apps/app_queue.c branches/11/channels/chan_iax2.c branches/11/channels/sip/dialplan_functions.c branches/11/main/jitterbuf.c branches/11/res/res_calendar.c branches/11/res/res_rtp_asterisk.c Modified: branches/11/apps/app_queue.c URL: http://svnview.digium.com/svn/asterisk/branches/11/apps/app_queue.c?view=diff&rev=433749&r1=433748&r2=433749 ============================================================================== --- branches/11/apps/app_queue.c (original) +++ branches/11/apps/app_queue.c Sun Mar 29 21:44:21 2015 @@ -3129,7 +3129,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; @@ -3203,23 +3204,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; @@ -5568,11 +5569,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: branches/11/channels/chan_iax2.c URL: http://svnview.digium.com/svn/asterisk/branches/11/channels/chan_iax2.c?view=diff&rev=433749&r1=433748&r2=433749 ============================================================================== --- branches/11/channels/chan_iax2.c (original) +++ branches/11/channels/chan_iax2.c Sun Mar 29 21:44:21 2015 @@ -6062,7 +6062,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 */ @@ -6134,7 +6134,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 @@ -6153,7 +6154,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) @@ -6175,9 +6175,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 */ { @@ -6203,11 +6203,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: branches/11/channels/sip/dialplan_functions.c URL: http://svnview.digium.com/svn/asterisk/branches/11/channels/sip/dialplan_functions.c?view=diff&rev=433749&r1=433748&r2=433749 ============================================================================== --- branches/11/channels/sip/dialplan_functions.c (original) +++ branches/11/channels/sip/dialplan_functions.c Sun Mar 29 21:44:21 2015 @@ -384,7 +384,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: branches/11/main/jitterbuf.c URL: http://svnview.digium.com/svn/asterisk/branches/11/main/jitterbuf.c?view=diff&rev=433749&r1=433748&r2=433749 ============================================================================== --- branches/11/main/jitterbuf.c (original) +++ branches/11/main/jitterbuf.c Sun Mar 29 21:44:21 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: branches/11/res/res_calendar.c URL: http://svnview.digium.com/svn/asterisk/branches/11/res/res_calendar.c?view=diff&rev=433749&r1=433748&r2=433749 ============================================================================== --- branches/11/res/res_calendar.c (original) +++ branches/11/res/res_calendar.c Sun Mar 29 21:44:21 2015 @@ -1080,8 +1080,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)))) { @@ -1094,16 +1094,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: branches/11/res/res_rtp_asterisk.c URL: http://svnview.digium.com/svn/asterisk/branches/11/res/res_rtp_asterisk.c?view=diff&rev=433749&r1=433748&r2=433749 ============================================================================== --- branches/11/res/res_rtp_asterisk.c (original) +++ branches/11/res/res_rtp_asterisk.c Sun Mar 29 21:44:21 2015 @@ -3123,10 +3123,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; } } @@ -3137,11 +3137,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; } } @@ -3151,11 +3151,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; } } -- _____________________________________________________________________ -- Bandwidth and Colocation Provided by http://www.api-digital.com -- svn-commits mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/svn-commits