Re: [PATCH] vfs: change 'struct file *' argument to 'const struct file *' where possible

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

 



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.




[Index of Archives]     [Linux Filesystems Devel]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux