From aef569172b1b115e89dd7b09a40f8c45b22dc4b7 Mon Sep 17 00:00:00 2001 From: Kathleen King Date: Thu, 3 Jul 2014 13:17:12 -0700 Subject: [PATCH] Removed a useless called to abs. Clang 3.5 reported the following error: error: taking the absolute value of unsigned type 'unsigned int' has no effect [-Werror,-Wabsolute-value] Subtracting unsigned variables will never be negative and will either be the small expected value or will wrap to a very big value. This code is trying to determine if the difference between these timestamps is greater than 16000. The variables last_write_ts and this_ts deal with timestamps. In the normal case this_ts will be a larger timestamp than last_write_ts. This change will maintain the intended behavior of reseting the video if the difference is larger than 16000 and in the abnormal case this value would wrap and still exceed the 16000. --- src/switch_rtp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/switch_rtp.c b/src/switch_rtp.c index eccce9d71c..de6a238852 100644 --- a/src/switch_rtp.c +++ b/src/switch_rtp.c @@ -6341,7 +6341,7 @@ static int rtp_common_write(switch_rtp_t *rtp_session, if (!switch_rtp_test_flag(rtp_session, SWITCH_RTP_FLAG_VIDEO)) { this_ts = ntohl(send_msg->header.ts); - if (abs(rtp_session->last_write_ts - this_ts) > 16000) { + if ((this_ts - rtp_session->last_write_ts) > 16000) { rtp_session->flags[SWITCH_RTP_FLAG_RESET] = 1; }