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


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@433751 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Matthew Jordan
2015-03-30 02:45:29 +00:00
parent ce59fabd5c
commit 7bc2345fb1
6 changed files with 31 additions and 29 deletions

View File

@@ -1106,8 +1106,8 @@ static struct ast_custom_function calendar_busy_function = {
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 @@ static int add_event_to_list(struct eventlist *events, struct ast_calendar_event
if (start == end) {
AST_LIST_TRAVERSE_SAFE_BEGIN(events, iter, list) {
int startdiff = abs(iter->event->start - start);
long startdiff = labs(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);
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);

View File

@@ -3147,10 +3147,10 @@ static int ast_rtp_raw_write(struct ast_rtp_instance *instance, struct ast_frame
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 @@ static int ast_rtp_raw_write(struct ast_rtp_instance *instance, struct ast_frame
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 @@ static int ast_rtp_raw_write(struct ast_rtp_instance *instance, struct ast_frame
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;
}
}