From: Blaisorblade <blaisorblade@yahoo.it>
To: Jeff Dike <jdike@addtoit.com>
Cc: user-mode-linux-devel@lists.sourceforge.net
Subject: [uml-devel] Real fix for rejected patch uaccess-warning
Date: Tue, 7 Mar 2006 20:31:15 +0100 [thread overview]
Message-ID: <200603072031.18574.blaisorblade@yahoo.it> (raw)
[-- Attachment #1: Type: text/plain, Size: 1399 bytes --]
About
http://user-mode-linux.sourceforge.net/work/current/2.6/2.6.16-rc4/patches/uaccess-warning
I read the patch which was rejected and noticed that you put there style
changes to get_user. They should be kept while the rest of the patch thrown
away, obviously, as discussed, but reading that made me wonder at this
(changes are just whitespace fixups):
- const __typeof__(ptr) __private_ptr = ptr; \
- __typeof__(*(__private_ptr)) __private_val; \
[...]
- if (__copy_from_user(&__private_val, (__private_ptr), \
- sizeof(*(__private_ptr))) == 0) {\
Given that __private_ptr is a const pointer, __private_val is a const value,
where we store something with __copy_from_user.
That's likely why GCC complains.
To fix that, we should remove some excess constness. Try the attached patch (I
haven't GCC 4.1 installed).
Also, I wonder why all this complicate and extra type-checked calls are
needed.
The i386 source use typeof only in 1 case, for put_user:
when I put_user((short)b, (unsigned long *) c) I must first cast (i.e.
zero-extend) b to a long and only after write it to c; writing the 4/8 bytes
pointed to by &b would be meaningless.
All this IMHO, obviously.
--
Inform me of my mistakes, so I can keep imitating Homer Simpson's "Doh!".
Paolo Giarrusso, aka Blaisorblade (Skype ID "PaoloGiarrusso", ICQ 215621894)
http://www.user-mode-linux.org/~blaisorblade
[-- Attachment #2: uml-fix-const-warns-gcc-4_1 --]
[-- Type: text/x-diff, Size: 874 bytes --]
Index: linux-2.6.git/include/asm-um/uaccess.h
===================================================================
--- linux-2.6.git.orig/include/asm-um/uaccess.h
+++ linux-2.6.git/include/asm-um/uaccess.h
@@ -42,7 +42,7 @@
#define __get_user(x, ptr) \
({ \
const __typeof__(ptr) __private_ptr = ptr; \
- __typeof__(*(__private_ptr)) __private_val; \
+ __typeof__(*(ptr)) __private_val; \
int __private_ret = -EFAULT; \
(x) = (__typeof__(*(__private_ptr)))0; \
if (__copy_from_user(&__private_val, (__private_ptr), \
@@ -55,7 +55,7 @@
#define get_user(x, ptr) \
({ \
- const __typeof__((*(ptr))) __user *private_ptr = (ptr); \
+ __typeof__((*(ptr))) __user *private_ptr = (ptr); \
(access_ok(VERIFY_READ, private_ptr, sizeof(*private_ptr)) ? \
__get_user(x, private_ptr) : ((x) = 0, -EFAULT)); \
})
next reply other threads:[~2006-03-07 19:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-03-07 19:31 Blaisorblade [this message]
2006-03-09 16:57 ` [uml-devel] Real fix for rejected patch uaccess-warning Jeff Dike
2006-03-10 15:22 ` Blaisorblade
2006-03-23 20:58 ` Jeff Dike
2006-03-23 23:52 ` Blaisorblade
2006-03-24 1:54 ` Jeff Dike
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=200603072031.18574.blaisorblade@yahoo.it \
--to=blaisorblade@yahoo.it \
--cc=jdike@addtoit.com \
--cc=user-mode-linux-devel@lists.sourceforge.net \
/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