lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date:	Fri, 14 Aug 2015 13:50:13 -0700
From:	"K. Y. Srinivasan" <kys@...rosoft.com>
To:	gregkh@...uxfoundation.org, linux-kernel@...r.kernel.org,
	devel@...uxdriverproject.org, ohering@...e.com,
	jbottomley@...allels.com, hch@...radead.org,
	linux-scsi@...r.kernel.org, apw@...onical.com, vkuznets@...hat.com,
	jasowang@...hat.com, jthumshirn@...e.de
Cc:	"K. Y. Srinivasan" <kys@...rosoft.com>
Subject: [PATCH 1/1] scsi: storvsc: Use ARRAY_SIZE() to compute the elements in the protocol array

Rather than hard coding the number of elements in the array, use the ARRAY_SIZE()
macro to compute the number of elements in the array. This would minimize the
changes needed when we have to extend the protocols supported.

This was suggested by Johannes Thumshirn <jthumshirn@...e.de>.

Signed-off-by: K. Y. Srinivasan <kys@...rosoft.com>
---
 drivers/scsi/storvsc_drv.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c
index 64fa305..4dffc3b 100644
--- a/drivers/scsi/storvsc_drv.c
+++ b/drivers/scsi/storvsc_drv.c
@@ -226,9 +226,8 @@ struct vmstor_protocol {
 	int vmscsi_size_delta;
 };
 
-#define VMSTOR_NUM_PROTOCOLS    5
 
-const struct vmstor_protocol vmstor_protocols[VMSTOR_NUM_PROTOCOLS] = {
+const struct vmstor_protocol vmstor_protocols[] = {
 	{
 		VMSTOR_PROTO_VERSION_WIN10,
 		POST_WIN7_STORVSC_SENSE_BUFFER_SIZE,
@@ -959,7 +958,7 @@ static int storvsc_channel_init(struct hv_device *device)
 	}
 
 
-	for (i = 0; i < VMSTOR_NUM_PROTOCOLS; i++) {
+	for (i = 0; i < ARRAY_SIZE(vmstor_protocols); i++) {
 		/* reuse the packet for version range supported */
 		memset(vstor_packet, 0, sizeof(struct vstor_packet));
 		vstor_packet->operation =
-- 
1.7.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ