[Home]

Summary:ASTERISK-25592: chan_unistim: Clang Warning: variable sized type not at end of a struct
Reporter:Alexander Traud (traud)Labels:patch
Date Opened:2015-11-25 07:57:32.000-0600Date Closed:2019-09-10 08:35:06
Priority:MinorRegression?
Status:Closed/CompleteComponents:Channels/chan_unistim
Versions:13.6.0 Frequency of
Occurrence
Related
Issues:
Environment:Clang 3.3Attachments:( 0) unistim.clang.patch
Description:{{chan_unistim.c:1003:18: warning: field 'cm' with variable sized type 'struct cmsghdr' not at the end of a struct}}

This happened on Ubuntu 14.04 LTS:
{{sudo apt-get -y install build-essential libssl-dev libncurses-dev libnewt-dev libxml2-dev libsqlite3-dev uuid-dev libjansson-dev libblocksruntime-dev git iwyu}}
{{cd /usr/src/}}
{{git clone http://gerrit.asterisk.org/asterisk}}
{{cd asterisk/}}
{{CC=clang CXX=clang++ ./configure}}
{{make}}

The affected source code was introduced with [Mantis-8864|http://bugs.digium.com/view.php?id=8864]. I have no idea what this code does and how it works. Therefore, I cannot provide a patch.
Comments:By: Rusty Newton (rnewton) 2015-11-25 08:36:55.970-0600

Igor is the community maintainer for this module. Assign to Igor for triage.

By: Igor Goncharovsky (igorg) 2015-12-30 02:50:47.917-0600

Please test patch attached

By: Rusty Newton (rnewton) 2016-01-05 15:24:40.315-0600

Setting this to Waiting On Feedback while the patch gets tested.

By: Asterisk Team (asteriskteam) 2016-01-20 12:00:19.901-0600

Suspended due to lack of activity. This issue will be automatically re-opened if the reporter posts a comment. If you are not the reporter and would like this re-opened please create a new issue instead. If the new issue is related to this one a link will be created during the triage process. Further information on issue tracker usage can be found in the Asterisk Issue Guidlines [1].

[1] https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines

By: Alexander Traud (traud) 2016-01-22 04:39:59.407-0600

Sorry, I do not understand what is required by me. Please, explain in greater detail. My current guess:

On 5th January, I was declared as ‘Assignee’ and the status was changed to ‘Waiting for Feedback’. As stated before, I have no knowledge, what this code does. Therefore, I cannot comment on the correctness of that patch. I am able to confirm that the warning on the console does not happen, after applying that patch.

On the contrary, I cannot say anything about the quality of that patch. {{channels/chan_unistim:get_to_address(…)}} creates and uses this struct. This struct is used to extract data from the wire. Therefore, I do not understand:
* How is it possible just to change the order within the struct?
Or stated differently: After looking at [a code example from StackOverflow|http://stackoverflow.com/questions/3062205],
* Isn’t {{in_addr address}} part of {{cmsghdr->cmsg_data}}?
* If it is, why is {{cmsghdr}} not accessed via its {{CMSG_*(…)}} to extract that IP address?

By: Asterisk Team (asteriskteam) 2016-01-22 04:40:00.312-0600

This issue has been reopened as a result of your commenting on it as the reporter. It will be triaged once again as applicable.

By: Igor Goncharovsky (igorg) 2016-01-26 17:28:51.512-0600

Alexander, I agree, this patch is wrong. I'll try to find a proper way to avoid this warning message while reading packet header when using clang.

By: George Joseph (gjoseph) 2016-02-05 12:04:41.435-0600

Any progress on this?
If the structure needs to stay as is we can add "#pragma GCC ingored" so it doesn't cause the error..
We can also make it an optional module so it only gets compiled if it's explicitly selected.


By: Alexander Traud (traud) 2016-02-05 12:47:41.055-0600

No pragma, please. As Igor pointed out, he was misusing the struct {{cmsghdr}} when he wrote that code years ago. The compiler clang just pointed out this mistake. Ideally, this code part is re-written to use CMSG_NXTHDR(…) and so on.

By: Igor Goncharovsky (igorg) 2016-02-06 17:02:43.697-0600

There is solution described here to read properly ip address:
http://stackoverflow.com/questions/5281409/get-destination-address-of-a-received-udp-packet

If this looks like proper solution, I'll update chan_unistim. Is it?

By: Friendly Automation (friendly-automation) 2019-09-10 08:35:07.552-0500

Change 12809 merged by Friendly Automation:
chan_unistim: Fix clang warning: variable sized type not at end of a struct

[https://gerrit.asterisk.org/c/asterisk/+/12809|https://gerrit.asterisk.org/c/asterisk/+/12809]

By: Friendly Automation (friendly-automation) 2019-09-10 08:44:11.335-0500

Change 12807 merged by George Joseph:
chan_unistim: Fix clang warning: variable sized type not at end of a struct

[https://gerrit.asterisk.org/c/asterisk/+/12807|https://gerrit.asterisk.org/c/asterisk/+/12807]

By: Friendly Automation (friendly-automation) 2019-09-10 08:44:25.818-0500

Change 12808 merged by George Joseph:
chan_unistim: Fix clang warning: variable sized type not at end of a struct

[https://gerrit.asterisk.org/c/asterisk/+/12808|https://gerrit.asterisk.org/c/asterisk/+/12808]

By: Friendly Automation (friendly-automation) 2019-09-10 08:44:39.951-0500

Change 12810 merged by George Joseph:
chan_unistim: Fix clang warning: variable sized type not at end of a struct

[https://gerrit.asterisk.org/c/asterisk/+/12810|https://gerrit.asterisk.org/c/asterisk/+/12810]