[svn-commits] dlee: trunk r372787 - in /trunk: ./ res/res_rtp_asterisk.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Sep 10 14:22:58 CDT 2012


Author: dlee
Date: Mon Sep 10 14:22:54 2012
New Revision: 372787

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=372787
Log:
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 Ruffel
Tested by: Michael L. Young
Patches:
  0001-res_rtp_asterisk-Eliminate-type-punned-pointer-build.patch uploaded by Shaun Ruffel (license 5417)
    slightly modified by David M. Lee.
........

Merged revisions 372777 from http://svn.asterisk.org/svn/asterisk/branches/11

Modified:
    trunk/   (props changed)
    trunk/res/res_rtp_asterisk.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-11-merged' - no diff available.

Modified: trunk/res/res_rtp_asterisk.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_rtp_asterisk.c?view=diff&rev=372787&r1=372786&r2=372787
==============================================================================
--- trunk/res/res_rtp_asterisk.c (original)
+++ trunk/res/res_rtp_asterisk.c Mon Sep 10 14:22:54 2012
@@ -700,14 +700,19 @@
 {
 	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;
 		}




More information about the svn-commits mailing list