Loading lib/vtls/gtls.c +6 −4 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms Loading Loading @@ -152,7 +152,8 @@ static int gtls_mapped_sockerrno(void) static ssize_t Curl_gtls_push(void *s, const void *buf, size_t len) { ssize_t ret = swrite(CURLX_POINTER_TO_INTEGER_CAST(s), buf, len); curl_socket_t sock = *(curl_socket_t *)s; ssize_t ret = swrite(sock, buf, len); #if defined(USE_WINSOCK) && !defined(GNUTLS_MAPS_WINSOCK_ERRORS) if(ret < 0) gnutls_transport_set_global_errno(gtls_mapped_sockerrno()); Loading @@ -162,7 +163,8 @@ static ssize_t Curl_gtls_push(void *s, const void *buf, size_t len) static ssize_t Curl_gtls_pull(void *s, void *buf, size_t len) { ssize_t ret = sread(CURLX_POINTER_TO_INTEGER_CAST(s), buf, len); curl_socket_t sock = *(curl_socket_t *)s; ssize_t ret = sread(sock, buf, len); #if defined(USE_WINSOCK) && !defined(GNUTLS_MAPS_WINSOCK_ERRORS) if(ret < 0) gnutls_transport_set_global_errno(gtls_mapped_sockerrno()); Loading Loading @@ -848,7 +850,7 @@ gtls_connect_step1(struct connectdata *conn, } else { /* file descriptor for the socket */ transport_ptr = CURLX_INTEGER_TO_POINTER_CAST(conn->sock[sockindex]); transport_ptr = &conn->sock[sockindex]; gnutls_transport_push = Curl_gtls_push; gnutls_transport_pull = Curl_gtls_pull; } Loading lib/warnless.h +1 −6 Original line number Diff line number Diff line Loading @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms Loading @@ -26,11 +26,6 @@ #include <curl/curl.h> /* for curl_socket_t */ #endif #define CURLX_POINTER_TO_INTEGER_CAST(p) \ ((char *)(p) - (char *)NULL) #define CURLX_INTEGER_TO_POINTER_CAST(i) \ ((void *)((char *)NULL + (i))) unsigned short curlx_ultous(unsigned long ulnum); unsigned char curlx_ultouc(unsigned long ulnum); Loading tests/unit/unit1309.c +11 −18 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 1998 - 2011, 2017, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms Loading Loading @@ -73,6 +73,7 @@ UNITTEST_START struct Curl_tree *root, *removed; struct Curl_tree nodes[NUM_NODES*3]; size_t storage[NUM_NODES*3]; int rc; int i, j; struct curltime tv_now = {0, 0}; Loading @@ -81,14 +82,11 @@ UNITTEST_START /* add nodes */ for(i = 0; i < NUM_NODES; i++) { struct curltime key; size_t payload; key.tv_sec = 0; key.tv_usec = (541*i)%1023; payload = (size_t) key.tv_usec; /* for simplicity */ nodes[i].payload = CURLX_INTEGER_TO_POINTER_CAST(payload); storage[i] = key.tv_usec; nodes[i].payload = &storage[i]; root = Curl_splayinsert(key, root, &nodes[i]); } Loading @@ -99,8 +97,8 @@ UNITTEST_START int rem = (i + 7)%NUM_NODES; printf("Tree look:\n"); splayprint(root, 0, 1); printf("remove pointer %d, payload %ld\n", rem, CURLX_POINTER_TO_INTEGER_CAST(nodes[rem].payload)); printf("remove pointer %d, payload %zd\n", rem, *(size_t *)nodes[rem].payload); rc = Curl_splayremovebyaddr(root, &nodes[rem], &root); if(rc) { /* failed! */ Loading @@ -120,9 +118,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; /* for simplicity */ nodes[i * 3 + j].payload = CURLX_INTEGER_TO_POINTER_CAST(payload); storage[i * 3 + j] = key.tv_usec*10 + j; nodes[i * 3 + j].payload = &storage[i * 3 + j]; root = Curl_splayinsert(key, root, &nodes[i * 3 + j]); } } Loading @@ -133,9 +130,9 @@ UNITTEST_START tv_now.tv_usec = i; root = Curl_splaygetbest(tv_now, root, &removed); while(removed != NULL) { printf("removed payload %ld[%ld]\n", CURLX_POINTER_TO_INTEGER_CAST(removed->payload) / 10, CURLX_POINTER_TO_INTEGER_CAST(removed->payload) % 10); printf("removed payload %zd[%zd]\n", (*(size_t *)removed->payload) / 10, (*(size_t *)removed->payload) % 10); root = Curl_splaygetbest(tv_now, root, &removed); } } Loading @@ -143,7 +140,3 @@ UNITTEST_START fail_unless(root == NULL, "tree not empty when it should be"); UNITTEST_STOP Loading
lib/vtls/gtls.c +6 −4 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms Loading Loading @@ -152,7 +152,8 @@ static int gtls_mapped_sockerrno(void) static ssize_t Curl_gtls_push(void *s, const void *buf, size_t len) { ssize_t ret = swrite(CURLX_POINTER_TO_INTEGER_CAST(s), buf, len); curl_socket_t sock = *(curl_socket_t *)s; ssize_t ret = swrite(sock, buf, len); #if defined(USE_WINSOCK) && !defined(GNUTLS_MAPS_WINSOCK_ERRORS) if(ret < 0) gnutls_transport_set_global_errno(gtls_mapped_sockerrno()); Loading @@ -162,7 +163,8 @@ static ssize_t Curl_gtls_push(void *s, const void *buf, size_t len) static ssize_t Curl_gtls_pull(void *s, void *buf, size_t len) { ssize_t ret = sread(CURLX_POINTER_TO_INTEGER_CAST(s), buf, len); curl_socket_t sock = *(curl_socket_t *)s; ssize_t ret = sread(sock, buf, len); #if defined(USE_WINSOCK) && !defined(GNUTLS_MAPS_WINSOCK_ERRORS) if(ret < 0) gnutls_transport_set_global_errno(gtls_mapped_sockerrno()); Loading Loading @@ -848,7 +850,7 @@ gtls_connect_step1(struct connectdata *conn, } else { /* file descriptor for the socket */ transport_ptr = CURLX_INTEGER_TO_POINTER_CAST(conn->sock[sockindex]); transport_ptr = &conn->sock[sockindex]; gnutls_transport_push = Curl_gtls_push; gnutls_transport_pull = Curl_gtls_pull; } Loading
lib/warnless.h +1 −6 Original line number Diff line number Diff line Loading @@ -7,7 +7,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms Loading @@ -26,11 +26,6 @@ #include <curl/curl.h> /* for curl_socket_t */ #endif #define CURLX_POINTER_TO_INTEGER_CAST(p) \ ((char *)(p) - (char *)NULL) #define CURLX_INTEGER_TO_POINTER_CAST(i) \ ((void *)((char *)NULL + (i))) unsigned short curlx_ultous(unsigned long ulnum); unsigned char curlx_ultouc(unsigned long ulnum); Loading
tests/unit/unit1309.c +11 −18 Original line number Diff line number Diff line Loading @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * * Copyright (C) 1998 - 2011, 2017, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms Loading Loading @@ -73,6 +73,7 @@ UNITTEST_START struct Curl_tree *root, *removed; struct Curl_tree nodes[NUM_NODES*3]; size_t storage[NUM_NODES*3]; int rc; int i, j; struct curltime tv_now = {0, 0}; Loading @@ -81,14 +82,11 @@ UNITTEST_START /* add nodes */ for(i = 0; i < NUM_NODES; i++) { struct curltime key; size_t payload; key.tv_sec = 0; key.tv_usec = (541*i)%1023; payload = (size_t) key.tv_usec; /* for simplicity */ nodes[i].payload = CURLX_INTEGER_TO_POINTER_CAST(payload); storage[i] = key.tv_usec; nodes[i].payload = &storage[i]; root = Curl_splayinsert(key, root, &nodes[i]); } Loading @@ -99,8 +97,8 @@ UNITTEST_START int rem = (i + 7)%NUM_NODES; printf("Tree look:\n"); splayprint(root, 0, 1); printf("remove pointer %d, payload %ld\n", rem, CURLX_POINTER_TO_INTEGER_CAST(nodes[rem].payload)); printf("remove pointer %d, payload %zd\n", rem, *(size_t *)nodes[rem].payload); rc = Curl_splayremovebyaddr(root, &nodes[rem], &root); if(rc) { /* failed! */ Loading @@ -120,9 +118,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; /* for simplicity */ nodes[i * 3 + j].payload = CURLX_INTEGER_TO_POINTER_CAST(payload); storage[i * 3 + j] = key.tv_usec*10 + j; nodes[i * 3 + j].payload = &storage[i * 3 + j]; root = Curl_splayinsert(key, root, &nodes[i * 3 + j]); } } Loading @@ -133,9 +130,9 @@ UNITTEST_START tv_now.tv_usec = i; root = Curl_splaygetbest(tv_now, root, &removed); while(removed != NULL) { printf("removed payload %ld[%ld]\n", CURLX_POINTER_TO_INTEGER_CAST(removed->payload) / 10, CURLX_POINTER_TO_INTEGER_CAST(removed->payload) % 10); printf("removed payload %zd[%zd]\n", (*(size_t *)removed->payload) / 10, (*(size_t *)removed->payload) % 10); root = Curl_splaygetbest(tv_now, root, &removed); } } Loading @@ -143,7 +140,3 @@ UNITTEST_START fail_unless(root == NULL, "tree not empty when it should be"); UNITTEST_STOP