From: Clément Gregoire <[email protected]>

On systems lacking getservbyport, struct servent might not be defined,
causing a compilation error when trying to access its member s_name 
(ent->s_name).
There is no point in keeping the if(ent) branch when getservbyport is not
available.

Signed-off-by: Clément Grégoire <[email protected]>
---
 libavformat/os_support.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavformat/os_support.c b/libavformat/os_support.c
index 650baea..78a2f07 100644
--- a/libavformat/os_support.c
+++ b/libavformat/os_support.c
@@ -204,15 +204,15 @@ int ff_getnameinfo(const struct sockaddr *sa, int salen,
     }
 
     if (serv && servlen > 0) {
-        struct servent *ent = NULL;
 #if HAVE_GETSERVBYPORT
+        struct servent *ent = NULL;
         if (!(flags & NI_NUMERICSERV))
             ent = getservbyport(sin->sin_port, flags & NI_DGRAM ? "udp" : 
"tcp");
-#endif /* HAVE_GETSERVBYPORT */
 
         if (ent)
             snprintf(serv, servlen, "%s", ent->s_name);
         else
+#endif /* HAVE_GETSERVBYPORT */
             snprintf(serv, servlen, "%d", ntohs(sin->sin_port));
     }
 
-- 
2.4.9 (Apple Git-60)

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to