diff options
author | David M. Lee <dlee@digium.com> | 2012-09-10 19:22:54 +0000 |
---|---|---|
committer | David M. Lee <dlee@digium.com> | 2012-09-10 19:22:54 +0000 |
commit | 1f0f8694d8434ff38f8469f126dcc0ab8fedc9a0 (patch) | |
tree | f63cce364e0eadb54a053bb80a70926b0ea0d35c /res/res_rtp_asterisk.c | |
parent | 9c9acc50e65963fd75cbbd8b51a5cd3ceaf9f208 (diff) |
res_rtp_asterisk: Eliminate "type-punned pointer" build warning.
Removes "res_rtp_asterisk.c:706: warning: dereferencing type-punned pointer
will break strict-aliasing rules" warning from the build on 32-bit platforms.
The problem is that 'size' was referenced aliased to both (pj_size_t *) and
(pj_ssize_t *). Now just make a copy of size that is the right type so there
isn't any pointer aliasing happening.
It also adds comments and asserts regarding what looks like an inappropriate
use of pj_sock_sendto, but is actually totally fine.
(closes issue ASTERISK-20368)
Reported by: Shaun Ruffell
Tested by: Michael L. Young
Patches:
0001-res_rtp_asterisk-Eliminate-type-punned-pointer-build.patch uploaded by Shaun Ruffell (license 5417)
slightly modified by David M. Lee.
........
Merged revisions 372777 from http://svn.asterisk.org/svn/asterisk/branches/11
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@372787 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_rtp_asterisk.c')
-rw-r--r-- | res/res_rtp_asterisk.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/res/res_rtp_asterisk.c b/res/res_rtp_asterisk.c index 9a78dbdc8..9283f8083 100644 --- a/res/res_rtp_asterisk.c +++ b/res/res_rtp_asterisk.c @@ -700,14 +700,19 @@ static pj_status_t ast_rtp_on_ice_tx_pkt(pj_ice_sess *ice, unsigned comp_id, uns { struct ast_rtp *rtp = ice->user_data; pj_status_t status = PJ_EINVALIDOP; + pj_ssize_t _size = (pj_ssize_t)size; if (transport_id == TRANSPORT_SOCKET_RTP) { /* Traffic is destined to go right out the RTP socket we already have */ - status = pj_sock_sendto(rtp->s, pkt, (pj_ssize_t*)&size, 0, dst_addr, dst_addr_len); + status = pj_sock_sendto(rtp->s, pkt, &_size, 0, dst_addr, dst_addr_len); + /* sendto on a connectionless socket should send all the data, or none at all */ + ast_assert(_size == size || status != PJ_SUCCESS); } else if (transport_id == TRANSPORT_SOCKET_RTCP) { /* Traffic is destined to go right out the RTCP socket we already have */ if (rtp->rtcp) { - status = pj_sock_sendto(rtp->rtcp->s, pkt, (pj_ssize_t*)&size, 0, dst_addr, dst_addr_len); + status = pj_sock_sendto(rtp->rtcp->s, pkt, &_size, 0, dst_addr, dst_addr_len); + /* sendto on a connectionless socket should send all the data, or none at all */ + ast_assert(_size == size || status != PJ_SUCCESS); } else { status = PJ_SUCCESS; } |