[Asterisk-code-review] translate: Avoid absolute value on unsigned substraction. (asterisk[master])

Corey Farrell asteriskteam at digium.com
Fri Jan 5 13:36:25 CST 2018


Corey Farrell has posted comments on this change. ( https://gerrit.asterisk.org/7815 )

Change subject: translate: Avoid absolute value on unsigned substraction.
......................................................................


Patch Set 1: Code-Review-1

(1 comment)

https://gerrit.asterisk.org/#/c/7815/1/main/translate.c
File main/translate.c:

https://gerrit.asterisk.org/#/c/7815/1/main/translate.c@1418
PS1, Line 1418: 				unsigned int gap_selected_dst = ast_format_get_sample_rate(bestdst);
I agree the change is needed but I think the fix should be implemented in a macro (probably in asterisk/utils.h).

Potential macro implementation:
#define ast_unsigned_diff(a, b) ({ \
  typeof(a) __a = a; \
  typeof(b) __b = b; \
  (__a > __b ? __a - __b : __b - __a); \
})

Then this file could be fixed without making the code harder to read.



-- 
To view, visit https://gerrit.asterisk.org/7815
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Ib904d9ee0d46b6fdd1476fbc464fbbf813304017
Gerrit-Change-Number: 7815
Gerrit-PatchSet: 1
Gerrit-Owner: Alexander Traud <pabstraud at compuserve.com>
Gerrit-Reviewer: Alexander Traud <pabstraud at compuserve.com>
Gerrit-Reviewer: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Comment-Date: Fri, 05 Jan 2018 19:36:25 +0000
Gerrit-HasComments: Yes
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180105/79ed35a4/attachment.html>


More information about the asterisk-code-review mailing list