From 24753bcd4821ead4b96650b12e6b47efe11181cb Mon Sep 17 00:00:00 2001 From: Marcel Raad Date: Sun, 25 Feb 2018 21:16:32 +0100 Subject: unit1309: fix warning on Windows x64 When targeting x64, MinGW-w64 complains about conversions between 32-bit long and 64-bit pointers. Fix this by reusing the GNUTLS_POINTER_TO_SOCKET_CAST / GNUTLS_SOCKET_TO_POINTER_CAST logic from gtls.c, moving it to warnless.h as CURLX_POINTER_TO_INTEGER_CAST / CURLX_INTEGER_TO_POINTER_CAST. Closes https://github.com/curl/curl/pull/2341 --- tests/unit/unit1309.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'tests/unit/unit1309.c') diff --git a/tests/unit/unit1309.c b/tests/unit/unit1309.c index c53cbcbce..9a07c9332 100644 --- a/tests/unit/unit1309.c +++ b/tests/unit/unit1309.c @@ -22,6 +22,7 @@ #include "curlcheck.h" #include "splay.h" +#include "warnless.h" static CURLcode unit_setup(void) @@ -86,7 +87,8 @@ UNITTEST_START key.tv_usec = (541*i)%1023; payload = (size_t) key.tv_usec; - nodes[i].payload = (void *)payload; /* for simplicity */ + /* for simplicity */ + nodes[i].payload = CURLX_INTEGER_TO_POINTER_CAST(payload); root = Curl_splayinsert(key, root, &nodes[i]); } @@ -98,7 +100,7 @@ UNITTEST_START printf("Tree look:\n"); splayprint(root, 0, 1); printf("remove pointer %d, payload %ld\n", rem, - (long)(nodes[rem].payload)); + CURLX_POINTER_TO_INTEGER_CAST(nodes[rem].payload)); rc = Curl_splayremovebyaddr(root, &nodes[rem], &root); if(rc) { /* failed! */ @@ -119,7 +121,8 @@ UNITTEST_START /* add some nodes with the same key */ for(j = 0; j <= i % 3; j++) { size_t payload = key.tv_usec*10 + j; - nodes[i * 3 + j].payload = (void *)payload; /* for simplicity */ + /* for simplicity */ + nodes[i * 3 + j].payload = CURLX_INTEGER_TO_POINTER_CAST(payload); root = Curl_splayinsert(key, root, &nodes[i * 3 + j]); } } @@ -130,8 +133,9 @@ UNITTEST_START tv_now.tv_usec = i; root = Curl_splaygetbest(tv_now, root, &removed); while(removed != NULL) { - printf("removed payload %ld[%ld]\n", (long)(removed->payload) / 10, - (long)(removed->payload) % 10); + printf("removed payload %ld[%ld]\n", + CURLX_POINTER_TO_INTEGER_CAST(removed->payload) / 10, + CURLX_POINTER_TO_INTEGER_CAST(removed->payload) % 10); root = Curl_splaygetbest(tv_now, root, &removed); } } -- cgit v1.2.3