Re: [PATCH] xfs: Add const qualifiers

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

 



On Tue, Dec 13, 2022 at 08:54:45PM +0000, Matthew Wilcox (Oracle) wrote:
> With a container_of() that preserves const, the compiler warns about
> all these places which are currently casting away the const.  For
> the IUL_ITEM() helper, we want to also make it const-preserving,
> and in every other case, we want to just add a const qualifier.

....

> diff --git a/fs/xfs/xfs_iunlink_item.c b/fs/xfs/xfs_iunlink_item.c
> index 43005ce8bd48..ff82a93f8a24 100644
> --- a/fs/xfs/xfs_iunlink_item.c
> +++ b/fs/xfs/xfs_iunlink_item.c
> @@ -20,10 +20,7 @@
>  
>  struct kmem_cache	*xfs_iunlink_cache;
>  
> -static inline struct xfs_iunlink_item *IUL_ITEM(struct xfs_log_item *lip)
> -{
> -	return container_of(lip, struct xfs_iunlink_item, item);
> -}
> +#define IUL_ITEM(lip) container_of(lip, struct xfs_iunlink_item, item)

I think this is somewhat of a step backwards. We moved these log
item type conversions from macros to static inlines to add type
checking so the compiler would catch the type conversion bugs we
found that the macros didn't warn about....

Which makes me ask: why do we even care about const here? What
actual real world problem are you trying to fix with these changes?

Cheers,

Dave.
-- 
Dave Chinner
david@xxxxxxxxxxxxx



[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux