From: Jesper Juhl <juhl-lkml@dif.dk>
To: Markus Lidel <Markus.Lidel@shadowconnect.com>
Cc: Christoph Hellwig <hch@infradead.org>,
linux-kernel <linux-kernel@vger.kernel.org>,
Alan Cox <alan@lxorguk.ukuu.org.uk>,
Andrew Morton <akpm@osdl.org>
Subject: Re: [PATCH] add missing checks of __copy_to_user return value in i2o_config.c
Date: Fri, 8 Oct 2004 02:23:51 +0200 (CEST) [thread overview]
Message-ID: <Pine.LNX.4.61.0410080210420.10473@dragon.hygekrogen.localhost> (raw)
In-Reply-To: <4165AEB9.8040608@shadowconnect.com>
On Thu, 7 Oct 2004, Markus Lidel wrote:
> Hello,
> thanks for fixing i2o_config.
You're welcome.
> In the meantime i've also made a patch, which
> tries to reduce the many return's too.
> Note: i've not touched the passthru stuff yet.
> Please let me know, which you think of it.
> --- a/drivers/message/i2o/i2o_config.c 2004-09-24 11:05:12.044972000 +0200
> +++ b/drivers/message/i2o/i2o_config.c 2004-10-07 22:49:59.786543596 +0200
> @@ -178,18 +178,17 @@
> struct i2o_controller *c;
> u8 __user *user_iop_table = (void __user *)arg;
> u8 tmp[MAX_I2O_CONTROLLERS];
> + int rc = 0;
Purely personal preference, I think "ret" is a more intuitive name for
that variable.
+ if (copy_from_user(&kcmd, cmd, sizeof(struct i2o_cmd_hrtlct))) {
+ rc = -EFAULT;
+ goto exit;
+ }
[...]
+exit:
+ return rc;
};
I prefer the
if (foo)
goto return_fault;
[...]
return_ret:
return ret;
return_fault:
ret = -EFAULT;
goto return_ret;
variant.
Sure, your way results in just a single mov and a single jmp when
the branch is taken, but, my way has only a single jmp at each branch,
then a mov and an additional jmp at the end, so for a single branch your
way wins with
1 mov + 1 jmp vs my 2 jmp's and 1 mov.
but, when you have a lot those branches my way generates less code. At 5
branches you have 5 mov + 5 jmp while I'll have 1 mov + 6 jmp.
Also, my way takes up less space in the source, so more code fits on
screen.
I doubt it matters much since this doesn't look like a very hot code path,
but I prefer the version that generates the smaller code and takes up less
space in the source.
Apart from those nitpicks it looks good to me :)
--
Jesper Juhl
prev parent reply other threads:[~2004-10-08 0:21 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-10-05 21:43 Jesper Juhl
2004-10-05 22:21 ` Andrew Morton
2004-10-05 22:34 ` Jesper Juhl
2004-10-05 22:43 ` Andrew Morton
2004-10-05 23:11 ` Jesper Juhl
2004-10-06 10:41 ` Christoph Hellwig
2004-10-06 20:11 ` Jesper Juhl
2004-10-07 21:01 ` Markus Lidel
2004-10-08 0:23 ` Jesper Juhl [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=Pine.LNX.4.61.0410080210420.10473@dragon.hygekrogen.localhost \
--to=juhl-lkml@dif.dk \
--cc=Markus.Lidel@shadowconnect.com \
--cc=akpm@osdl.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=hch@infradead.org \
--cc=linux-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®