[PATCH v2] erofs: make erofs_err() and erofs_info() support NULL sb parameter

Jingbo Xu jefflexu at linux.alibaba.com
Wed Jan 3 02:10:09 AEDT 2024


Hi Chunhai,

Thanks for the commit.

On 1/2/24 11:01 PM, Chunhai Guo wrote:
> Make erofs_err() and erofs_info() support NULL sb parameter for more
> general usage.
> 
> Suggested-by: Gao Xiang <xiang at kernel.org>
> Signed-off-by: Chunhai Guo <guochunhai at vivo.com>
> ---
>  fs/erofs/super.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/erofs/super.c b/fs/erofs/super.c
> index 3789d6224513..5f60f163bd56 100644
> --- a/fs/erofs/super.c
> +++ b/fs/erofs/super.c
> @@ -27,7 +27,10 @@ void _erofs_err(struct super_block *sb, const char *func, const char *fmt, ...)
>  	vaf.fmt = fmt;
>  	vaf.va = &args;
>  
> -	pr_err("(device %s): %s: %pV", sb->s_id, func, &vaf);
> +	if (sb)
> +		pr_err("(device %s): %s: %pV", sb->s_id, func, &vaf);
> +	else
> +		pr_err("%s: %pV", func, &vaf);
>  	va_end(args);
>  }
>  
> @@ -41,7 +44,10 @@ void _erofs_info(struct super_block *sb, const char *func, const char *fmt, ...)
>  	vaf.fmt = fmt;
>  	vaf.va = &args;
>  
> -	pr_info("(device %s): %pV", sb->s_id, &vaf);
> +	if (sb)
> +		pr_info("(device %s): %pV", sb->s_id, &vaf);
> +	else
> +		pr_info("%pV", &vaf);
>  	va_end(args);
>  }
>  

May I ask in which case the input sb parameter will be NULL?  In that
case, why don't we call pr_err() or pr_info() directly?

-- 
Thanks,
Jingbo


More information about the Linux-erofs mailing list