[asterisk-bugs] [JIRA] (ASTERISK-27549) [patch] translate: Avoid absolute value on unsigned substraction.

Alexander Traud (JIRA) noreply at issues.asterisk.org
Fri Jan 5 05:49:39 CST 2018


Alexander Traud created ASTERISK-27549:
------------------------------------------

             Summary: [patch] translate: Avoid absolute value on unsigned substraction.
                 Key: ASTERISK-27549
                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-27549
             Project: Asterisk
          Issue Type: Bug
      Security Level: None
          Components: Formats/General
    Affects Versions: 13.19.0, 15.2.0
            Reporter: Alexander Traud
         Attachments: clang_translate.patch

The compiler _clang_ reports:
{code}translate.c:1418:24: warning: taking the absolute value of unsigned type 'unsigned int' has no effect [-Wabsolute-value]
                                int gap_selected = abs(ast_format_get_sample_rate(best)
                                                   ^
translate.c:1418:24: note: remove the call to 'abs' since unsigned values cannot be negative
                                int gap_selected = abs(ast_format_get_sample_rate(best)
                                                   ^~~
translate.c:1420:23: warning: taking the absolute value of unsigned type 'unsigned int' has no effect [-Wabsolute-value]
                                int gap_current = abs(ast_format_get_sample_rate(src)
                                                  ^
translate.c:1420:23: note: remove the call to 'abs' since unsigned values cannot be negative
                                int gap_current = abs(ast_format_get_sample_rate(src){code}Reporting my own code. I missed, that an unsigned type is returned by ast_format_get_sample_rate(.). More [details...|http://www.soundsoftware.ac.uk/c-pitfall-unsigned] The attached patch is [based on...|http://stackoverflow.com/a/27833306]



--
This message was sent by Atlassian JIRA
(v6.2#6252)



More information about the asterisk-bugs mailing list