[hackers] [scc] Use uintptr_t for arithmetic on pointers || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Mon, 20 Jul 2015 08:23:25 +0200 (CEST)

commit 9b65a9cadd670f9cdd7ac4d8e203240fbfcd80cf
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Mon Jul 20 08:19:25 2015 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Mon Jul 20 08:19:25 2015 +0200

    Use uintptr_t for arithmetic on pointers
    
    Conversion between pointers and integers are allowed,
    but the result is implementation defined, except in
    the case of uinptr_t which is big enough to hold
    the value of the pointer without losing any information
    and allow return to the pointer type.

diff --git a/cc1/types.c b/cc1/types.c
index 72547b8..5aef90d 100644
--- a/cc1/types.c
+++ b/cc1/types.c
_AT_@ -210,9 +210,12 @@ mktype(Type *tp, unsigned op, short nelem, void *data)
         unsigned t;
         Type *bp;
         static char letters[] = {
- [PTR] = L_POINTER, [ARY] = L_ARRAY,
- [FTN] = L_FUNCTION, [ENUM] = L_INT,
- [STRUCT] = L_STRUCT, [UNION] = L_UNION
+ [PTR] = L_POINTER,
+ [ARY] = L_ARRAY,
+ [FTN] = L_FUNCTION,
+ [ENUM] = L_INT,
+ [STRUCT] = L_STRUCT,
+ [UNION] = L_UNION
         };
 
         if (op == PTR && tp == voidtype)
_AT_@ -230,7 +233,7 @@ mktype(Type *tp, unsigned op, short nelem, void *data)
         else
                 type.defined = 1;
 
- t = (op ^ (char) ((unsigned short) tp >> 3)) & NR_TYPE_HASH-1;
+ t = (op ^ (uintptr_t) tp >> 3) & NR_TYPE_HASH-1;
         tbl = &typetab[t];
         for (bp = *tbl; bp; bp = bp->next) {
                 if (eqtype(bp, &type)) {
Received on Mon Jul 20 2015 - 08:23:25 CEST

This archive was generated by hypermail 2.3.0 : Mon Jul 20 2015 - 08:24:13 CEST