From: Arnd Bergmann <arnd@arndb.de>
To: "Stoyan Gaydarov" <stoyboyker@gmail.com>
Cc: rjw@sisk.pl, pavel@suse.cz, linux-kernel@vger.kernel.org,
linux-pm@lists.linux-foundation.org
Subject: Re: [PATCH] ioctl conversion
Date: Fri, 11 Jul 2008 10:08:20 +0200 [thread overview]
Message-ID: <200807111008.21497.arnd@arndb.de> (raw)
In-Reply-To: <6d291e080807101728j62be7c93qba11aa214a8dfe1@mail.gmail.com>
On Friday 11 July 2008, Stoyan Gaydarov wrote:
> - if (_IOC_TYPE(cmd) != SNAPSHOT_IOC_MAGIC)
> + lock_kernel();
> +
> + if (_IOC_TYPE(cmd) != SNAPSHOT_IOC_MAGIC) {
> + unlock_kernel();
> return -ENOTTY;
> - if (_IOC_NR(cmd) > SNAPSHOT_IOC_MAXNR)
> + }
> + if (_IOC_NR(cmd) > SNAPSHOT_IOC_MAXNR) {
> + unlock_kernel();
> return -ENOTTY;
> - if (!capable(CAP_SYS_ADMIN))
> + }
> + if (!capable(CAP_SYS_ADMIN)) {
> + unlock_kernel();
> return -EPERM;
> + }
>
> data = filp->private_data;
The more common way to express this is to end the function with
out:
unlock_kernel();
return ret;
}
and then jump to that label in the error case. This makes it
much easier to verify that you haven't missed a cased.
Arnd <><
next prev parent reply other threads:[~2008-07-11 8:09 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-11 0:28 [PATCH] ioctl conversion Stoyan Gaydarov
2008-07-11 8:08 ` Arnd Bergmann [this message]
2008-07-11 8:21 ` Stoyan Gaydarov
2008-07-11 9:22 ` Arnd Bergmann
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=200807111008.21497.arnd@arndb.de \
--to=arnd@arndb.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@lists.linux-foundation.org \
--cc=pavel@suse.cz \
--cc=rjw@sisk.pl \
--cc=stoyboyker@gmail.com \
/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