linux-unionfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Miklos Szeredi <mszeredi@redhat.com>
Cc: linux-fsdevel@vger.kernel.org, linux-unionfs@vger.kernel.org,
	"André Almeida" <andrealmeid@igalia.com>,
	"John Schoenick" <johns@valvesoftware.com>
Subject: Re: [PATCH] vfs: change 'struct file *' argument to 'const struct file *' where possible
Date: Mon, 5 May 2025 17:27:34 +0100	[thread overview]
Message-ID: <aBjm9khhIBOUTFcV@casper.infradead.org> (raw)
In-Reply-To: <20250505154149.301235-1-mszeredi@redhat.com>

On Mon, May 05, 2025 at 05:41:47PM +0200, Miklos Szeredi wrote:
> -static inline struct backing_file *backing_file(struct file *f)
> +#define backing_file(f) container_of(f, struct backing_file, file)
> +
> +struct path *backing_file_user_path(struct file *f)
>  {
> -	return container_of(f, struct backing_file, file);
> +	return &backing_file(f)->user_path;
>  }
>  
> -struct path *backing_file_user_path(struct file *f)
> +const struct path *backing_file_user_path_c(const struct file *f)
>  {
>  	return &backing_file(f)->user_path;
>  }
> -EXPORT_SYMBOL_GPL(backing_file_user_path);
> +EXPORT_SYMBOL_GPL(backing_file_user_path_c);

May I suggest:

#define backing_file_user_path(f)	(_Generic((f),		\
	const struct file *:	(const struct path *)&backing_file(f)->user_path,  \
	struct file *:		(struct path *)&backing_file(f)->user_path)))

It's the same technique we use for page_folio() so it's quite well
tested.

  reply	other threads:[~2025-05-05 16:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-05 15:41 [PATCH] vfs: change 'struct file *' argument to 'const struct file *' where possible Miklos Szeredi
2025-05-05 16:27 ` Matthew Wilcox [this message]
2025-05-05 17:29   ` Al Viro

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=aBjm9khhIBOUTFcV@casper.infradead.org \
    --to=willy@infradead.org \
    --cc=andrealmeid@igalia.com \
    --cc=johns@valvesoftware.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=mszeredi@redhat.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;
as well as URLs for NNTP newsgroup(s).