[vlc-commits] vlc_getaddrinfo: remove useless parameter

Rémi Denis-Courmont git at videolan.org
Sun Aug 19 15:44:49 CEST 2012


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Aug 19 16:22:39 2012 +0300| [ad370e1ed3aaae8c1a66f290b51b6d3ea0286ed5] | committer: Rémi Denis-Courmont

vlc_getaddrinfo: remove useless parameter

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ad370e1ed3aaae8c1a66f290b51b6d3ea0286ed5
---

 include/vlc_network.h         |    2 +-
 modules/stream_out/standard.c |    4 ++--
 src/network/getaddrinfo.c     |    8 ++------
 src/network/io.c              |    2 +-
 src/network/tcp.c             |   20 ++++++++++----------
 src/network/udp.c             |   17 ++++++++---------
 src/stream_output/announce.c  |    2 +-
 7 files changed, 25 insertions(+), 30 deletions(-)

diff --git a/include/vlc_network.h b/include/vlc_network.h
index 0102bb3..8cfc27f 100644
--- a/include/vlc_network.h
+++ b/include/vlc_network.h
@@ -260,7 +260,7 @@ VLC_API int  getnameinfo ( const struct sockaddr *, socklen_t,
 #endif
 
 VLC_API int vlc_getnameinfo( const struct sockaddr *, int, char *, int, int *, int );
-VLC_API int vlc_getaddrinfo (vlc_object_t *, const char *, unsigned,
+VLC_API int vlc_getaddrinfo (const char *, unsigned,
                              const struct addrinfo *, struct addrinfo **);
 
 
diff --git a/modules/stream_out/standard.c b/modules/stream_out/standard.c
index 72efd20..93f072f 100644
--- a/modules/stream_out/standard.c
+++ b/modules/stream_out/standard.c
@@ -167,13 +167,13 @@ static void create_SDP(sout_stream_t *p_stream, sout_access_out_t *p_access)
     socklen_t srclen = 0, dstlen = 0;
     struct addrinfo *res;
 
-    if (!vlc_getaddrinfo ( VLC_OBJECT(p_stream), dhost, dport, &hints, &res))
+    if (!vlc_getaddrinfo (dhost, dport, &hints, &res))
     {
         memcpy (&dst, res->ai_addr, dstlen = res->ai_addrlen);
         freeaddrinfo (res);
     }
 
-    if (!vlc_getaddrinfo ( VLC_OBJECT(p_stream), shost, sport, &hints, &res))
+    if (!vlc_getaddrinfo (shost, sport, &hints, &res))
     {
         memcpy (&src, res->ai_addr, srclen = res->ai_addrlen);
         freeaddrinfo (res);
diff --git a/src/network/getaddrinfo.c b/src/network/getaddrinfo.c
index dfc3242..f0b9d44 100644
--- a/src/network/getaddrinfo.c
+++ b/src/network/getaddrinfo.c
@@ -80,9 +80,8 @@ int vlc_getnameinfo( const struct sockaddr *sa, int salen,
  * On failure, *res is undefined. On success, it must be freed with
  * freeaddrinfo().
  */
-int vlc_getaddrinfo (vlc_object_t *p_this, const char *node,
-                     unsigned port, const struct addrinfo *p_hints,
-                     struct addrinfo **res)
+int vlc_getaddrinfo (const char *node, unsigned port,
+                     const struct addrinfo *p_hints, struct addrinfo **res)
 {
     struct addrinfo hints;
     char psz_buf[NI_MAXHOST], portbuf[6], *servname;
@@ -94,10 +93,7 @@ int vlc_getaddrinfo (vlc_object_t *p_this, const char *node,
     if (port != 0)
     {
         if (port > 65535)
-        {
-            msg_Err (p_this, "invalid port number %u specified", port);
             return EAI_SERVICE;
-        }
         /* cannot overflow */
         snprintf (portbuf, sizeof (portbuf), "%u", port);
         servname = portbuf;
diff --git a/src/network/io.c b/src/network/io.c
index 1fc8361..d469ffd 100644
--- a/src/network/io.c
+++ b/src/network/io.c
@@ -137,7 +137,7 @@ int *net_Listen (vlc_object_t *p_this, const char *psz_host,
     msg_Dbg (p_this, "net: listening to %s port %d",
              (psz_host != NULL) ? psz_host : "*", i_port);
 
-    int i_val = vlc_getaddrinfo (p_this, psz_host, i_port, &hints, &res);
+    int i_val = vlc_getaddrinfo (psz_host, i_port, &hints, &res);
     if (i_val)
     {
         msg_Err (p_this, "Cannot resolve %s port %d : %s",
diff --git a/src/network/tcp.c b/src/network/tcp.c
index 9e0442c..8ea3339 100644
--- a/src/network/tcp.c
+++ b/src/network/tcp.c
@@ -78,7 +78,7 @@ int net_Connect( vlc_object_t *p_this, const char *psz_host, int i_port,
     struct addrinfo hints, *res, *ptr;
     const char      *psz_realhost;
     char            *psz_socks;
-    int             i_realport, i_val, i_handle = -1;
+    int             i_realport, i_handle = -1;
 
     int evfd = vlc_object_waitpipe (p_this);
     if (evfd == -1)
@@ -137,13 +137,13 @@ int net_Connect( vlc_object_t *p_this, const char *psz_host, int i_port,
                  i_realport );
     }
 
-    i_val = vlc_getaddrinfo( p_this, psz_realhost, i_realport, &hints, &res );
+    int val = vlc_getaddrinfo (psz_realhost, i_realport, &hints, &res);
     free( psz_socks );
 
-    if( i_val )
+    if (val)
     {
-        msg_Err( p_this, "cannot resolve %s port %d : %s", psz_realhost,
-                 i_realport, gai_strerror( i_val ) );
+        msg_Err (p_this, "cannot resolve %s port %d : %s", psz_realhost,
+                 i_realport, gai_strerror (val));
         return -1;
     }
 
@@ -445,22 +445,22 @@ static int SocksHandshakeTCP( vlc_object_t *p_obj,
 
     if( i_socks_version == 4 )
     {
-        struct addrinfo hints, *p_res;
+        struct addrinfo hints, *res;
 
         /* v4 only support ipv4 */
         memset (&hints, 0, sizeof (hints));
         hints.ai_family = AF_INET;
         hints.ai_socktype = SOCK_STREAM;
         hints.ai_protocol = IPPROTO_TCP;
-        if( vlc_getaddrinfo( p_obj, psz_host, 0, &hints, &p_res ) )
+        if (vlc_getaddrinfo (psz_host, 0, &hints, &res))
             return VLC_EGENERIC;
 
         buffer[0] = i_socks_version;
         buffer[1] = 0x01;               /* CONNECT */
         SetWBE( &buffer[2], i_port );   /* Port */
-        memcpy( &buffer[4],             /* Address */
-                &((struct sockaddr_in *)(p_res->ai_addr))->sin_addr, 4 );
-        freeaddrinfo( p_res );
+        memcpy (&buffer[4],             /* Address */
+                &((struct sockaddr_in *)(res->ai_addr))->sin_addr, 4);
+        freeaddrinfo (res);
 
         buffer[8] = 0;                  /* Empty user id */
 
diff --git a/src/network/udp.c b/src/network/udp.c
index d88e18d..ffa10d5 100644
--- a/src/network/udp.c
+++ b/src/network/udp.c
@@ -150,7 +150,7 @@ static int net_ListenSingle (vlc_object_t *obj, const char *host, int port,
     msg_Dbg (obj, "net: opening %s datagram port %d",
              host ? host : "any", port);
 
-    int val = vlc_getaddrinfo (obj, host, port, &hints, &res);
+    int val = vlc_getaddrinfo (host, port, &hints, &res);
     if (val)
     {
         msg_Err (obj, "Cannot resolve %s port %d : %s", host, port,
@@ -504,7 +504,7 @@ int net_ConnectDgram( vlc_object_t *p_this, const char *psz_host, int i_port,
                       int i_hlim, int proto )
 {
     struct addrinfo hints, *res, *ptr;
-    int             i_val, i_handle = -1;
+    int       i_handle = -1;
     bool      b_unreach = false;
 
     if( i_hlim < 0 )
@@ -516,11 +516,11 @@ int net_ConnectDgram( vlc_object_t *p_this, const char *psz_host, int i_port,
 
     msg_Dbg( p_this, "net: connecting to [%s]:%d", psz_host, i_port );
 
-    i_val = vlc_getaddrinfo( p_this, psz_host, i_port, &hints, &res );
-    if( i_val )
+    int val = vlc_getaddrinfo (psz_host, i_port, &hints, &res);
+    if (val)
     {
-        msg_Err( p_this, "cannot resolve [%s]:%d : %s", psz_host, i_port,
-                 gai_strerror( i_val ) );
+        msg_Err (p_this, "cannot resolve [%s]:%d : %s", psz_host, i_port,
+                 gai_strerror (val));
         return -1;
     }
 
@@ -602,13 +602,12 @@ int net_OpenDgram( vlc_object_t *obj, const char *psz_bind, int i_bind,
              psz_server, i_server, psz_bind, i_bind);
 
     struct addrinfo hints, *loc, *rem;
-    int val;
 
     memset (&hints, 0, sizeof (hints));
     hints.ai_socktype = SOCK_DGRAM;
     hints.ai_protocol = protocol;
 
-    val = vlc_getaddrinfo (obj, psz_server, i_server, &hints, &rem);
+    int val = vlc_getaddrinfo (psz_server, i_server, &hints, &rem);
     if (val)
     {
         msg_Err (obj, "cannot resolve %s port %d : %s", psz_bind, i_bind,
@@ -617,7 +616,7 @@ int net_OpenDgram( vlc_object_t *obj, const char *psz_bind, int i_bind,
     }
 
     hints.ai_flags = AI_PASSIVE;
-    val = vlc_getaddrinfo (obj, psz_bind, i_bind, &hints, &loc);
+    val = vlc_getaddrinfo (psz_bind, i_bind, &hints, &loc);
     if (val)
     {
         msg_Err (obj, "cannot resolve %s port %d : %s", psz_bind, i_bind,
diff --git a/src/stream_output/announce.c b/src/stream_output/announce.c
index e7f39e7..7bebdf2 100644
--- a/src/stream_output/announce.c
+++ b/src/stream_output/announce.c
@@ -68,7 +68,7 @@ sout_AnnounceRegisterSDP( vlc_object_t *obj, const char *psz_sdp,
 
     /* GRUIK. We should not convert back-and-forth from string to numbers */
     struct addrinfo *res;
-    if (vlc_getaddrinfo (obj, psz_dst, 0, NULL, &res) == 0)
+    if (vlc_getaddrinfo (psz_dst, 0, NULL, &res) == 0)
     {
         if (res->ai_addrlen <= sizeof (p_session->addr))
             memcpy (&p_session->addr, res->ai_addr,



More information about the vlc-commits mailing list