[svn-commits] twilson: trunk r293809 - in /trunk: ./ channels/ include/asterisk/ main/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Nov 3 13:43:22 CDT 2010


Author: twilson
Date: Wed Nov  3 13:43:18 2010
New Revision: 293809

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=293809
Log:
Merged revisions 293803 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.8

........
  r293803 | twilson | 2010-11-03 11:05:14 -0700 (Wed, 03 Nov 2010) | 25 lines
  
  Avoid valgrind warnings for ast_rtp_instance_get_xxx_address
  
  The documentation for ast_rtp_instance_get_(local/remote)_address stated that
  they returned 0 for success and -1 on failure. Instead, they returned 0 if the
  address structure passed in was already equivalent to the address instance
  local/remote address or 1 otherwise. 90% of the calls to these functions
  completely ignored the return address and passed in an uninitialized struct,
  which would make valgrind complain even though the operation was technically
  safe.
  
  This patch fixes the documentation and converts the get_xxx_address functions
  to void since all they really do is copy the address and cannot fail.
  Additionally two new functions
  (ast_rtp_instance_get_and_cmp_(local/remote)_address) are created for the 3
  times where the return value was actually checked. The
  get_and_cmp_local_address function is currently unused, but exists for the sake
  of symmetry.
  
  The only functional change as a result of this change is that we will not do an
  ast_sockaddr_cmp() on (mostly uninitialized) addresses before doing the
  ast_sockaddr_copy() in the get_*_address functions. So, even though it is an
  API change, it shouldn't have a noticeable change in behavior.
  
  Review: https://reviewboard.asterisk.org/r/995/
........

Modified:
    trunk/   (props changed)
    trunk/channels/chan_sip.c
    trunk/include/asterisk/rtp_engine.h
    trunk/main/rtp_engine.c

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

Modified: trunk/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_sip.c?view=diff&rev=293809&r1=293808&r2=293809
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Wed Nov  3 13:43:18 2010
@@ -27686,19 +27686,19 @@
 	}
 
 	if (instance) {
-		changed |= ast_rtp_instance_get_remote_address(instance, &p->redirip);
+		changed |= ast_rtp_instance_get_and_cmp_remote_address(instance, &p->redirip);
 	} else if (!ast_sockaddr_isnull(&p->redirip)) {
 		memset(&p->redirip, 0, sizeof(p->redirip));
 		changed = 1;
 	}
 	if (vinstance) {
-		changed |= ast_rtp_instance_get_remote_address(vinstance, &p->vredirip);
+		changed |= ast_rtp_instance_get_and_cmp_remote_address(vinstance, &p->vredirip);
 	} else if (!ast_sockaddr_isnull(&p->vredirip)) {
 		memset(&p->vredirip, 0, sizeof(p->vredirip));
 		changed = 1;
 	}
 	if (tinstance) {
-		changed |= ast_rtp_instance_get_remote_address(tinstance, &p->tredirip);
+		changed |= ast_rtp_instance_get_and_cmp_remote_address(tinstance, &p->tredirip);
 	} else if (!ast_sockaddr_isnull(&p->tredirip)) {
 		memset(&p->tredirip, 0, sizeof(p->tredirip));
 		changed = 1;

Modified: trunk/include/asterisk/rtp_engine.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/rtp_engine.h?view=diff&rev=293809&r1=293808&r2=293809
==============================================================================
--- trunk/include/asterisk/rtp_engine.h (original)
+++ trunk/include/asterisk/rtp_engine.h Wed Nov  3 13:43:18 2010
@@ -720,9 +720,6 @@
  * \param instance The RTP instance to get the address from
  * \param address The variable to store the address in
  *
- * \retval 0 success
- * \retval -1 failure
- *
  * Example usage:
  *
  * \code
@@ -734,7 +731,30 @@
  *
  * \since 1.8
  */
-int ast_rtp_instance_get_local_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address);
+void ast_rtp_instance_get_local_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address);
+
+/*!
+ * \brief Get the address of the local endpoint that we are sending RTP to, comparing its address to another
+ *
+ * \param instance The instance that we want to get the local address for
+ * \param address An initialized address that may be overwritten if the local address is different
+ *
+ * \retval 0 address was not changed
+ * \retval 1 address was changed
+ * Example usage:
+ *
+ * \code
+ * struct ast_sockaddr address;
+ * int ret;
+ * ret = ast_rtp_instance_get_and_cmp_local_address(instance, &address);
+ * \endcode
+ *
+ * This retrieves the current local address set on the instance pointed to by instance and puts the value
+ * into the address structure.
+ *
+ * \since 1.8
+ */
+int ast_rtp_instance_get_and_cmp_local_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address);
 
 /*!
  * \brief Get the address of the remote endpoint that we are sending RTP to
@@ -742,9 +762,6 @@
  * \param instance The instance that we want to get the remote address for
  * \param address A structure to put the address into
  *
- * \retval 0 success
- * \retval -1 failure
- *
  * Example usage:
  *
  * \code
@@ -757,7 +774,31 @@
  *
  * \since 1.8
  */
-int ast_rtp_instance_get_remote_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address);
+void ast_rtp_instance_get_remote_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address);
+
+/*!
+ * \brief Get the address of the remote endpoint that we are sending RTP to, comparing its address to another
+ *
+ * \param instance The instance that we want to get the remote address for
+ * \param address An initialized address that may be overwritten if the remote address is different
+ *
+ * \retval 0 address was not changed
+ * \retval 1 address was changed
+ * Example usage:
+ *
+ * \code
+ * struct ast_sockaddr address;
+ * int ret;
+ * ret = ast_rtp_instance_get_and_cmp_remote_address(instance, &address);
+ * \endcode
+ *
+ * This retrieves the current remote address set on the instance pointed to by instance and puts the value
+ * into the address structure.
+ *
+ * \since 1.8
+ */
+
+int ast_rtp_instance_get_and_cmp_remote_address(struct ast_rtp_instance *instance, struct ast_sockaddr *address);
 
 /*!
  * \brief Set the value of an RTP instance extended property

Modified: trunk/main/rtp_engine.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/rtp_engine.c?view=diff&rev=293809&r1=293808&r2=293809
==============================================================================
--- trunk/main/rtp_engine.c (original)
+++ trunk/main/rtp_engine.c Wed Nov  3 13:43:18 2010
@@ -410,7 +410,7 @@
 	return 0;
 }
 
-int ast_rtp_instance_get_local_address(struct ast_rtp_instance *instance,
+int ast_rtp_instance_get_and_cmp_local_address(struct ast_rtp_instance *instance,
 		struct ast_sockaddr *address)
 {
 	if (ast_sockaddr_cmp(address, &instance->local_address) != 0) {
@@ -421,7 +421,13 @@
 	return 0;
 }
 
-int ast_rtp_instance_get_remote_address(struct ast_rtp_instance *instance,
+void ast_rtp_instance_get_local_address(struct ast_rtp_instance *instance,
+		struct ast_sockaddr *address)
+{
+	ast_sockaddr_copy(address, &instance->local_address);
+}
+
+int ast_rtp_instance_get_and_cmp_remote_address(struct ast_rtp_instance *instance,
 		struct ast_sockaddr *address)
 {
 	if (ast_sockaddr_cmp(address, &instance->remote_address) != 0) {
@@ -430,6 +436,12 @@
 	}
 
 	return 0;
+}
+
+void ast_rtp_instance_get_remote_address(struct ast_rtp_instance *instance,
+		struct ast_sockaddr *address)
+{
+	ast_sockaddr_copy(address, &instance->remote_address);
 }
 
 void ast_rtp_instance_set_extended_prop(struct ast_rtp_instance *instance, int property, void *value)




More information about the svn-commits mailing list