summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2003-09-10 04:24:55 +1000
committerPaul Mackerras <paulus@samba.org>2003-09-10 04:24:55 +1000
commit3e2adaf6c0bc9c23da70e1957d63bc1c644015e4 (patch)
tree233ca61ad33e6f002302f0d83d43d33831f946b9 /include
parentd59b047306655c3da13045f65f2206b4cdfa3eea (diff)
parent29472126c4af5d7a320baa15f0510766330633ee (diff)
Merge bk://ppc@ppc.bkbits.net/for-linus-ppc
into samba.org:/home/paulus/kernel/for-linus-ppc
Diffstat (limited to 'include')
-rw-r--r--include/asm-ppc/ioctl.h16
1 files changed, 13 insertions, 3 deletions
diff --git a/include/asm-ppc/ioctl.h b/include/asm-ppc/ioctl.h
index 8785a3a85d26..8d8cb7ec4f01 100644
--- a/include/asm-ppc/ioctl.h
+++ b/include/asm-ppc/ioctl.h
@@ -37,11 +37,21 @@
((nr) << _IOC_NRSHIFT) | \
((size) << _IOC_SIZESHIFT))
+/* provoke compile error for invalid uses of size argument */
+extern int __invalid_size_argument_for_IOC;
+#define _IOC_TYPECHECK(t) \
+ ((sizeof(t) == sizeof(t[1]) && \
+ sizeof(t) < (1 << _IOC_SIZEBITS)) ? \
+ sizeof(t) : __invalid_size_argument_for_IOC)
+
/* used to create numbers */
#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0)
-#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size))
-#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size))
-#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size))
+#define _IOR(type,nr,size) _IOC(_IOC_READ,(type),(nr),(_IOC_TYPECHECK(size)))
+#define _IOW(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size)))
+#define _IOWR(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),(_IOC_TYPECHECK(size)))
+#define _IOR_BAD(type,nr,size) _IOC(_IOC_READ,(type),(nr),sizeof(size))
+#define _IOW_BAD(type,nr,size) _IOC(_IOC_WRITE,(type),(nr),sizeof(size))
+#define _IOWR_BAD(type,nr,size) _IOC(_IOC_READ|_IOC_WRITE,(type),(nr),sizeof(size))
/* used to decode them.. */
#define _IOC_DIR(nr) (((nr) >> _IOC_DIRSHIFT) & _IOC_DIRMASK)