From ee26c26de2074dd433e5c5010ebc4d2769bbf386 Mon Sep 17 00:00:00 2001
From: Sascha Wildner <saw@online.de>
Date: Mon, 22 Jan 2018 13:15:17 +0100
Subject: [PATCH 21/21] WIP __nonnull variadic

---
 include/pthread.h | 11 +++++------
 sys/sys/cdefs.h   |  6 +++---
 sys/sys/systm.h   | 22 ++++++++++------------
 3 files changed, 18 insertions(+), 21 deletions(-)

diff --git a/include/pthread.h b/include/pthread.h
index 991ecaa976..dba7b30304 100644
--- a/include/pthread.h
+++ b/include/pthread.h
@@ -184,11 +184,10 @@ int	pthread_cond_init(pthread_cond_t *, const pthread_condattr_t *)
 int	pthread_cond_signal(pthread_cond_t *) __nonnull(1);
 int	pthread_cond_timedwait(pthread_cond_t *, pthread_mutex_t *,
 			       const struct timespec *) __nonnull(2);
-int	pthread_cond_wait(pthread_cond_t *, pthread_mutex_t *)
-			  __nonnull(1) __nonnull(2);
+int	pthread_cond_wait(pthread_cond_t *, pthread_mutex_t *) __nonnull(1, 2);
 
 int	pthread_create(pthread_t *, const pthread_attr_t *,
-		       void *(*) (void *), void *) __nonnull(1) __nonnull(3);
+		       void *(*) (void *), void *) __nonnull(1, 3);
 int	pthread_detach(pthread_t);
 int	pthread_equal(pthread_t, pthread_t);
 void	pthread_exit(void *) __dead2;
@@ -220,9 +219,9 @@ int	pthread_rwlock_init(pthread_rwlock_t *, const pthread_rwlockattr_t *)
 			    __nonnull(1);
 int	pthread_rwlock_rdlock(pthread_rwlock_t *) __nonnull(1);
 int	pthread_rwlock_timedrdlock(pthread_rwlock_t *, const struct timespec *)
-				   __nonnull(1) __nonnull(2);
+				   __nonnull(1, 2);
 int	pthread_rwlock_timedwrlock(pthread_rwlock_t *, const struct timespec *)
-				   __nonnull(1) __nonnull(2);
+				   __nonnull(1, 2);
 int	pthread_rwlock_tryrdlock(pthread_rwlock_t *);
 int	pthread_rwlock_trywrlock(pthread_rwlock_t *);
 int	pthread_rwlock_unlock(pthread_rwlock_t *);
@@ -230,7 +229,7 @@ int	pthread_rwlock_wrlock(pthread_rwlock_t *) __nonnull(1);
 
 int	pthread_rwlockattr_destroy(pthread_rwlockattr_t *);
 int	pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *, int *)
-				      __nonnull(1) __nonnull(2);
+				      __nonnull(1, 2);
 int	pthread_rwlockattr_init(pthread_rwlockattr_t *);
 int	pthread_rwlockattr_setpshared(pthread_rwlockattr_t *, int) __nonnull(1);
 
diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h
index 612fa0ae8b..2b5e31fd75 100644
--- a/sys/sys/cdefs.h
+++ b/sys/sys/cdefs.h
@@ -170,7 +170,7 @@
 #define	__alloc_size(x)
 #define	__section(x)
 #define	__always_inline
-#define	__nonnull(x)
+#define	__nonnull(...)
 #define	__heedresult
 #define	__malloclike
 #define	__returns_twice
@@ -209,10 +209,10 @@
 #endif
 
 #if __GNUC_PREREQ__(3, 3)
-#define	__nonnull(x)	__attribute__((__nonnull__(x)))
+#define	__nonnull(...)	__attribute__((__nonnull__(__VA_ARGS__)))
 #define	__used		__attribute__((__used__))
 #else
-#define	__nonnull(x)
+#define	__nonnull(...)
 #define	__used		__unused
 #endif
 
diff --git a/sys/sys/systm.h b/sys/sys/systm.h
index 049f30973a..dd0ecb0b70 100644
--- a/sys/sys/systm.h
+++ b/sys/sys/systm.h
@@ -223,9 +223,9 @@ void	kprint_cpuset(cpumask_t *mask);
 #define	HD_OMIT_HEX	(1 << 17)
 #define	HD_OMIT_CHARS	(1 << 18)
 int	ksscanf(const char *, char const *, ...)
-	    __nonnull(1) __nonnull(2) __scanflike(2, 3);
+	    __nonnull(1, 2) __scanflike(2, 3);
 int	kvsscanf(const char *, char const *, __va_list)
-	    __nonnull(1) __nonnull(2) __scanflike(2, 0);
+	    __nonnull(1, 2) __scanflike(2, 0);
 void	kvasfree(char **);
 
 long	strtol(const char *, char **, int) __nonnull(1);
@@ -238,26 +238,24 @@ u_quad_t strtouq(const char *, char **, int) __nonnull(1);
  * pointers to volatile storage, volatile set to avoid warnings.
  */
 void	bcopy(volatile const void *from, volatile void *to, size_t len)
-	    __nonnull(1) __nonnull(2);
+	    __nonnull(1, 2);
 void	bzero(volatile void *buf, size_t len) __nonnull(1);
 void	bzeront(volatile void *buf, size_t len) __nonnull(1);
 void	*memcpy(void *to, const void *from, size_t len)
-	    __nonnull(1) __nonnull(2);
+	    __nonnull(1, 2);
 
 long	kreadmem64(const void *addr);
 
 int	copystr (const void *kfaddr, void *kdaddr, size_t len,
-		size_t *lencopied) __nonnull(1) __nonnull(2);
+		size_t *lencopied) __nonnull(1, 2);
 int	copyinstr (const void *udaddr, void *kaddr, size_t len,
-		size_t *lencopied) __nonnull(1) __nonnull(2);
-int	copyin(const void *udaddr, void *kaddr, size_t len)
-	    __nonnull(1) __nonnull(2);
+		size_t *lencopied) __nonnull(1, 2);
+int	copyin(const void *udaddr, void *kaddr, size_t len) __nonnull(1, 2);
 int	copyin_nofault(const void *udaddr, void *kaddr, size_t len)
-	    __nonnull(1) __nonnull(2);
-int	copyout(const void *kaddr, void *udaddr, size_t len)
-	    __nonnull(1) __nonnull(2);
+	    __nonnull(1, 2);
+int	copyout(const void *kaddr, void *udaddr, size_t len) __nonnull(1, 2);
 int	copyout_nofault(const void *kaddr, void *udaddr, size_t len)
-	    __nonnull(1) __nonnull(2);
+	    __nonnull(1, 2);
 
 int	fubyte (const uint8_t *base);
 int	subyte (uint8_t *base, uint8_t byte);
-- 
2.15.1

