[vlc-commits] http: avoid nonportable int to void conversions

Rémi Denis-Courmont git at videolan.org
Tue Nov 20 21:34:07 CET 2018


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Nov 20 20:20:51 2018 +0200| [8ab3c59baab72a24b3ce9641cdd7dd82443be0b1] | committer: Rémi Denis-Courmont

http: avoid nonportable int to void conversions

(only affects test cases)

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

 modules/access/http/h2frame_test.c |  3 ++-
 modules/access/http/tunnel_test.c  | 18 ++++++++++--------
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/modules/access/http/h2frame_test.c b/modules/access/http/h2frame_test.c
index c2351082d8..35cb5777a4 100644
--- a/modules/access/http/h2frame_test.c
+++ b/modules/access/http/h2frame_test.c
@@ -35,7 +35,8 @@
 #include <vlc_common.h>
 #include "conn.h"
 
-#define CTX ((void *)(uintptr_t)0x44556677)
+static char dummy;
+static char *const CTX = &dummy;
 
 static unsigned settings;
 
diff --git a/modules/access/http/tunnel_test.c b/modules/access/http/tunnel_test.c
index d79329118e..353caf123b 100644
--- a/modules/access/http/tunnel_test.c
+++ b/modules/access/http/tunnel_test.c
@@ -92,11 +92,11 @@ static unsigned connection_count = 0;
 
 static void *proxy_thread(void *data)
 {
-    int lfd = (intptr_t)data;
+    int *lfd = data;
 
     for (;;)
     {
-        int cfd = accept4(lfd, NULL, NULL, SOCK_CLOEXEC);
+        int cfd = accept4(*lfd, NULL, NULL, SOCK_CLOEXEC);
         if (cfd == -1)
             continue;
 
@@ -147,7 +147,9 @@ int main(void)
     vlc_https_connect_proxy(NULL, NULL, "www.example.com", 0, &two,
                             "ftp://proxy.example.com/");
 
-    int lfd = server_socket(&port);
+    int *lfd = malloc(sizeof (int));
+    assert(lfd != NULL);
+    *lfd = server_socket(&port);
     if (lfd == -1)
         return 77;
 
@@ -159,15 +161,14 @@ int main(void)
     /* Test connection failure */
     vlc_https_connect_proxy(NULL, NULL, "www.example.com", 0, &two, url);
 
-    if (listen(lfd, 255))
+    if (listen(*lfd, 255))
     {
-        vlc_close(lfd);
+        vlc_close(*lfd);
         return 77;
     }
 
     vlc_thread_t th;
-    if (vlc_clone(&th, proxy_thread, (void*)(intptr_t)lfd,
-                  VLC_THREAD_PRIORITY_LOW))
+    if (vlc_clone(&th, proxy_thread, lfd, VLC_THREAD_PRIORITY_LOW))
         assert(!"Thread error");
 
     /* Test proxy error */
@@ -177,5 +178,6 @@ int main(void)
     vlc_join(th, NULL);
     assert(connection_count > 0);
     free(url);
-    vlc_close(lfd);
+    vlc_close(*lfd);
+    free(lfd);
 }



More information about the vlc-commits mailing list