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:27:34PM +0100, Matthew Wilcox wrote:
> 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)))

Um...  You do realize that backing_file_user_path() has users in places
that do *NOT* see the definition of struct backing_file?




[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