diff options
author | Marcel Raad <Marcel.Raad@teamviewer.com> | 2018-02-25 21:16:32 +0100 |
---|---|---|
committer | Marcel Raad <Marcel.Raad@teamviewer.com> | 2018-02-28 20:04:48 +0100 |
commit | 24753bcd4821ead4b96650b12e6b47efe11181cb (patch) | |
tree | 631a279c66144ce2f197ae11b2f73fabd7ec8f8f /tests | |
parent | 828187d86b70af3a031b529312b8027b4ece10a5 (diff) |
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
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/unit1309.c | 14 |
1 files changed, 9 insertions, 5 deletions
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); } } |