diff options
author | dim <dim@FreeBSD.org> | 2011-12-15 19:42:25 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2011-12-15 19:42:25 +0000 |
commit | 366d0e5e6bc8a4c9a663a8cfb196b8010dc2f5f6 (patch) | |
tree | 184b2cffdb01cccab60f99d3f13073800e72d1db | |
parent | 7538d819fc6d6789835d8e24e4573eb1a35658d4 (diff) | |
download | FreeBSD-src-366d0e5e6bc8a4c9a663a8cfb196b8010dc2f5f6.zip FreeBSD-src-366d0e5e6bc8a4c9a663a8cfb196b8010dc2f5f6.tar.gz |
The TCB_GET32() and TCB_GET64() macros in the i386 and amd64-specific
versions of pthread_md.h have a special case of dereferencing a null
pointer. Clang warns about this with:
In file included from lib/libthr/arch/i386/i386/pthread_md.c:36:
lib/libthr/arch/i386/include/pthread_md.h:96:10: error: indirection of non-volatile null pointer will be deleted, not trap [-Werror,-Wnull-dereference]
return (TCB_GET32(tcb_self));
^~~~~~~~~~~~~~~~~~~
lib/libthr/arch/i386/include/pthread_md.h:73:13: note: expanded from:
: "m" (*(u_int *)(__tcb_offset(name)))); \
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lib/libthr/arch/i386/include/pthread_md.h:96:10: note: consider using __builtin_trap() or qualifying pointer with 'volatile'
Since this indirection is done relative to the fs or gs segment, to
retrieve thread-specific data, it is an exception to the rule.
Therefore, add a volatile qualifier to tell the compiler we really want
to dereference a zero address.
MFC after: 1 week
-rw-r--r-- | lib/libthr/arch/amd64/include/pthread_md.h | 2 | ||||
-rw-r--r-- | lib/libthr/arch/i386/include/pthread_md.h | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/lib/libthr/arch/amd64/include/pthread_md.h b/lib/libthr/arch/amd64/include/pthread_md.h index 9f6d3a1..0ebea2e 100644 --- a/lib/libthr/arch/amd64/include/pthread_md.h +++ b/lib/libthr/arch/amd64/include/pthread_md.h @@ -71,7 +71,7 @@ struct tcb { u_long __i; \ __asm __volatile("movq %%fs:%1, %0" \ : "=r" (__i) \ - : "m" (*(u_long *)(__tcb_offset(name)))); \ + : "m" (*(volatile u_long *)(__tcb_offset(name)))); \ __result = (__tcb_type(name))__i; \ \ __result; \ diff --git a/lib/libthr/arch/i386/include/pthread_md.h b/lib/libthr/arch/i386/include/pthread_md.h index 5c00cf6..c160aa4 100644 --- a/lib/libthr/arch/i386/include/pthread_md.h +++ b/lib/libthr/arch/i386/include/pthread_md.h @@ -70,7 +70,7 @@ struct tcb { u_int __i; \ __asm __volatile("movl %%gs:%1, %0" \ : "=r" (__i) \ - : "m" (*(u_int *)(__tcb_offset(name)))); \ + : "m" (*(volatile u_int *)(__tcb_offset(name)))); \ __result = (__tcb_type(name))__i; \ \ __result; \ |