From: Arnd Bergmann <arnd@arndb.de>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Michael Abbott <michael@araneidae.co.uk>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH]: Make ioctl.h compatible with userland
Date: Tue, 12 Aug 2008 17:12:18 +0200 [thread overview]
Message-ID: <200808121712.19207.arnd@arndb.de> (raw)
In-Reply-To: <20080730011035.a7d84e55.akpm@linux-foundation.org>
[PATCH] Make _IOC_TYPECHECK use BUILD_BUG_ON_ZERO
This converts _IOC_TYPECHECK from a link error to a compile-time
error using BUILD_BUG_ON_ZERO. This makes it possible to use
the standard _IOC macros in user space even with non-optizing
compilers.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
On Wednesday 30 July 2008, Andrew Morton wrote:
> We could also replace that open-coded assertion with the shiny new
> BUILD_BUG_ON(), which would a) be cleaner and b) fix the problem which
> you describe. I expect that would be quite safe, but obviously doesn't
> have all the testing which the above patch has, so shrug.
There is one significant difference: using BUILD_BUG_ON_ZERO will
break user space code that uses broken ioctl number definitions
like _IOC('x', 1, sizeof(int)) that were fixed up in the kernel
but not in external copies of the definitions.
I'm undecided whether such breakage would be a good or a bad thing.
--- a/include/asm-generic/ioctl.h
+++ b/include/asm-generic/ioctl.h
@@ -69,11 +69,9 @@
((size) << _IOC_SIZESHIFT))
/* provoke compile error for invalid uses of size argument */
-extern unsigned 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)
+#define _IOC_TYPECHECK(t) (sizeof(t) + \
+ BUILD_BUG_ON_ZERO(sizeof(t) != sizeof(t[1]) || \
+ sizeof(t) >= (1 << _IOC_SIZEBITS)))
/* used to create numbers */
#define _IO(type,nr) _IOC(_IOC_NONE,(type),(nr),0)
prev parent reply other threads:[~2008-08-12 15:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-28 6:48 [PATCH]: Make ioctl.h compatible with userland Michael Abbott
2008-07-30 8:10 ` Andrew Morton
2008-08-12 15:12 ` Arnd Bergmann [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200808121712.19207.arnd@arndb.de \
--to=arnd@arndb.de \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michael@araneidae.co.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.