PERFORCE change 150621 for review

Hans Petter Selasky hselasky at FreeBSD.org
Sun Sep 28 19:52:05 UTC 2008


http://perforce.freebsd.org/chv.cgi?CH=150621

Change 150621 by hselasky at hselasky_laptop001 on 2008/09/28 19:51:37

	
	Revert some changes to "subr_bus.c" .

Affected files ...

.. //depot/projects/usb/src/sys/kern/subr_bus.c#13 integrate

Differences ...

==== //depot/projects/usb/src/sys/kern/subr_bus.c#13 (text+ko) ====

@@ -1879,8 +1879,7 @@
 int
 device_get_children(device_t dev, device_t **devlistp, int *devcountp)
 {
-	uint32_t count;
-	uint32_t n;
+	int count;
 	device_t child;
 	device_t *list;
 
@@ -1889,34 +1888,14 @@
 		count++;
 	}
 
-	if (count == 0) {
-		/* avoid zero size allocation */
-		n = 1 * sizeof(device_t);
-	} else {
-		n = count * sizeof(device_t);
-	}
-
-	list = malloc(n, M_TEMP, M_NOWAIT|M_ZERO);
-	if (!list) {
-		*devlistp = NULL;
-		*devcountp = 0;
+	list = malloc(count * sizeof(device_t), M_TEMP, M_NOWAIT|M_ZERO);
+	if (!list)
 		return (ENOMEM);
-	}
 
-	n = 0;
+	count = 0;
 	TAILQ_FOREACH(child, &dev->children, link) {
-		if (n < count) {
-			list[n] = child;
-		}
-		n++;
-	}
-
-	if (n != count) {
-		printf("device_get_children: Number of devices changed "
-		       "from %d to %d!\n", count, n);
-		if (n < count) {
-			count = n;
-		}
+		list[count] = child;
+		count++;
 	}
 
 	*devlistp = list;


More information about the p4-projects mailing list