From: Cong Wang <amwang@redhat.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org,
Alexander Viro <viro@zeniv.linux.org.uk>,
Arnd Bergmann <arnd@arndb.de>
Subject: Re: [Patch] compat ioctl: fix some build warnings
Date: Mon, 08 Feb 2010 10:56:26 +0800 [thread overview]
Message-ID: <4B6F7D5A.50501@redhat.com> (raw)
In-Reply-To: <20100205140150.7f5df97b.akpm@linux-foundation.org>
Andrew Morton wrote:
> On Fri, 5 Feb 2010 02:05:56 -0500
> Amerigo Wang <amwang@redhat.com> wrote:
>
>> I got these warnings:
>>
>> fs/compat_ioctl.c: In function ___compat_sys_ioctl':
>> fs/compat_ioctl.c:534: warning: ___karg' may be used uninitialized in this function
>> fs/compat_ioctl.c:533: warning: ___kcmd' may be used uninitialized in this function
>> fs/compat_ioctl.c:656: warning: ___ret' may be used uninitialized in this function
>>
>> These warnings are harmless, so just shut gcc up.
>>
>> Signed-off-by: WANG Cong <amwang@redhat.com>
>> Cc: Alexander Viro <viro@zeniv.linux.org.uk>
>> Cc: Arnd Bergmann <arnd@arndb.de>
>>
>> ---
>> diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
>> index c5c45de..2468f80 100644
>> --- a/fs/compat_ioctl.c
>> +++ b/fs/compat_ioctl.c
>> @@ -543,6 +543,8 @@ static int mt_ioctl_trans(unsigned int fd, unsigned int cmd, void __user *argp)
>> kcmd = MTIOCGET;
>> karg = &get;
>> break;
>> + default:
>> + return -EINVAL;
>> }
>> set_fs (KERNEL_DS);
>> err = sys_ioctl (fd, kcmd, (unsigned long)karg);
>> @@ -653,7 +655,7 @@ static int set_raw32_request(struct raw_config_request *req, struct raw32_config
>> static int raw_ioctl(unsigned fd, unsigned cmd,
>> struct raw32_config_request __user *user_req)
>> {
>> - int ret;
>> + int ret = -EINVAL;
>>
>> switch (cmd) {
>> case RAW_SETBIND:
>
> Unfortunately that adds more code for something which cannot happen at
> runtime.
>
> I guess we could do this trick:
>
> --- a/fs/compat_ioctl.c~a
> +++ a/fs/compat_ioctl.c
> @@ -539,7 +539,7 @@ static int mt_ioctl_trans(unsigned int f
> kcmd = MTIOCPOS;
> karg = &pos;
> break;
> - case MTIOCGET32:
> + default: /* MTIOCGET32 */
> kcmd = MTIOCGET;
> karg = &get;
> break;
> @@ -657,7 +657,7 @@ static int raw_ioctl(unsigned fd, unsign
>
> switch (cmd) {
> case RAW_SETBIND:
> - case RAW_GETBIND: {
> + default: { /* RAW_GETBIND */
> struct raw_config_request req;
> mm_segment_t oldfs = get_fs();
>
> _
>
>
> Which actually reduces code:
>
> akpm:/usr/src/25> size fs/compat_ioctl.o
> text data bss dec hex filename
> 9012 2232 2864 14108 371c fs/compat_ioctl.o
>
> 8968 2232 2848 14048 36e0 fs/compat_ioctl.o
>
Yeah! Definitely better.
Thanks, Andrew!
prev parent reply other threads:[~2010-02-08 2:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-05 7:05 [Patch] compat ioctl: fix some build warnings Amerigo Wang
2010-02-05 22:01 ` Andrew Morton
2010-02-06 8:58 ` Arnd Bergmann
2010-02-08 2:56 ` Cong Wang [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=4B6F7D5A.50501@redhat.com \
--to=amwang@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox