svn commit: r336652 - head/stand/efi/libefi

Warner Losh imp at FreeBSD.org
Mon Jul 23 20:36:42 UTC 2018


Author: imp
Date: Mon Jul 23 20:36:41 2018
New Revision: 336652
URL: https://svnweb.freebsd.org/changeset/base/336652

Log:
  Store the number of handles we get back in efipart_nhandles rather
  than the number of bytes. Don't divide by the element size every time
  we have to iterate. Eliminate now-unused variables.
  
  Sponsored by: Netflix

Modified:
  head/stand/efi/libefi/efipart.c

Modified: head/stand/efi/libefi/efipart.c
==============================================================================
--- head/stand/efi/libefi/efipart.c	Mon Jul 23 20:36:25 2018	(r336651)
+++ head/stand/efi/libefi/efipart.c	Mon Jul 23 20:36:41 2018	(r336652)
@@ -210,7 +210,7 @@ efipart_inithandles(void)
 		return (efi_status_to_errno(status));
 
 	efipart_handles = hin;
-	efipart_nhandles = sz;
+	efipart_nhandles = sz / sizeof(*hin);
 #ifdef EFIPART_DEBUG
 	printf("%s: Got %d BLOCK IO MEDIA handle(s)\n", __func__,
 	    efipart_nhandles);
@@ -246,7 +246,7 @@ efipart_floppy(EFI_DEVICE_PATH *node)
 static bool
 efipart_hdd(EFI_DEVICE_PATH *dp)
 {
-	unsigned i, nin;
+	unsigned i;
 	EFI_DEVICE_PATH *devpath, *node;
 	EFI_BLOCK_IO *blkio;
 	EFI_STATUS status;
@@ -264,8 +264,7 @@ efipart_hdd(EFI_DEVICE_PATH *dp)
 	 * Test every EFI BLOCK IO handle to make sure dp is not device path
 	 * for CD/DVD.
 	 */
-	nin = efipart_nhandles / sizeof (*efipart_handles);
-	for (i = 0; i < nin; i++) {
+	for (i = 0; i < efipart_nhandles; i++) {
 		devpath = efi_lookup_devpath(efipart_handles[i]);
 		if (devpath == NULL)
 			return (false);
@@ -340,10 +339,9 @@ efipart_updatefd(void)
 {
 	EFI_DEVICE_PATH *devpath, *node;
 	ACPI_HID_DEVICE_PATH *acpi;
-	int i, nin;
+	int i;
 
-	nin = efipart_nhandles / sizeof (*efipart_handles);
-	for (i = 0; i < nin; i++) {
+	for (i = 0; i < efipart_nhandles; i++) {
 		devpath = efi_lookup_devpath(efipart_handles[i]);
 		if (devpath == NULL)
 			continue;
@@ -410,14 +408,13 @@ efipart_cdinfo_add(EFI_HANDLE handle, EFI_HANDLE alias
 static void
 efipart_updatecd(void)
 {
-	int i, nin;
+	int i;
 	EFI_DEVICE_PATH *devpath, *devpathcpy, *tmpdevpath, *node;
 	EFI_HANDLE handle;
 	EFI_BLOCK_IO *blkio;
 	EFI_STATUS status;
 
-	nin = efipart_nhandles / sizeof (*efipart_handles);
-	for (i = 0; i < nin; i++) {
+	for (i = 0; i < efipart_nhandles; i++) {
 		devpath = efi_lookup_devpath(efipart_handles[i]);
 		if (devpath == NULL)
 			continue;
@@ -666,14 +663,13 @@ efipart_hdinfo_add_filepath(EFI_HANDLE disk_handle)
 static void
 efipart_updatehd(void)
 {
-	int i, nin;
+	int i;
 	EFI_DEVICE_PATH *devpath, *devpathcpy, *tmpdevpath, *node;
 	EFI_HANDLE handle;
 	EFI_BLOCK_IO *blkio;
 	EFI_STATUS status;
 
-	nin = efipart_nhandles / sizeof (*efipart_handles);
-	for (i = 0; i < nin; i++) {
+	for (i = 0; i < efipart_nhandles; i++) {
 		devpath = efi_lookup_devpath(efipart_handles[i]);
 		if (devpath == NULL)
 			continue;


More information about the svn-src-all mailing list