Re: [PATCH] fs/dlm: use scnprintf() in lockspace show funcs
From: Greg KH
Date: Mon Jun 16 2025 - 10:29:38 EST
On Mon, Jun 16, 2025 at 04:04:41PM +0530, Pranav Tyagi wrote:
> Replace all snprintf() instances with scnprintf(). snprintf() returns
> the number of bytes that would have been written had there been enough
> space. For sysfs attributes, snprintf() should not be used for the
> show() method. Instead use scnprintf() which returns the number of
> bytes actually written.
>
> Signed-off-by: Pranav Tyagi <pranav.tyagi03@xxxxxxxxx>
> ---
> fs/dlm/config.c | 2 +-
> fs/dlm/lockspace.c | 8 ++++----
> 2 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/fs/dlm/config.c b/fs/dlm/config.c
> index a23fd524a6ee..10486a46a540 100644
> --- a/fs/dlm/config.c
> +++ b/fs/dlm/config.c
> @@ -185,7 +185,7 @@ static ssize_t cluster_##name##_store(struct config_item *item, \
> } \
> static ssize_t cluster_##name##_show(struct config_item *item, char *buf) \
> { \
> - return snprintf(buf, PAGE_SIZE, "%u\n", dlm_config.ci_##name); \
> + return scnprintf(buf, PAGE_SIZE, "%u\n", dlm_config.ci_##name); \
sysfs_emit() or no change at all please.