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

Friendly Automation (JIRA) noreply at issues.asterisk.org
Mon Jan 8 06:48:39 CST 2018


    [ https://issues.asterisk.org/jira/browse/ASTERISK-27557?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=241407#comment-241407 ] 

Friendly Automation commented on ASTERISK-27557:
------------------------------------------------

Change 7851 merged by Jenkins2:
General: Avoid implicit conversion to char when changes value to negative.

[https://gerrit.asterisk.org/7851|https://gerrit.asterisk.org/7851]

> [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: 13.18.5, 15.1.5
>            Reporter: Alexander Traud
>            Assignee: Alexander Traud
>            Severity: Minor
>              Labels: patch
>         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