Re: [PATCH] scsi: core: Consult supported VPD page list prior to fetching page

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2/14/24 12:20, Martin K. Petersen wrote:
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.

Although I slightly prefer the memchr() variant, I'm also fine with keeping the
for-loop.

Thanks,

Bart.





[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux