Re: [PATCH v2][next] xfs: Replace one-element arrays with flexible-array members

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

 




On 3/10/21 21:17, Darrick J. Wong wrote:

> Why not use size_t instead of uint?  You converted the @len declaration
> above.
> 
>> +				 src_efi_fmt->efi_nextents);
>> +	uint len64 = struct_size((xfs_efi_log_format_64_t *)0, efi_extents,
> 
> Also, please don't use the struct typedefs, we're trying to get rid of
> those slowly.
> 
> TBH I wonder if these could just be turned into static inline helpers to
> decrapify the code:
> 
> static inline size_t
> sizeof_efi_log_format32(unsigned int nr)
> {
> 	return struct_size((xfs_efi_log_format_32_t *)0, efi_extents, nr);
> }
> 
> Then you only need:
> 
> 	size_t len = sizeof_efi_log_format(src_efi_fmt->efi_nextents);
> 	size_t len32 = sizeof_efi_log_format32(src_efi_fmt->efi_nextents);
> 	size_t len64 = sizeof_efi_log_format64(src_efi_fmt->efi_nextents);
> 
> 	if (len == len32) ...
> 	else if (len == len64) ...
> 
> And down below you can clean up the asserts a bit:
> 
> 	ASSERT(item->ri_buf[0].i_len ==
> 			sizeof_efi_log_format32(efd_formatp->efd_nextents) ||
> 	       item->ri_buf[0].i_len ==
> 			sizeof_efi_log_format64(efd_formatp->efd_nextents));
> 

Done: https://lore.kernel.org/lkml/20210311042302.GA137676@embeddedor/

Thanks for the feedback!
--
Gustavo



[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