Re: [PATCH 10/37] xfs: pretty print metadata file types in error messages

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

 



On Thu, Dec 12, 2024 at 05:03:11PM -0800, Darrick J. Wong wrote:
> +static inline const char *
> +xfs_metafile_type_str(enum xfs_metafile_type metatype)
> +{
> +	static const struct {
> +		enum xfs_metafile_type	mtype;
> +		const char		*name;
> +	} strings[] = { XFS_METAFILE_TYPE_STR };
> +	unsigned int	i;
> +
> +	for (i = 0; i < ARRAY_SIZE(strings); i++) {
> +		if (strings[i].mtype == metatype)
> +			return strings[i].name;
> +	}
> +
> +	return NULL;
> +}

Having this as an inline helpers means not just the code, but also
the string array is duplicated in every caller.  While there are only
two with your entire series that's still a lіttle suboptimal.  Maybe
move it out of line to xfs_metafile.c?

And make the array file scope to be a little more readable.




[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