linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Alexey Dobriyan <adobriyan@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] proc: use typeof_member() macro
Date: Wed, 29 May 2019 15:33:37 -0700	[thread overview]
Message-ID: <20190529153337.3e8fcd2b6b54e11e5ef23d04@linux-foundation.org> (raw)
In-Reply-To: <20190529191110.GB5703@avx2>

On Wed, 29 May 2019 22:11:10 +0300 Alexey Dobriyan <adobriyan@gmail.com> 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.



  reply	other threads:[~2019-05-29 22:33 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-29 19:07 [PATCH 1/2] add " Alexey Dobriyan
2019-05-29 19:11 ` [PATCH 2/2] proc: use " Alexey Dobriyan
2019-05-29 22:33   ` Andrew Morton [this message]
2019-05-30 11:37 ` [PATCH 1/2] add " David Laight
2019-05-30 11:53   ` Joe Perches
2019-05-30 19:57   ` Alexey Dobriyan

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=20190529153337.3e8fcd2b6b54e11e5ef23d04@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=adobriyan@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --subject='Re: [PATCH 2/2] proc: use typeof_member() macro' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).