Author: vangyzen
Date: Tue May 23 16:12:50 2017
New Revision: 318749
URL: https://svnweb.freebsd.org/changeset/base/318749

Log:
  libthr: fix warnings from GCC when WARNS=6
  
  Fix warnings about:
  - redundant declarations
  - a local variable shadowing a global function (dlinfo)
  - an old-style function definition (with an empty parameter list)
  - a variable that is possibly used uninitialized
  
  "make tinderbox" passes this time, except for a few unrelated
  kernel failures.
  
  Reviewed by:  kib
  MFC after:    3 days
  Sponsored by: Dell EMC
  Differential Revision:        https://reviews.freebsd.org/D10870

Modified:
  head/include/stdio.h
  head/lib/libc/include/libc_private.h
  head/lib/libthr/thread/thr_exit.c
  head/lib/libthr/thread/thr_kern.c
  head/lib/libthr/thread/thr_list.c
  head/lib/libthr/thread/thr_mutex.c
  head/lib/libthr/thread/thr_private.h
Directory Properties:
  head/   (props changed)

Modified: head/include/stdio.h
==============================================================================
--- head/include/stdio.h        Tue May 23 15:46:21 2017        (r318748)
+++ head/include/stdio.h        Tue May 23 16:12:50 2017        (r318749)
@@ -464,7 +464,10 @@ static __inline int __sputc(int _c, FILE
                (*(p)->_p = (c), (int)*(p)->_p++))
 #endif
 
+#ifndef __LIBC_ISTHREADED_DECLARED
+#define __LIBC_ISTHREADED_DECLARED
 extern int __isthreaded;
+#endif
 
 #ifndef __cplusplus
 

Modified: head/lib/libc/include/libc_private.h
==============================================================================
--- head/lib/libc/include/libc_private.h        Tue May 23 15:46:21 2017        
(r318748)
+++ head/lib/libc/include/libc_private.h        Tue May 23 16:12:50 2017        
(r318749)
@@ -42,7 +42,10 @@
  * or more threads. It is used to avoid calling locking functions
  * when they are not required.
  */
+#ifndef __LIBC_ISTHREADED_DECLARED
+#define __LIBC_ISTHREADED_DECLARED
 extern int     __isthreaded;
+#endif
 
 /*
  * Elf_Auxinfo *__elf_aux_vector, the pointer to the ELF aux vector

Modified: head/lib/libthr/thread/thr_exit.c
==============================================================================
--- head/lib/libthr/thread/thr_exit.c   Tue May 23 15:46:21 2017        
(r318748)
+++ head/lib/libthr/thread/thr_exit.c   Tue May 23 16:12:50 2017        
(r318749)
@@ -46,8 +46,6 @@ __FBSDID("$FreeBSD$");
 #include "libc_private.h"
 #include "thr_private.h"
 
-void   _pthread_exit(void *status);
-
 static void    exit_thread(void) __dead2;
 
 __weak_reference(_pthread_exit, pthread_exit);
@@ -72,7 +70,7 @@ static void
 thread_uw_init(void)
 {
        static int inited = 0;
-       Dl_info dlinfo;
+       Dl_info dli;
        void *handle;
        void *forcedunwind, *getcfa;
 
@@ -80,12 +78,12 @@ thread_uw_init(void)
            return;
        handle = RTLD_DEFAULT;
        if ((forcedunwind = dlsym(handle, "_Unwind_ForcedUnwind")) != NULL) {
-           if (dladdr(forcedunwind, &dlinfo)) {
+           if (dladdr(forcedunwind, &dli)) {
                /*
                 * Make sure the address is always valid by holding the library,
                 * also assume functions are in same library.
                 */
-               if ((handle = dlopen(dlinfo.dli_fname, RTLD_LAZY)) != NULL) {
+               if ((handle = dlopen(dli.dli_fname, RTLD_LAZY)) != NULL) {
                    forcedunwind = dlsym(handle, "_Unwind_ForcedUnwind");
                    getcfa = dlsym(handle, "_Unwind_GetCFA");
                    if (forcedunwind != NULL && getcfa != NULL) {

Modified: head/lib/libthr/thread/thr_kern.c
==============================================================================
--- head/lib/libthr/thread/thr_kern.c   Tue May 23 15:46:21 2017        
(r318748)
+++ head/lib/libthr/thread/thr_kern.c   Tue May 23 16:12:50 2017        
(r318749)
@@ -62,7 +62,7 @@ _thr_setthreaded(int threaded)
 }
 
 void
-_thr_assert_lock_level()
+_thr_assert_lock_level(void)
 {
        PANIC("locklevel <= 0");
 }

Modified: head/lib/libthr/thread/thr_list.c
==============================================================================
--- head/lib/libthr/thread/thr_list.c   Tue May 23 15:46:21 2017        
(r318748)
+++ head/lib/libthr/thread/thr_list.c   Tue May 23 16:12:50 2017        
(r318749)
@@ -35,8 +35,8 @@ __FBSDID("$FreeBSD$");
 #include <string.h>
 #include <pthread.h>
 
-#include "thr_private.h"
 #include "libc_private.h"
+#include "thr_private.h"
 
 /*#define DEBUG_THREAD_LIST */
 #ifdef DEBUG_THREAD_LIST

Modified: head/lib/libthr/thread/thr_mutex.c
==============================================================================
--- head/lib/libthr/thread/thr_mutex.c  Tue May 23 15:46:21 2017        
(r318748)
+++ head/lib/libthr/thread/thr_mutex.c  Tue May 23 16:12:50 2017        
(r318749)
@@ -70,8 +70,6 @@ int   __pthread_mutex_trylock(pthread_mute
 int    __pthread_mutex_lock(pthread_mutex_t *mutex);
 int    __pthread_mutex_timedlock(pthread_mutex_t *mutex,
                const struct timespec *abstime);
-int    _pthread_mutex_init_calloc_cb(pthread_mutex_t *mutex,
-               void *(calloc_cb)(size_t, size_t));
 int    _pthread_mutex_getspinloops_np(pthread_mutex_t *mutex, int *count);
 int    _pthread_mutex_setspinloops_np(pthread_mutex_t *mutex, int count);
 int    __pthread_mutex_setspinloops_np(pthread_mutex_t *mutex, int count);
@@ -712,6 +710,7 @@ mutex_lock_common(struct pthread_mutex *
        struct pthread *curthread;
        int ret, robust;
 
+       robust = 0;  /* pacify gcc */
        curthread  = _get_curthread();
        if (!cvattach && m->m_flags & PMUTEX_FLAG_PRIVATE)
                THR_CRITICAL_ENTER(curthread);

Modified: head/lib/libthr/thread/thr_private.h
==============================================================================
--- head/lib/libthr/thread/thr_private.h        Tue May 23 15:46:21 2017        
(r318748)
+++ head/lib/libthr/thread/thr_private.h        Tue May 23 16:12:50 2017        
(r318749)
@@ -701,7 +701,10 @@ do {                                                       
        \
        (curthr->report_events &&                       \
         (((curthr)->event_mask | _thread_event_mask ) & e) != 0)
 
+#ifndef __LIBC_ISTHREADED_DECLARED
+#define __LIBC_ISTHREADED_DECLARED
 extern int __isthreaded;
+#endif
 
 /*
  * Global variables for the pthread kernel.
@@ -835,8 +838,10 @@ int        _sched_yield(void);
 void   _pthread_cleanup_push(void (*)(void *), void *);
 void   _pthread_cleanup_pop(int);
 void   _pthread_exit_mask(void *status, sigset_t *mask) __dead2 __hidden;
+#ifndef _LIBC_PRIVATE_H_
 void   _pthread_cancel_enter(int maycancel);
 void   _pthread_cancel_leave(int maycancel);
+#endif
 int    _pthread_mutex_consistent(pthread_mutex_t * _Nonnull);
 int    _pthread_mutexattr_getrobust(pthread_mutexattr_t * _Nonnull __restrict,
            int * _Nonnull __restrict);
@@ -844,46 +849,56 @@ int       _pthread_mutexattr_setrobust(pthread
 
 /* #include <fcntl.h> */
 #ifdef  _SYS_FCNTL_H_
+#ifndef _LIBC_PRIVATE_H_
 int     __sys_fcntl(int, int, ...);
 int     __sys_openat(int, const char *, int, ...);
-#endif
+#endif /* _LIBC_PRIVATE_H_ */
+#endif /* _SYS_FCNTL_H_ */
 
 /* #include <signal.h> */
 #ifdef _SIGNAL_H_
 int    __sys_kill(pid_t, int);
-int     __sys_sigaction(int, const struct sigaction *, struct sigaction *);
+int     __sys_sigaltstack(const struct sigaltstack *, struct sigaltstack *);
 int     __sys_sigpending(sigset_t *);
+int     __sys_sigreturn(const ucontext_t *);
+#ifndef _LIBC_PRIVATE_H_
+int     __sys_sigaction(int, const struct sigaction *, struct sigaction *);
 int     __sys_sigprocmask(int, const sigset_t *, sigset_t *);
 int     __sys_sigsuspend(const sigset_t *);
-int     __sys_sigreturn(const ucontext_t *);
-int     __sys_sigaltstack(const struct sigaltstack *, struct sigaltstack *);
-int    __sys_sigwait(const sigset_t *, int *);
 int    __sys_sigtimedwait(const sigset_t *, siginfo_t *,
                const struct timespec *);
+int    __sys_sigwait(const sigset_t *, int *);
 int    __sys_sigwaitinfo(const sigset_t *set, siginfo_t *info);
-#endif
+#endif /* _LIBC_PRIVATE_H_ */
+#endif /* _SYS_FCNTL_H_ */
 
 /* #include <time.h> */
 #ifdef _TIME_H_
+#ifndef _LIBC_PRIVATE_H_
 int    __sys_clock_nanosleep(clockid_t, int, const struct timespec *,
            struct timespec *);
 int    __sys_nanosleep(const struct timespec *, struct timespec *);
-#endif
+#endif /* _LIBC_PRIVATE_H_ */
+#endif /* _SYS_FCNTL_H_ */
 
 /* #include <sys/ucontext.h> */
 #ifdef _SYS_UCONTEXT_H_
+#ifndef _LIBC_PRIVATE_H_
 int    __sys_setcontext(const ucontext_t *ucp);
 int    __sys_swapcontext(ucontext_t *oucp, const ucontext_t *ucp);
-#endif
+#endif /* _LIBC_PRIVATE_H_ */
+#endif /* _SYS_FCNTL_H_ */
 
 /* #include <unistd.h> */
 #ifdef  _UNISTD_H_
+void   __sys_exit(int);
+pid_t  __sys_getpid(void);
+#ifndef _LIBC_PRIVATE_H_
 int     __sys_close(int);
 int    __sys_fork(void);
-pid_t  __sys_getpid(void);
 ssize_t __sys_read(int, void *, size_t);
-void   __sys_exit(int);
-#endif
+#endif /* _LIBC_PRIVATE_H_ */
+#endif /* _SYS_FCNTL_H_ */
 
 static inline int
 _thr_isthreaded(void)
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to