[asterisk-commits] trunk r29265 - /trunk/channels/chan_sip.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sun May 21 17:17:46 MST 2006


Author: rizzo
Date: Sun May 21 19:17:46 2006
New Revision: 29265

URL: http://svn.digium.com/view/asterisk?rev=29265&view=rev
Log:
simplify logic in function create_addr()


Modified:
    trunk/channels/chan_sip.c

Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?rev=29265&r1=29264&r2=29265&view=diff
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Sun May 21 19:17:46 2006
@@ -2190,7 +2190,9 @@
 	return u;
 }
 
-/*! \brief Create address structure from peer reference */
+/*! \brief Create address structure from peer reference.
+ *  return -1 on error, 0 on success.
+ */
 static int create_addr_from_peer(struct sip_pvt *r, struct sip_peer *peer)
 {
 	int natflags;
@@ -2283,7 +2285,6 @@
 	struct hostent *hp;
 	struct ast_hostent ahp;
 	struct sip_peer *p;
-	int found=0;
 	char *port;
 	int portno;
 	char host[MAXHOSTNAMELEN], *hostn;
@@ -2298,14 +2299,10 @@
 	p = find_peer(peer, NULL, 1);
 
 	if (p) {
-		found++;
-		if (create_addr_from_peer(dialog, p))
-			ASTOBJ_UNREF(p, sip_destroy_peer);
-	}
-	if (!p) {
-		if (found)
-			return -1;
-
+		int res = create_addr_from_peer(dialog, p);
+		ASTOBJ_UNREF(p, sip_destroy_peer);
+		return res;
+	} else {
 		hostn = peer;
 		portno = port ? atoi(port) : DEFAULT_SIP_PORT;
 		if (srvlookup) {
@@ -2330,9 +2327,6 @@
 			ast_log(LOG_WARNING, "No such host: %s\n", peer);
 			return -1;
 		}
-	} else {
-		ASTOBJ_UNREF(p, sip_destroy_peer);
-		return 0;
 	}
 }
 



More information about the asterisk-commits mailing list