[asterisk-bugs] [JIRA] (ASTERISK-27557) [patch] clang 5.0: implicit conversion to char changes value to negative.

Alexander Traud (JIRA) noreply at issues.asterisk.org
Sat Jan 6 01:20:40 CST 2018


Alexander Traud created ASTERISK-27557:
------------------------------------------

             Summary: [patch] clang 5.0: implicit conversion to char changes value to negative.
                 Key: ASTERISK-27557
                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-27557
             Project: Asterisk
          Issue Type: Bug
      Security Level: None
          Components: Addons/chan_ooh323, Applications/app_adsiprog, Applications/app_sms, Resources/res_http_websocket
    Affects Versions: 15.1.5, 13.18.5
            Reporter: Alexander Traud
            Severity: Minor
         Attachments: we_do_bytes_part_1.patch, we_do_bytes_part_2.patch, we_do_bytes_part_3.patch

The compiler _clang_ (5.0.1) reports:{code}warning: implicit conversion from 'int' to 'char' changes value from 191 to -65 [-Wconstant-conversion]{code}This happens at six places (four modules) in the current Asterisk source code. In all cases, the integer value is a byte/flag actually. Two approaches are known to solve this:
A) change the literal to hexadecimal, for example {{*p++ = 191}} to *p++ = 0xbf}}
B) change the type to {{unsigned char}} for example {{char frame\[4\]}} to {{unsigned char frame\[4\]}}.

Approach B is to prefer when possible†, [see...|http://www.soundsoftware.ac.uk/c-pitfall-unsigned]
† The ABI does not change, for example in case of local variables.



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



More information about the asterisk-bugs mailing list