mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Stoyan Gaydarov" <stoyboyker@gmail.com>
To: "Arnd Bergmann" <arnd@arndb.de>
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 03:21:59 -0500	[thread overview]
Message-ID: <6d291e080807110121t203c7cd0v9c84fb087cd75aa0@mail.gmail.com> (raw)
In-Reply-To: <200807111008.21497.arnd@arndb.de>

On Fri, Jul 11, 2008 at 3:08 AM, Arnd Bergmann <arnd@arndb.de> wrote:
> 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;
> }

This would work normally but there are three early returns and the
rest are just switch statements that set the return code.

>
> 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 <><
>

  reply	other threads:[~2008-07-11  8:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-11  0:28 Stoyan Gaydarov
2008-07-11  8:08 ` Arnd Bergmann
2008-07-11  8:21   ` Stoyan Gaydarov [this message]
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=6d291e080807110121t203c7cd0v9c84fb087cd75aa0@mail.gmail.com \
    --to=stoyboyker@gmail.com \
    --cc=arnd@arndb.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=pavel@suse.cz \
    --cc=rjw@sisk.pl \
    /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®