mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: Igor Pylypiv <ipylypiv@google.com>, Hannes Reinecke <hare@suse.de>
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: [PATCH v3] scsi: core: Add 'serial' sysfs attribute for SCSI/SATA
Date: Tue, 17 Feb 2026 11:25:53 -0800	[thread overview]
Message-ID: <532ecccc-a225-44d2-bab9-52f0f758fb8b@acm.org> (raw)
In-Reply-To: <aYtiDLvRotCE0hEt@google.com>

On 2/10/26 8:51 AM, Igor Pylypiv wrote:
> On Tue, Feb 10, 2026 at 12:38:51PM +0100, Hannes Reinecke wrote:
>> On 2/9/26 22:21, Igor Pylypiv wrote:
>>> +	if (sn_size < len + 1)
>>> +		return -EINVAL;
>>> +
>>> +	memcpy(sn, d, len);
>>
>> 'len' might well be '0' after 'strim()', please check
>> before calling 'memcpy'.
> 
> It looks like calling a memcpy() with zero length is a no-op. Is checking
> for len > 0 really necessary in this case?

It seems to me that the Linux kernel memcpy() implementation handles len 
== 0 fine. From lib/string.c:

void *memcpy(void *dest, const void *src, size_t count)
{
	char *tmp = dest;
	const char *s = src;

	while (count--)
		*tmp++ = *s++;
	return dest;
}
EXPORT_SYMBOL(memcpy);

Bart.

  parent reply	other threads:[~2026-02-17 19:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-09 21:21 Igor Pylypiv
2026-02-09 21:36 ` Bart Van Assche
2026-02-10 11:38 ` Hannes Reinecke
2026-02-10 16:51   ` Igor Pylypiv
2026-02-17 16:58     ` Igor Pylypiv
2026-02-18  8:28       ` Hannes Reinecke
2026-02-17 19:25     ` Bart Van Assche [this message]
2026-03-01  1:06 ` Martin K. Petersen
2026-03-11  2:06 ` Martin K. Petersen

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=532ecccc-a225-44d2-bab9-52f0f758fb8b@acm.org \
    --to=bvanassche@acm.org \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=hare@suse.de \
    --cc=ipylypiv@google.com \
    --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

all inboxes | Powered by JetHome®