linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Pranav Tyagi <pranav.tyagi03@gmail.com>
Cc: cem@kernel.org, skhan@linuxfoundation.org,
	linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-kernel-mentees@lists.linux.dev
Subject: Re: [PATCH] fs/xfs: use scnprintf() in show functions
Date: Mon, 16 Jun 2025 16:20:16 +0200	[thread overview]
Message-ID: <2025061610-basics-attendee-cd02@gregkh> (raw)
In-Reply-To: <20250616110313.372314-1-pranav.tyagi03@gmail.com>

On Mon, Jun 16, 2025 at 04:33:13PM +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.

No, please use sysfs_emit() if you really want to change this.

> 
> Signed-off-by: Pranav Tyagi <pranav.tyagi03@gmail.com>
> ---
>  fs/xfs/xfs_sysfs.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/xfs/xfs_sysfs.c b/fs/xfs/xfs_sysfs.c
> index 7a5c5ef2db92..f7206e3edea2 100644
> --- a/fs/xfs/xfs_sysfs.c
> +++ b/fs/xfs/xfs_sysfs.c
> @@ -257,7 +257,7 @@ larp_show(
>  	struct kobject	*kobject,
>  	char		*buf)
>  {
> -	return snprintf(buf, PAGE_SIZE, "%d\n", xfs_globals.larp);

There is nothing wrong with the original code here, you could use
sprintf() and it too is ok.  So this type of change is not needed.  But
again, if you really want to, use sysfs_emit() instead.

Same for all the other show() callback changes you just made.

thanks,

greg k-h

  reply	other threads:[~2025-06-16 14:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-16 11:03 [PATCH] fs/xfs: use scnprintf() in show functions Pranav Tyagi
2025-06-16 14:20 ` Greg KH [this message]
2025-06-17 13:23   ` Pranav Tyagi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2025061610-basics-attendee-cd02@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=cem@kernel.org \
    --cc=linux-kernel-mentees@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=pranav.tyagi03@gmail.com \
    --cc=skhan@linuxfoundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).