]> CyberLeo.Net >> Repos - FreeBSD/stable/9.git/commit
MFC r228536:
authordim <dim@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Fri, 30 Dec 2011 23:41:24 +0000 (23:41 +0000)
committerdim <dim@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Fri, 30 Dec 2011 23:41:24 +0000 (23:41 +0000)
commit6038e5b155efd6af5740aa6018b04b7ead454176
tree51c135a4299cffe1dc32f3361dbec7f1c74bfdac
parent8e8b8d813f80112c259d13391546821abc30fc4b
MFC r228536:

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.

git-svn-id: svn://svn.freebsd.org/base/stable/9@229047 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
lib/libthr/arch/amd64/include/pthread_md.h
lib/libthr/arch/i386/include/pthread_md.h