Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 23 Jul 2018 20:36:41 +0000 (UTC)
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r336652 - head/stand/efi/libefi
Message-ID:  <201807232036.w6NKafpE012129@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201807232036.w6NKafpE012129>