[PATCH 1/2] erofs: using macro instead of definition of log functions

Gou Hao gouhaojake at 163.com
Thu Oct 17 21:12:24 AEDT 2024


At 2024-10-17 11:39:53, "Gao Xiang" <hsiangkao at linux.alibaba.com> wrote:

>Hi Hao,
>
>On 2024/10/16 23:24, Gou Hao wrote:
>> No functional change intended.
>> 
>> Signed-off-by: Gou Hao <gouhao at uniontech.com>
>> ---
>>   fs/erofs/super.c | 51 ++++++++++++++++++------------------------------
>>   1 file changed, 19 insertions(+), 32 deletions(-)
>> 
>> diff --git a/fs/erofs/super.c b/fs/erofs/super.c
>> index 666873f745da..b04f888c8123 100644
>> --- a/fs/erofs/super.c
>> +++ b/fs/erofs/super.c
>> @@ -18,39 +18,26 @@
>>   
>>   static struct kmem_cache *erofs_inode_cachep __read_mostly;
>>   
>> -void _erofs_err(struct super_block *sb, const char *func, const char *fmt, ...)
>> -{
>> -	struct va_format vaf;
>> -	va_list args;
>> -
>> -	va_start(args, fmt);
>> -
>> -	vaf.fmt = fmt;
>> -	vaf.va = &args;
>> -
>> -	if (sb)
>> -		pr_err("(device %s): %s: %pV", sb->s_id, func, &vaf);
>> -	else
>> -		pr_err("%s: %pV", func, &vaf);
>> -	va_end(args);
>> -}
>> -
>> -void _erofs_info(struct super_block *sb, const char *func, const char *fmt, ...)
>> -{
>> -	struct va_format vaf;
>> -	va_list args;
>> -
>> -	va_start(args, fmt);
>> -
>> -	vaf.fmt = fmt;
>> -	vaf.va = &args;
>> +#define _erofs_log_def(name) \
>> +	void _erofs_##name(struct super_block *sb, const char *func, const char *fmt, ...) \
>> +	{ \
>> +		struct va_format vaf; \
>> +		va_list args; \
>> +		\
>> +		va_start(args, (fmt)); \
>> +		\
>> +		vaf.fmt = (fmt); \
>> +		vaf.va = &args; \
>> +		\
>> +		if ((sb)) \
>> +			pr_##name("(device %s): %s: %pV", (sb)->s_id, (func), &vaf); \
>> +		else \
>> +			pr_##name("%s: %pV", (func), &vaf); \
>> +		va_end(args); \
>> +	}
>
>Thanks for the patch!
>
>Although code simplicity is quite important for EROFS, but
>I'm not sure introducing unnecessary macro definitions (which
>can be avoided) is better for code readability.
>
>I wonder if we can put this into another way, like the current
>_btrfs_printk() and _f2fs_printk() if we really need to work
>on this.
>
>Thanks,

>Gao Xiang


Thanks for your review and advise. I take a look at these two functions.



--

thanks,
Gou Hao
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ozlabs.org/pipermail/linux-erofs/attachments/20241017/f4139792/attachment.htm>


More information about the Linux-erofs mailing list