aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authortwilson <twilson@f38db490-d61c-443f-a65b-d21fe96a405b>2010-11-03 18:05:14 +0000
committertwilson <twilson@f38db490-d61c-443f-a65b-d21fe96a405b>2010-11-03 18:05:14 +0000
commit88cfac188620a17fb9105439c2c7c1aff1ed53bd (patch)
treeb7916ec13ed52ca76d96ef6e0528344e164271eb /main
parentcc876d6a1d8cb5092defaa7867c9c10e1b8808d6 (diff)
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/ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.8@293803 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main')
-rw-r--r--main/rtp_engine.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/main/rtp_engine.c b/main/rtp_engine.c
index ff8ebd481..0fecff8cf 100644
--- a/main/rtp_engine.c
+++ b/main/rtp_engine.c
@@ -410,7 +410,7 @@ int ast_rtp_instance_set_alt_remote_address(struct ast_rtp_instance *instance,
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 @@ int ast_rtp_instance_get_local_address(struct ast_rtp_instance *instance,
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) {
@@ -432,6 +438,12 @@ int ast_rtp_instance_get_remote_address(struct ast_rtp_instance *instance,
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)
{
if (instance->engine->extended_prop_set) {