libthread_xu: Fix issues detected by gcc80.
authorSascha Wildner <saw@online.de>
Fri, 19 Jan 2018 08:55:59 +0000 (09:55 +0100)
committerSascha Wildner <saw@online.de>
Fri, 19 Jan 2018 08:58:28 +0000 (09:58 +0100)
commit0f037c78525bfb7df49de8338826e15137859b1d
treec290c97071f23cca6c42605c6fd2a7e40638bdd1
parent8fa1a71d96020b2965426c6bdab0a3a0d98f431f
libthread_xu: Fix issues detected by gcc80.

The changes to <pthread.h> all deal with -Wnonnull-compare warnings,
which are issued when a function has a NULL check for a parameter that
at the same time is marked with __attribute__((nonnull(...))), aka
__nonnull(...).

Such __nonnull() decoration only ever catches those cases where NULL is
passed directly to the function, but not any more indirect ways. What
makes matters worse is that in higher optimization levels (-O >= 2),
GCC will happily optimize out any NULL checks within the function for
these parameters.

This means that __nonnull() is generally inferior to a direct NULL check
in the function itself and if we have both, which newer GCCs warn about
with -Wnonnull-compare (that is part of -Wall), we should remove the
__nonnull().

This commit does that for all parameters which our libthread_xu checks
directly in the function. What remains are __nonnull() for parameters
which are _not_ checked in the functions, to at least catch cases where
NULL is passed directly. We should think about adding real checks for
those parameters too.

While here, add a "/* FALLTHROUGH */" comment in thr_printf.c which
fixes a -Wimplicit-fallthrough warning.
include/pthread.h
lib/libthread_xu/thread/thr_printf.c