From: "Martin K. Petersen" <martin.petersen@oracle.com>
To: Bart Van Assche <bvanassche@acm.org>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>,
linux-scsi@vger.kernel.org, linux-usb@vger.kernel.org,
belegdol@gmail.com, stable@vger.kernel.org
Subject: Re: [PATCH] scsi: core: Consult supported VPD page list prior to fetching page
Date: Wed, 14 Feb 2024 15:20:53 -0500 [thread overview]
Message-ID: <yq1plwyhlc6.fsf@ca-mkp.ca.oracle.com> (raw)
In-Reply-To: <a0f6d397-8162-4e89-a1ff-99540c70fa00@acm.org> (Bart Van Assche's message of "Wed, 14 Feb 2024 10:44:35 -0800")
Hi Bart!
> On 2/14/24 10:25, Martin K. Petersen wrote:
>> + for (unsigned int i = SCSI_VPD_HEADER_SIZE ; i < result ; i++) {
>> + if (vpd[i] == page)
>> + goto found;
>> + }
>
> Can this loop be changed into a memchr() call?
Would you prefer the following?
/* Look for page number in the returned list of supported VPDs */
result -= SCSI_VPD_HEADER_SIZE;
if (!memchr(&vpd[SCSI_VPD_HEADER_SIZE], page, result))
return 0;
I find that the idiomatic for loop is easy to understand whereas the
memchr() requires a bit of squinting. But I don't really have a strong
preference. I do like that the memchr() gets rid of the goto.
>> diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
>> index cb019c80763b..6673885565e3 100644
>> --- a/include/scsi/scsi_device.h
>> +++ b/include/scsi/scsi_device.h
>> @@ -102,6 +102,7 @@ struct scsi_vpd {
>> enum scsi_vpd_parameters {
>> SCSI_VPD_HEADER_SIZE = 4,
>> + SCSI_VPD_LIST_SIZE = 36,
>> };
>> struct scsi_device {
>
> Since these constants are only used inside drivers/scsi/scsi.c, how about
> moving these constants into the drivers/scsi/scsi.c file?
Sure!
--
Martin K. Petersen Oracle Linux Engineering
next prev parent reply other threads:[~2024-02-14 20:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-14 18:25 [PATCH] scsi: core: Consult supported VPD page list prior to fetching page Martin K. Petersen
2024-02-14 18:44 ` Bart Van Assche
2024-02-14 20:20 ` Martin K. Petersen [this message]
2024-02-14 21:41 ` 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=yq1plwyhlc6.fsf@ca-mkp.ca.oracle.com \
--to=martin.petersen@oracle.com \
--cc=belegdol@gmail.com \
--cc=bvanassche@acm.org \
--cc=linux-scsi@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=stable@vger.kernel.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