summaryrefslogtreecommitdiffstats
path: root/sys/sys
diff options
context:
space:
mode:
authorpfg <pfg@FreeBSD.org>2017-03-14 20:14:57 +0000
committerpfg <pfg@FreeBSD.org>2017-03-14 20:14:57 +0000
commit8c08bfe0a237cbc568a58adcefa2b61e7a46fa9d (patch)
tree885ac3dd460b34cb7e8b9a30b568a3592fb4725e /sys/sys
parent85fddbd8bf2c10c05892daf14ffca4458f839f38 (diff)
downloadFreeBSD-src-8c08bfe0a237cbc568a58adcefa2b61e7a46fa9d.zip
FreeBSD-src-8c08bfe0a237cbc568a58adcefa2b61e7a46fa9d.tar.gz
MFC r312934:
Make use of clang nullability attributes in C headers. Replace uses of the GCC __nonnull__ attribute with the clang nullability qualifiers. These are starting to get use in clang's static analyzer. Replacement should be transparent for developers using clang. GCC ports from older FreeBSD versions may need updating if the compiler was built before r312860 (Jan-27-2017). Hinted by: Apple's Libc-1158.20.4, Bionic libc Relnotes: yes
Diffstat (limited to 'sys/sys')
-rw-r--r--sys/sys/systm.h70
1 files changed, 37 insertions, 33 deletions
diff --git a/sys/sys/systm.h b/sys/sys/systm.h
index 88e1838..5421b12 100644
--- a/sys/sys/systm.h
+++ b/sys/sys/systm.h
@@ -45,6 +45,8 @@
#include <sys/queue.h>
#include <sys/stdint.h> /* for people using printf mainly */
+__NULLABILITY_PRAGMA_PUSH
+
extern int cold; /* nonzero if we are doing a cold boot */
extern int suspend_blocked; /* block suspend due to pending shutdown */
extern int rebooting; /* kern_reboot() has been called. */
@@ -227,12 +229,12 @@ int vsnprintf(char *, size_t, const char *, __va_list) __printflike(3, 0);
int vsnrprintf(char *, size_t, int, const char *, __va_list) __printflike(4, 0);
int vsprintf(char *buf, const char *, __va_list) __printflike(2, 0);
int ttyprintf(struct tty *, const char *, ...) __printflike(2, 3);
-int sscanf(const char *, char const *, ...) __nonnull(1) __nonnull(2);
-int vsscanf(const char *, char const *, __va_list) __nonnull(1) __nonnull(2);
-long strtol(const char *, char **, int) __nonnull(1);
-u_long strtoul(const char *, char **, int) __nonnull(1);
-quad_t strtoq(const char *, char **, int) __nonnull(1);
-u_quad_t strtouq(const char *, char **, int) __nonnull(1);
+int sscanf(const char *, char const * _Nonnull, ...) __scanflike(2, 3);
+int vsscanf(const char * _Nonnull, char const * _Nonnull, __va_list) __scanflike(2, 0);
+long strtol(const char *, char **, int);
+u_long strtoul(const char *, char **, int);
+quad_t strtoq(const char *, char **, int);
+u_quad_t strtouq(const char *, char **, int);
void tprintf(struct proc *p, int pri, const char *, ...) __printflike(3, 4);
void vtprintf(struct proc *, int, const char *, __va_list) __printflike(3, 0);
void hexdump(const void *ptr, int length, const char *hdr, int flags);
@@ -243,27 +245,27 @@ void hexdump(const void *ptr, int length, const char *hdr, int flags);
#define HD_OMIT_CHARS (1 << 18)
#define ovbcopy(f, t, l) bcopy((f), (t), (l))
-void bcopy(const void *from, void *to, size_t len) __nonnull(1) __nonnull(2);
-void bzero(void *buf, size_t len) __nonnull(1);
-void explicit_bzero(void *, size_t) __nonnull(1);
-
-void *memcpy(void *to, const void *from, size_t len) __nonnull(1) __nonnull(2);
-void *memmove(void *dest, const void *src, size_t n) __nonnull(1) __nonnull(2);
-
-int copystr(const void * __restrict kfaddr, void * __restrict kdaddr,
- size_t len, size_t * __restrict lencopied)
- __nonnull(1) __nonnull(2);
-int copyinstr(const void * __restrict udaddr, void * __restrict kaddr,
- size_t len, size_t * __restrict lencopied)
- __nonnull(1) __nonnull(2);
-int copyin(const void * __restrict udaddr, void * __restrict kaddr,
- size_t len) __nonnull(1) __nonnull(2);
-int copyin_nofault(const void * __restrict udaddr, void * __restrict kaddr,
- size_t len) __nonnull(1) __nonnull(2);
-int copyout(const void * __restrict kaddr, void * __restrict udaddr,
- size_t len) __nonnull(1) __nonnull(2);
-int copyout_nofault(const void * __restrict kaddr, void * __restrict udaddr,
- size_t len) __nonnull(1) __nonnull(2);
+void bcopy(const void * _Nonnull from, void * _Nonnull to, size_t len);
+void bzero(void * _Nonnull buf, size_t len);
+void explicit_bzero(void * _Nonnull, size_t);
+
+void *memcpy(void * _Nonnull to, const void * _Nonnull from, size_t len);
+void *memmove(void * _Nonnull dest, const void * _Nonnull src, size_t n);
+
+int copystr(const void * _Nonnull __restrict kfaddr,
+ void * _Nonnull __restrict kdaddr, size_t len,
+ size_t * __restrict lencopied);
+int copyinstr(const void * __restrict udaddr,
+ void * _Nonnull __restrict kaddr, size_t len,
+ size_t * __restrict lencopied);
+int copyin(const void * _Nonnull __restrict udaddr,
+ void * _Nonnull __restrict kaddr, size_t len);
+int copyin_nofault(const void * _Nonnull __restrict udaddr,
+ void * _Nonnull __restrict kaddr, size_t len);
+int copyout(const void * _Nonnull __restrict kaddr,
+ void * _Nonnull __restrict udaddr, size_t len);
+int copyout_nofault(const void * _Nonnull __restrict kaddr,
+ void * _Nonnull __restrict udaddr, size_t len);
int fubyte(volatile const void *base);
long fuword(volatile const void *base);
@@ -377,16 +379,16 @@ static __inline void splx(intrmask_t ipl __unused) { return; }
* Common `proc' functions are declared here so that proc.h can be included
* less often.
*/
-int _sleep(void *chan, struct lock_object *lock, int pri, const char *wmesg,
- sbintime_t sbt, sbintime_t pr, int flags) __nonnull(1);
+int _sleep(void * _Nonnull chan, struct lock_object *lock, int pri,
+ const char *wmesg, sbintime_t sbt, sbintime_t pr, int flags);
#define msleep(chan, mtx, pri, wmesg, timo) \
_sleep((chan), &(mtx)->lock_object, (pri), (wmesg), \
tick_sbt * (timo), 0, C_HARDCLOCK)
#define msleep_sbt(chan, mtx, pri, wmesg, bt, pr, flags) \
_sleep((chan), &(mtx)->lock_object, (pri), (wmesg), (bt), (pr), \
(flags))
-int msleep_spin_sbt(void *chan, struct mtx *mtx, const char *wmesg,
- sbintime_t sbt, sbintime_t pr, int flags) __nonnull(1);
+int msleep_spin_sbt(void * _Nonnull chan, struct mtx *mtx,
+ const char *wmesg, sbintime_t sbt, sbintime_t pr, int flags);
#define msleep_spin(chan, mtx, wmesg, timo) \
msleep_spin_sbt((chan), (mtx), (wmesg), tick_sbt * (timo), \
0, C_HARDCLOCK)
@@ -399,8 +401,8 @@ int pause_sbt(const char *wmesg, sbintime_t sbt, sbintime_t pr,
0, C_HARDCLOCK)
#define tsleep_sbt(chan, pri, wmesg, bt, pr, flags) \
_sleep((chan), NULL, (pri), (wmesg), (bt), (pr), (flags))
-void wakeup(void *chan) __nonnull(1);
-void wakeup_one(void *chan) __nonnull(1);
+void wakeup(void * chan);
+void wakeup_one(void * chan);
/*
* Common `struct cdev *' stuff are declared here to avoid #include poisoning
@@ -446,4 +448,6 @@ void intr_prof_stack_use(struct thread *td, struct trapframe *frame);
void counted_warning(unsigned *counter, const char *msg);
+__NULLABILITY_PRAGMA_POP
+
#endif /* !_SYS_SYSTM_H_ */
OpenPOWER on IntegriCloud