git: libthread_xu: Fix issues detected by gcc80.

Sascha Wildner swildner at crater.dragonflybsd.org
Fri Jan 19 01:02:27 PST 2018


commit 0f037c78525bfb7df49de8338826e15137859b1d
Author: Sascha Wildner <saw at online.de>
Date:   Fri Jan 19 09:55:59 2018 +0100

    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.

Summary of changes:
 include/pthread.h                    | 88 ++++++++++++++++--------------------
 lib/libthread_xu/thread/thr_printf.c |  1 +
 2 files changed, 39 insertions(+), 50 deletions(-)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/0f037c78525bfb7df49de8338826e15137859b1d


-- 
DragonFly BSD source repository


More information about the Commits mailing list