lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <63a68526-3f21-4ef8-a782-74dc4f428272@linux.alibaba.com>
Date: Wed, 13 Nov 2024 23:32:37 +0800
From: Gao Xiang <hsiangkao@...ux.alibaba.com>
To: Gou Hao <gouhao@...ontech.com>, xiang@...nel.org, chao@...nel.org
Cc: linux-erofs@...ts.ozlabs.org, linux-kernel@...r.kernel.org,
 gouhaojake@....com
Subject: Re: [PATCH V2] erofs: simplify definition of the log functions



On 2024/11/13 22:41, Gou Hao wrote:
> Use printk instead of pr_info/err to reduce
> redundant code.
> 
> Signed-off-by: Gou Hao <gouhao@...ontech.com>
> ---
>   fs/erofs/internal.h | 14 ++++----------
>   fs/erofs/super.c    | 28 +++++++---------------------
>   2 files changed, 11 insertions(+), 31 deletions(-)
> 
> Changes:
> V2:
> - remove 'const char  *function' from _erofs_printk
> - remove pr_fmt macro, put 'erofs' prefix into printk
> 
> diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
> index 4efd578d7c62..116c82588661 100644
> --- a/fs/erofs/internal.h
> +++ b/fs/erofs/internal.h
> @@ -20,18 +20,12 @@
>   #include <linux/iomap.h>
>   #include "erofs_fs.h"
>   
> -/* redefine pr_fmt "erofs: " */
> -#undef pr_fmt
> -#define pr_fmt(fmt) "erofs: " fmt
> -
> -__printf(3, 4) void _erofs_err(struct super_block *sb,
> -			       const char *function, const char *fmt, ...);
> +__printf(2, 3) void _erofs_printk(struct super_block *sb, const char *fmt, ...);
>   #define erofs_err(sb, fmt, ...)	\
> -	_erofs_err(sb, __func__, fmt "\n", ##__VA_ARGS__)
> -__printf(3, 4) void _erofs_info(struct super_block *sb,
> -			       const char *function, const char *fmt, ...);
> +	_erofs_printk(sb, KERN_ERR fmt "\n", ##__VA_ARGS__)
>   #define erofs_info(sb, fmt, ...) \
> -	_erofs_info(sb, __func__, fmt "\n", ##__VA_ARGS__)
> +	_erofs_printk(sb, KERN_INFO fmt "\n", ##__VA_ARGS__)
> +
>   #ifdef CONFIG_EROFS_FS_DEBUG
>   #define DBG_BUGON               BUG_ON
>   #else
> diff --git a/fs/erofs/super.c b/fs/erofs/super.c
> index 666873f745da..93b44b77a41c 100644
> --- a/fs/erofs/super.c
> +++ b/fs/erofs/super.c
> @@ -18,37 +18,23 @@
>   
>   static struct kmem_cache *erofs_inode_cachep __read_mostly;
>   
> -void _erofs_err(struct super_block *sb, const char *func, const char *fmt, ...)
> +void _erofs_printk(struct super_block *sb, const char *fmt, ...)
>   {
>   	struct va_format vaf;
>   	va_list args;
> +	int level;
>   
>   	va_start(args, fmt);
>   
> -	vaf.fmt = fmt;
> +	level = printk_get_level(fmt);
> +	vaf.fmt = printk_skip_level(fmt);
>   	vaf.va = &args;
>   
>   	if (sb)
> -		pr_err("(device %s): %s: %pV", sb->s_id, func, &vaf);
> +		printk("%c%cerofs: (device %s): %pV",

		printk("%c%cerofs (device %s): %pV",

is preferred.

Otherwise it looks good to me.

Thanks,
Gao Xiang

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ