]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Cast pointers to uintptr_t instead of unsigned {long,int}.
authorTim Kosse <tim.kosse@filezilla-project.org>
Tue, 11 Aug 2015 12:01:02 +0000 (14:01 +0200)
committerSimon Tatham <anakin@pobox.com>
Sat, 15 Aug 2015 12:54:46 +0000 (13:54 +0100)
On 64bit Windows, pointers are 64bit whereas both unsigned long and
unsigned int are 32bit. Using uintptr_t avoids truncation.

misc.c
windows/winhandl.c
windows/winnet.c

diff --git a/misc.c b/misc.c
index 0e1d622d380228ad13b11181abc5d20dc309170e..b1bfb36176fab38832a9244e03e8422620bc8cbf 100644 (file)
--- a/misc.c
+++ b/misc.c
@@ -853,7 +853,7 @@ void debug_memdump(const void *buf, int len, int L)
     if (L) {
        int delta;
        debug_printf("\t%d (0x%x) bytes:\n", len, len);
-       delta = 15 & (unsigned long int) p;
+       delta = 15 & (uintptr_t)p;
        p -= delta;
        len += delta;
     }
index 7c282fc7d5502f128f300d3ea09d942026d4c525..4746d1b4b55425b6f0c7b290940849209e6f00aa 100644 (file)
@@ -411,9 +411,9 @@ static int handle_cmp_evtomain(void *av, void *bv)
     struct handle *a = (struct handle *)av;
     struct handle *b = (struct handle *)bv;
 
-    if ((unsigned)a->u.g.ev_to_main < (unsigned)b->u.g.ev_to_main)
+    if ((uintptr_t)a->u.g.ev_to_main < (uintptr_t)b->u.g.ev_to_main)
        return -1;
-    else if ((unsigned)a->u.g.ev_to_main > (unsigned)b->u.g.ev_to_main)
+    else if ((uintptr_t)a->u.g.ev_to_main > (uintptr_t)b->u.g.ev_to_main)
        return +1;
     else
        return 0;
@@ -424,9 +424,9 @@ static int handle_find_evtomain(void *av, void *bv)
     HANDLE *a = (HANDLE *)av;
     struct handle *b = (struct handle *)bv;
 
-    if ((unsigned)*a < (unsigned)b->u.g.ev_to_main)
+    if ((uintptr_t)*a < (uintptr_t)b->u.g.ev_to_main)
        return -1;
-    else if ((unsigned)*a > (unsigned)b->u.g.ev_to_main)
+    else if ((uintptr_t)*a > (uintptr_t)b->u.g.ev_to_main)
        return +1;
     else
        return 0;
index e1beb5d194b40e38d562bb4928aa672f898685cb..fa2de80967565e91cd7161512fd2646f7d563bfc 100644 (file)
@@ -138,7 +138,7 @@ static int cmpfortree(void *av, void *bv)
 static int cmpforsearch(void *av, void *bv)
 {
     Actual_Socket b = (Actual_Socket) bv;
-    unsigned long as = (unsigned long) av, bs = (unsigned long) b->s;
+    uintptr_t as = (uintptr_t) av, bs = (uintptr_t) b->s;
     if (as < bs)
        return -1;
     if (as > bs)