Re: [PATCH] ioctl conversion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <><
_______________________________________________
linux-pm mailing list
linux-pm@xxxxxxxxxxxxxxxxxxxxxxxxxx
https://lists.linux-foundation.org/mailman/listinfo/linux-pm


[Index of Archives]     [Linux ACPI]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [CPU Freq]     [Kernel Newbies]     [Fedora Kernel]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux