summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2003-07-21 18:35:51 +0000
committerphk <phk@FreeBSD.org>2003-07-21 18:35:51 +0000
commit88e6a8374689d8102f4b151b94dbe307e4726210 (patch)
treed9432eca0f0b7c6192970d44da96ee9038ea1afd /sys
parent0914303fac7bcaf1a83b12ff3b58676e973eef1f (diff)
downloadFreeBSD-src-88e6a8374689d8102f4b151b94dbe307e4726210.zip
FreeBSD-src-88e6a8374689d8102f4b151b94dbe307e4726210.tar.gz
Add a new macro __nonnull(x) to use the new GCC33 attribute which checks
that an argument is not a NULL pointer. Apply various obvious places. I belive __printf*() implies __nonnull() so it is not needed on functions already tagged that way.
Diffstat (limited to 'sys')
-rw-r--r--sys/sys/cdefs.h6
-rw-r--r--sys/sys/systm.h32
2 files changed, 22 insertions, 16 deletions
diff --git a/sys/sys/cdefs.h b/sys/sys/cdefs.h
index ff81fb5..b3a5485 100644
--- a/sys/sys/cdefs.h
+++ b/sys/sys/cdefs.h
@@ -143,6 +143,12 @@
#endif
#endif
+#if __GNUC__ == 3 && __GNUC_MINOR__ >= 3
+#define __nonnull(x) __attribute__((__nonnull__(x)))
+#else
+#define __nonnull(x)
+#endif
+
/* XXX: should use `#if __STDC_VERSION__ < 199901'. */
#if !(__GNUC__ == 2 && __GNUC_MINOR__ >= 7 || __GNUC__ >= 3)
#define __func__ NULL
diff --git a/sys/sys/systm.h b/sys/sys/systm.h
index 0f7889f..abdc0b2 100644
--- a/sys/sys/systm.h
+++ b/sys/sys/systm.h
@@ -122,7 +122,7 @@ struct _jmp_buf;
int setjmp(struct _jmp_buf *);
void longjmp(struct _jmp_buf *, int) __dead2;
-void Debugger(const char *msg);
+void Debugger(const char *msg) __nonnull(1);
int dumpstatus(vm_offset_t addr, off_t count);
int nullop(void);
int eopnotsupp(void);
@@ -162,26 +162,26 @@ 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 *, ...);
-int vsscanf(const char *, char const *, __va_list);
-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);
+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) __nonnull(2);
+u_long strtoul(const char *, char **, int) __nonnull(1), __nonnull(2);
+quad_t strtoq(const char *, char **, int) __nonnull(1);
+u_quad_t strtouq(const char *, char **, int) __nonnull(1);
void tprintf(struct proc *p, int pri, const char *, ...) __printflike(3, 4);
#define ovbcopy(f, t, l) bcopy((f), (t), (l))
-void bcopy(const void *from, void *to, size_t len);
-void bzero(void *buf, size_t len);
+void bcopy(const void *from, void *to, size_t len) __nonnull(1) __nonnull(2);
+void bzero(void *buf, size_t len) __nonnull(1);
-void *memcpy(void *to, const void *from, size_t len);
+void *memcpy(void *to, const void *from, size_t len) __nonnull(1) __nonnull(2);
int copystr(const void *kfaddr, void *kdaddr, size_t len,
- size_t *lencopied);
+ size_t *lencopied) __nonnull(1) __nonnull(2);
int copyinstr(const void *udaddr, void *kaddr, size_t len,
- size_t *lencopied);
-int copyin(const void *udaddr, void *kaddr, size_t len);
-int copyout(const void *kaddr, void *udaddr, size_t len);
+ size_t *lencopied) __nonnull(1) __nonnull(2);
+int copyin(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);
int fubyte(const void *base);
long fuword(const void *base);
@@ -299,8 +299,8 @@ int msleep(void *chan, struct mtx *mtx, int pri, const char *wmesg,
int timo);
void abortsleep(struct thread *td);
#define tsleep(chan, pri, wmesg, timo) msleep(chan, NULL, pri, wmesg, timo)
-void wakeup(void *chan);
-void wakeup_one(void *chan);
+void wakeup(void *chan) __nonnull(1);
+void wakeup_one(void *chan) __nonnull(1);
/*
* Common `dev_t' stuff are declared here to avoid #include poisoning
OpenPOWER on IntegriCloud