public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Andreas Schwab <schwab@suse.de>, "Kevin P. Fleming" <kpfleming@cox.net>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] new ioctl type checking causes gcc warning
Date: Fri, 12 Sep 2003 14:53:06 +0200	[thread overview]
Message-ID: <200309121453.07111.arnd@arndb.de> (raw)
In-Reply-To: <je65jx3hdk.fsf@sykes.suse.de>

On Friday 12 September 2003 22:02, Andreas Schwab wrote:
> "Kevin P. Fleming" <kpfleming@cox.net> writes:
> >   /* provoke compile error for invalid uses of size argument */
> > -extern int __invalid_size_argument_for_IOC;
> > +extern unsigned int __invalid_size_argument_for_IOC;
>
> Why not make it size_t which is what sizeof actually returns?

I had tried that first, but found that there are places that
use asm/ioctl.h without including asm/posix_types.h first, so 
size_t might not be declared. unsigned int (or unsigned long)
is the better alternative here. Does this look ok to everyone?

	Arnd <><

===== include/asm-i386/ioctl.h 1.2 vs edited =====
--- 1.2/include/asm-i386/ioctl.h	Mon Sep  8 15:21:28 2003
+++ edited/include/asm-i386/ioctl.h	Fri Sep 12 14:42:58 2003
@@ -52,12 +52,16 @@
 	 ((nr)   << _IOC_NRSHIFT) | \
 	 ((size) << _IOC_SIZESHIFT))
 
+#ifdef __KERNEL__
 /* provoke compile error for invalid uses of size argument */
-extern int __invalid_size_argument_for_IOC;
+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)
+#else
+#define _IOC_TYPECHECK(t) sizeof(t)
+#endif
 
 /* used to create numbers */
 #define _IO(type,nr)		_IOC(_IOC_NONE,(type),(nr),0)
===== include/asm-ppc/ioctl.h 1.4 vs edited =====
--- 1.4/include/asm-ppc/ioctl.h	Mon Sep  8 20:14:00 2003
+++ edited/include/asm-ppc/ioctl.h	Fri Sep 12 14:42:42 2003
@@ -37,12 +37,16 @@
 	 ((nr)   << _IOC_NRSHIFT) | \
 	 ((size) << _IOC_SIZESHIFT))
 
+#ifdef __KERNEL__
 /* provoke compile error for invalid uses of size argument */
-extern int __invalid_size_argument_for_IOC;
+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)
+#else
+#define _IOC_TYPECHECK(t) sizeof(t)
+#endif
 
 /* used to create numbers */
 #define _IO(type,nr)		_IOC(_IOC_NONE,(type),(nr),0)
===== include/asm-ppc64/ioctl.h 1.2 vs edited =====
--- 1.2/include/asm-ppc64/ioctl.h	Tue Sep  9 22:23:09 2003
+++ edited/include/asm-ppc64/ioctl.h	Fri Sep 12 14:43:50 2003
@@ -42,12 +42,16 @@
 	 ((nr)   << _IOC_NRSHIFT) | \
 	 ((size) << _IOC_SIZESHIFT))
 
+#ifdef __KERNEL__
 /* provoke compile error for invalid uses of size argument */
-extern int __invalid_size_argument_for_IOC;
+extern unsigned long __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)
+#else
+#define _IOC_TYPECHECK(t) sizeof(t)
+#endif
 
 /* used to create numbers */
 #define _IO(type,nr)		_IOC(_IOC_NONE,(type),(nr),0)


  reply	other threads:[~2003-09-12 23:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-12 19:13 [PATCH] new ioctl type checking causes gcc warning Kevin P. Fleming
2003-09-12 20:02 ` Andreas Schwab
2003-09-12 12:53   ` Arnd Bergmann [this message]
2003-09-12 23:43     ` Kevin P. Fleming
2003-09-13  0:22       ` Arnd Bergmann
2003-09-13  0:31         ` Kevin P. Fleming
2003-09-13 11:05           ` Arnd Bergmann
2003-09-13 13:17             ` Kevin P. Fleming
2003-09-13 19:10       ` Jamie Lokier

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=200309121453.07111.arnd@arndb.de \
    --to=arnd@arndb.de \
    --cc=kpfleming@cox.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=schwab@suse.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox