mirror of
https://github.com/curl/curl.git
synced 2026-08-25 23:53:43 +03:00
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
This commit is contained in:
parent
828187d86b
commit
24753bcd48
3 changed files with 17 additions and 17 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue