public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Igor Pylypiv <ipylypiv@google.com>
To: Bart Van Assche <bvanassche@acm.org>
Cc: "James E.J. Bottomley" <James.Bottomley@hansenpartnership.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	linux-scsi@vger.kernel.org, linux-ide@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [RESEND PATCH v2] scsi: core: Add 'serial' sysfs attribute for SCSI/SATA
Date: Mon, 9 Feb 2026 11:31:48 -0800	[thread overview]
Message-ID: <aYo2JBW76jH44lAU@google.com> (raw)
In-Reply-To: <430f606d-9305-41d9-9a49-b9ab6894cd61@acm.org>

On Mon, Feb 09, 2026 at 09:31:39AM -0800, Bart Van Assche wrote:
> On 2/5/26 10:00 AM, Igor Pylypiv wrote:
> > +	return sysfs_emit(buf, "%s\n", buf);
> 
> Since many snprintf() variants do not allow to specify the output buffer as
> input argument, the above seems risky to me. Has it been considered to
> replace the above statement with the following?
> 
> 	return sysfs_emit_at(buf, strlen(buf), "\n");

Thank you for pointing this out, Bart! I've now realized that you
pointed out this in V1 as well but I misunderstood your comment.

sysfs_emit_at() returns number of characters written starting at &buf[at]
so it would return 1 for the added newline. We can add the number of
characters written by scsi_vpd_lun_serial() to return the correct number
of characters:

	return ret + sysfs_emit_at(buf, ret, "\n");

This looks a bit too complicated/ugly to me. Instead, I will put a newline
manually and return the correct number of characters. PAGE_SIZE is passed
to scsi_vpd_lun_serial() so we don't sysfs_emit_at() to check it again.

	buf[ret] = '\n';
	return ret + 1;

Let me know if this sounds good to you.

Thank you!
Igor

> 
> Thanks,
> 
> Bart.
> 

  reply	other threads:[~2026-02-09 19:31 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-05 18:00 [RESEND PATCH v2] scsi: core: Add 'serial' sysfs attribute for SCSI/SATA Igor Pylypiv
2026-02-09 17:31 ` Bart Van Assche
2026-02-09 19:31   ` Igor Pylypiv [this message]
2026-02-09 20:27     ` Bart Van Assche

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=aYo2JBW76jH44lAU@google.com \
    --to=ipylypiv@google.com \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=bvanassche@acm.org \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    /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