Re: [PATCH 2/2] proc: use typeof_member() macro

From: Andrew Morton
Date: Wed May 29 2019 - 18:37:09 EST


On Wed, 29 May 2019 22:11:10 +0300 Alexey Dobriyan <adobriyan@xxxxxxxxx> wrote:

> Don't repeat function signatures twice.
>
> This is a kind-of-precursor for "struct proc_ops".
>
> Note:
>
> typeof(pde->proc_fops->...) ...;
>
> can't be used because ->proc_fops is "const struct file_operations *".
> "const" prevents assignment down the code and it can't be deleted
> in the type system.
>
> ...
>
> --- a/fs/proc/inode.c
> +++ b/fs/proc/inode.c
> @@ -200,7 +200,8 @@ static loff_t proc_reg_llseek(struct file *file, loff_t offset, int whence)
> struct proc_dir_entry *pde = PDE(file_inode(file));
> loff_t rv = -EINVAL;
> if (use_pde(pde)) {
> - loff_t (*llseek)(struct file *, loff_t, int);
> + typeof_member(struct file_operations, llseek) llseek;

ooh. That's pretty nifty.