From 5f8faf16af107855e6afa2574b3e9436ed20250c Mon Sep 17 00:00:00 2001 From: Matthew Jordan Date: Mon, 30 Mar 2015 02:44:57 +0000 Subject: 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 git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@433750 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- channels/chan_iax2.c | 13 +++++++------ channels/sip/dialplan_functions.c | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'channels') diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index e1fbbd10d..eeec1e1f1 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -5999,7 +5999,7 @@ static unsigned int calc_txpeerstamp(struct iax2_trunk_peer *tpeer, int sampms, 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 */ @@ -6072,7 +6072,8 @@ static unsigned int calc_timestamp(struct chan_iax2_pvt *p, unsigned int ts, str 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 @@ -6091,7 +6092,6 @@ static unsigned int calc_timestamp(struct chan_iax2_pvt *p, unsigned int ts, str 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) @@ -6113,9 +6113,9 @@ static unsigned int calc_timestamp(struct chan_iax2_pvt *p, unsigned int ts, str * 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 */ { @@ -6141,11 +6141,12 @@ static unsigned int calc_timestamp(struct chan_iax2_pvt *p, unsigned int ts, str } 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; } diff --git a/channels/sip/dialplan_functions.c b/channels/sip/dialplan_functions.c index c3e113a83..5ee66fbdb 100644 --- a/channels/sip/dialplan_functions.c +++ b/channels/sip/dialplan_functions.c @@ -386,7 +386,7 @@ AST_TEST_DEFINE(test_sip_rtpqos_1) 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; -- cgit v1.2.3