summaryrefslogtreecommitdiffstats
path: root/contrib/binutils/include/obstack.h
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2018-01-01 20:39:12 +0000
committerLuiz Souza <luiz@netgate.com>2018-02-21 15:19:51 -0300
commitb042831d7b39460b5b04220cf450867d9dabe394 (patch)
treea069324f1d6fa199f420edbc0ecd3a579e89c906 /contrib/binutils/include/obstack.h
parent7f33f93bf2f7c20161a5486c2d80c28c6152969a (diff)
downloadFreeBSD-src-b042831d7b39460b5b04220cf450867d9dabe394.zip
FreeBSD-src-b042831d7b39460b5b04220cf450867d9dabe394.tar.gz
MFC r327164:
Fix clang 6.0.0 compiler warnings in binutils Latest clang git has a warning -Wnull-pointer-arithmetic which will trigger a -Werror failure. Addition and subtraction from a null pointer is undefined behaviour and could be optimized into anything. Furthermore, using the difference between two pointers and casting the result back to a pointer is not portable since the size of ptrdiff_t does not necessary have to be the same as size of void* (this happens e.g. on CHERI). Using intptr_t instead fixes this portability issue and the compiler warning. Submitted by; Alexander Richardson Obtained from: CheriBSD Differential Revision: https://reviews.freebsd.org/D12928 (cherry picked from commit 0cd25a0c5807abc3eb947abf62bc29f95037eba2)
Diffstat (limited to 'contrib/binutils/include/obstack.h')
-rw-r--r--contrib/binutils/include/obstack.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/contrib/binutils/include/obstack.h b/contrib/binutils/include/obstack.h
index 88c2a26..725b6cc 100644
--- a/contrib/binutils/include/obstack.h
+++ b/contrib/binutils/include/obstack.h
@@ -119,11 +119,11 @@ extern "C" {
may ignore the byte-within-word field of the pointer. */
#ifndef __PTR_TO_INT
-# define __PTR_TO_INT(P) ((P) - (char *) 0)
+# define __PTR_TO_INT(P) ((intptr_t)(P))
#endif
#ifndef __INT_TO_PTR
-# define __INT_TO_PTR(P) ((P) + (char *) 0)
+# define __INT_TO_PTR(P) ((void*)(intptr_t)(P))
#endif
/* We need the type of the resulting object. If __PTRDIFF_TYPE__ is
@@ -427,7 +427,7 @@ __extension__ \
__o1->maybe_empty_object = 1; \
__o1->next_free \
= __INT_TO_PTR ((__PTR_TO_INT (__o1->next_free)+__o1->alignment_mask)\
- & ~ (__o1->alignment_mask)); \
+ & ~(intptr_t)(__o1->alignment_mask)); \
if (__o1->next_free - (char *)__o1->chunk \
> __o1->chunk_limit - (char *)__o1->chunk) \
__o1->next_free = __o1->chunk_limit; \
OpenPOWER on IntegriCloud