[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnurl] 64/178: build: cleanup to fix clang warnings/errors
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnurl] 64/178: build: cleanup to fix clang warnings/errors |
Date: |
Wed, 23 May 2018 12:24:59 +0200 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to branch master
in repository gnurl.
commit dc1b6c5a00f938474a385c2af8aeef56583b989c
Author: Daniel Stenberg <address@hidden>
AuthorDate: Sat Apr 7 11:03:18 2018 +0200
build: cleanup to fix clang warnings/errors
unit1309 and vtls/gtls: error: arithmetic on a null pointer treated as a
cast from integer to pointer is a GNU extension
Reported-by: Rikard Falkeborn
Fixes #2466
Closes #2468
---
lib/vtls/gtls.c | 10 ++++++----
lib/warnless.h | 7 +------
tests/unit/unit1309.c | 29 +++++++++++------------------
3 files changed, 18 insertions(+), 28 deletions(-)
diff --git a/lib/vtls/gtls.c b/lib/vtls/gtls.c
index 3f30b6c8c..688e83807 100644
--- a/lib/vtls/gtls.c
+++ b/lib/vtls/gtls.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <address@hidden>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <address@hidden>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -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());
@@ -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());
@@ -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;
}
diff --git a/lib/warnless.h b/lib/warnless.h
index efd552a60..f6a2d744b 100644
--- a/lib/warnless.h
+++ b/lib/warnless.h
@@ -7,7 +7,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <address@hidden>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <address@hidden>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -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);
diff --git a/tests/unit/unit1309.c b/tests/unit/unit1309.c
index 9a07c9332..7d3c00017 100644
--- a/tests/unit/unit1309.c
+++ b/tests/unit/unit1309.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2011, 2017, Daniel Stenberg, <address@hidden>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <address@hidden>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -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};
@@ -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]);
}
@@ -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! */
@@ -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]);
}
}
@@ -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);
}
}
@@ -143,7 +140,3 @@ UNITTEST_START
fail_unless(root == NULL, "tree not empty when it should be");
UNITTEST_STOP
-
-
-
-
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [gnurl] 52/178: file: restore old behavior for file:////foo/bar URLs, (continued)
- [GNUnet-SVN] [gnurl] 52/178: file: restore old behavior for file:////foo/bar URLs, gnunet, 2018/05/23
- [GNUnet-SVN] [gnurl] 69/178: travis: use trusty for coverage build, gnunet, 2018/05/23
- [GNUnet-SVN] [gnurl] 70/178: travis: bump to clang 6 and gcc 7, gnunet, 2018/05/23
- [GNUnet-SVN] [gnurl] 85/178: README.md: add backers and sponsors, gnunet, 2018/05/23
- [GNUnet-SVN] [gnurl] 55/178: winbuild: make the clean target work without build-type, gnunet, 2018/05/23
- [GNUnet-SVN] [gnurl] 44/178: cookies: when reading from a file, only remove_expired once, gnunet, 2018/05/23
- [GNUnet-SVN] [gnurl] 68/178: lib: silence null-dereference warnings, gnunet, 2018/05/23
- [GNUnet-SVN] [gnurl] 48/178: cookie: fix and optimize 2nd top level domain name extraction, gnunet, 2018/05/23
- [GNUnet-SVN] [gnurl] 51/178: Revert "openssl: Don't add verify locations when verifypeer==0", gnunet, 2018/05/23
- [GNUnet-SVN] [gnurl] 73/178: mailmap: add a monnerat fixup [ci skip], gnunet, 2018/05/23
- [GNUnet-SVN] [gnurl] 64/178: build: cleanup to fix clang warnings/errors,
gnunet <=
- [GNUnet-SVN] [gnurl] 56/178: build-openssl.bat: Refer to VS2017 as VC14.1 instead of VC15, gnunet, 2018/05/23
- [GNUnet-SVN] [gnurl] 116/178: strcpy_url: only %-encode values >= 0x80, gnunet, 2018/05/23
- [GNUnet-SVN] [gnurl] 105/178: curl_global_sslset: always provide available backends, gnunet, 2018/05/23
- [GNUnet-SVN] [gnurl] 86/178: winbuild: Support custom devel paths for each dependency, gnunet, 2018/05/23
- [GNUnet-SVN] [gnurl] 100/178: Revert "ftplistparser: keep state between invokes", gnunet, 2018/05/23
- [GNUnet-SVN] [gnurl] 103/178: curl.1: clarify that options and URLs can be mixed, gnunet, 2018/05/23
- [GNUnet-SVN] [gnurl] 119/178: RELEASE-NOTES: synced, gnunet, 2018/05/23
- [GNUnet-SVN] [gnurl] 114/178: ctype: restore character classification for non-ASCII platforms, gnunet, 2018/05/23
- [GNUnet-SVN] [gnurl] 115/178: mime: avoid NULL pointer dereference risk, gnunet, 2018/05/23
- [GNUnet-SVN] [gnurl] 129/178: TODO: Support the clienthello extension, gnunet, 2018/05/23