changeset 13019:05a4e7665357

6973912 pci_autoconfig: alloc_res_array() feels a little off (by one)
author Praveen Kumar Dasaraju Rama <Praveen.Dasaraju@Oracle.COM>
date Tue, 03 Aug 2010 18:32:30 -0700
parents 22e6d3edaab5
children a2b26a53fd00
files usr/src/uts/intel/io/pci/pci_boot.c
diffstat 1 files changed, 12 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/uts/intel/io/pci/pci_boot.c	Wed Aug 04 07:38:56 2010 +0800
+++ b/usr/src/uts/intel/io/pci/pci_boot.c	Tue Aug 03 18:32:30 2010 -0700
@@ -3244,28 +3244,28 @@
 static void
 alloc_res_array(void)
 {
-	static int array_max = 0;
-	int old_max;
+	static int array_size = 0;
+	int old_size;
 	void *old_res;
 
-	if (array_max > pci_bios_maxbus + 1)
+	if (array_size > pci_bios_maxbus + 1)
 		return;	/* array is big enough */
 
-	old_max = array_max;
+	old_size = array_size;
 	old_res = pci_bus_res;
 
-	if (array_max == 0)
-		array_max = 16;	/* start with a reasonable number */
-
-	while (array_max < pci_bios_maxbus + 1)
-		array_max <<= 1;
+	if (array_size == 0)
+		array_size = 16;	/* start with a reasonable number */
+
+	while (array_size <= pci_bios_maxbus + 1)
+		array_size <<= 1;
 	pci_bus_res = (struct pci_bus_resource *)kmem_zalloc(
-	    array_max * sizeof (struct pci_bus_resource), KM_SLEEP);
+	    array_size * sizeof (struct pci_bus_resource), KM_SLEEP);
 
 	if (old_res) {	/* copy content and free old array */
 		bcopy(old_res, pci_bus_res,
-		    old_max * sizeof (struct pci_bus_resource));
-		kmem_free(old_res, old_max * sizeof (struct pci_bus_resource));
+		    old_size * sizeof (struct pci_bus_resource));
+		kmem_free(old_res, old_size * sizeof (struct pci_bus_resource));
 	}
 }