Преглед на файлове

[efi] Avoid unnecessarily passing pointers to EFI_HANDLEs

efi_file_install() and efi_download_install() are both used to install
onto existing handles.  There is therefore no need to allow for each
of their calls to InstallMultipleProtocolInterfaces() to create a new
handle.

By passing the handle directly (rather than a pointer to the handle),
we avoid potential confusion (and erroneous debug message colours).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown преди 9 години
родител
ревизия
4a480f1d15
променени са 5 файла, в които са добавени 14 реда и са изтрити 14 реда
  1. 2
    2
      src/image/efi_image.c
  2. 2
    2
      src/include/ipxe/efi/efi_download.h
  3. 1
    1
      src/include/ipxe/efi/efi_file.h
  4. 2
    2
      src/interface/efi/efi_download.c
  5. 7
    7
      src/interface/efi/efi_file.c

+ 2
- 2
src/image/efi_image.c Целия файл

157
 	}
157
 	}
158
 
158
 
159
 	/* Install file I/O protocols */
159
 	/* Install file I/O protocols */
160
-	if ( ( rc = efi_file_install ( &snpdev->handle ) ) != 0 ) {
160
+	if ( ( rc = efi_file_install ( snpdev->handle ) ) != 0 ) {
161
 		DBGC ( image, "EFIIMAGE %p could not install file protocol: "
161
 		DBGC ( image, "EFIIMAGE %p could not install file protocol: "
162
 		       "%s\n", image, strerror ( rc ) );
162
 		       "%s\n", image, strerror ( rc ) );
163
 		goto err_file_install;
163
 		goto err_file_install;
164
 	}
164
 	}
165
 
165
 
166
 	/* Install iPXE download protocol */
166
 	/* Install iPXE download protocol */
167
-	if ( ( rc = efi_download_install ( &snpdev->handle ) ) != 0 ) {
167
+	if ( ( rc = efi_download_install ( snpdev->handle ) ) != 0 ) {
168
 		DBGC ( image, "EFIIMAGE %p could not install iPXE download "
168
 		DBGC ( image, "EFIIMAGE %p could not install iPXE download "
169
 		       "protocol: %s\n", image, strerror ( rc ) );
169
 		       "protocol: %s\n", image, strerror ( rc ) );
170
 		goto err_download_install;
170
 		goto err_download_install;

+ 2
- 2
src/include/ipxe/efi/efi_download.h Целия файл

151
     0x3eaeaebd, 0xdecf, 0x493b, { 0x9b, 0xd1, 0xcd, 0xb2, 0xde, 0xca, 0xe7, 0x19 } \
151
     0x3eaeaebd, 0xdecf, 0x493b, { 0x9b, 0xd1, 0xcd, 0xb2, 0xde, 0xca, 0xe7, 0x19 } \
152
   }
152
   }
153
 
153
 
154
-extern int efi_download_install ( EFI_HANDLE *device );
155
-extern void efi_download_uninstall ( EFI_HANDLE device );
154
+extern int efi_download_install ( EFI_HANDLE handle );
155
+extern void efi_download_uninstall ( EFI_HANDLE handle );
156
 
156
 
157
 #endif /* _IPXE_DOWNLOAD_H */
157
 #endif /* _IPXE_DOWNLOAD_H */

+ 1
- 1
src/include/ipxe/efi/efi_file.h Целия файл

7
  *
7
  *
8
  */
8
  */
9
 
9
 
10
-extern int efi_file_install ( EFI_HANDLE *handle );
10
+extern int efi_file_install ( EFI_HANDLE handle );
11
 extern void efi_file_uninstall ( EFI_HANDLE handle );
11
 extern void efi_file_uninstall ( EFI_HANDLE handle );
12
 
12
 
13
 #endif /* _IPXE_EFI_FILE_H */
13
 #endif /* _IPXE_EFI_FILE_H */

+ 2
- 2
src/interface/efi/efi_download.c Целия файл

205
  * @v handle		EFI handle
205
  * @v handle		EFI handle
206
  * @ret rc		Return status code
206
  * @ret rc		Return status code
207
  */
207
  */
208
-int efi_download_install ( EFI_HANDLE *handle ) {
208
+int efi_download_install ( EFI_HANDLE handle ) {
209
 	EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
209
 	EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
210
 	EFI_STATUS efirc;
210
 	EFI_STATUS efirc;
211
 	int rc;
211
 	int rc;
212
 
212
 
213
 	efirc = bs->InstallMultipleProtocolInterfaces (
213
 	efirc = bs->InstallMultipleProtocolInterfaces (
214
-			handle,
214
+			&handle,
215
 			&ipxe_download_protocol_guid,
215
 			&ipxe_download_protocol_guid,
216
 			&ipxe_download_protocol_interface,
216
 			&ipxe_download_protocol_interface,
217
 			NULL );
217
 			NULL );

+ 7
- 7
src/interface/efi/efi_file.c Целия файл

575
  * @v handle		EFI handle
575
  * @v handle		EFI handle
576
  * @ret rc		Return status code
576
  * @ret rc		Return status code
577
  */
577
  */
578
-int efi_file_install ( EFI_HANDLE *handle ) {
578
+int efi_file_install ( EFI_HANDLE handle ) {
579
 	EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
579
 	EFI_BOOT_SERVICES *bs = efi_systab->BootServices;
580
 	union {
580
 	union {
581
 		EFI_DISK_IO_PROTOCOL *diskio;
581
 		EFI_DISK_IO_PROTOCOL *diskio;
592
 	 * handle just to keep things looking normal.
592
 	 * handle just to keep things looking normal.
593
 	 */
593
 	 */
594
 	if ( ( efirc = bs->InstallMultipleProtocolInterfaces (
594
 	if ( ( efirc = bs->InstallMultipleProtocolInterfaces (
595
-			handle,
595
+			&handle,
596
 			&efi_block_io_protocol_guid,
596
 			&efi_block_io_protocol_guid,
597
 			&efi_block_io_protocol,
597
 			&efi_block_io_protocol,
598
 			&efi_disk_io_protocol_guid,
598
 			&efi_disk_io_protocol_guid,
624
 	 * of calls to our DRIVER_STOP method when starting the EFI
624
 	 * of calls to our DRIVER_STOP method when starting the EFI
625
 	 * shell.  I have no idea why this is.
625
 	 * shell.  I have no idea why this is.
626
 	 */
626
 	 */
627
-	if ( ( efirc = bs->OpenProtocol ( *handle, &efi_disk_io_protocol_guid,
627
+	if ( ( efirc = bs->OpenProtocol ( handle, &efi_disk_io_protocol_guid,
628
 					  &diskio.interface, efi_image_handle,
628
 					  &diskio.interface, efi_image_handle,
629
-					  *handle,
629
+					  handle,
630
 					  EFI_OPEN_PROTOCOL_BY_DRIVER ) ) != 0){
630
 					  EFI_OPEN_PROTOCOL_BY_DRIVER ) ) != 0){
631
 		rc = -EEFI ( efirc );
631
 		rc = -EEFI ( efirc );
632
 		DBGC ( handle, "Could not open disk I/O protocol: %s\n",
632
 		DBGC ( handle, "Could not open disk I/O protocol: %s\n",
637
 
637
 
638
 	return 0;
638
 	return 0;
639
 
639
 
640
-	bs->CloseProtocol ( *handle, &efi_disk_io_protocol_guid,
641
-			    efi_image_handle, *handle );
640
+	bs->CloseProtocol ( handle, &efi_disk_io_protocol_guid,
641
+			    efi_image_handle, handle );
642
  err_open:
642
  err_open:
643
 	bs->UninstallMultipleProtocolInterfaces (
643
 	bs->UninstallMultipleProtocolInterfaces (
644
-			*handle,
644
+			handle,
645
 			&efi_simple_file_system_protocol_guid,
645
 			&efi_simple_file_system_protocol_guid,
646
 			&efi_simple_file_system_protocol,
646
 			&efi_simple_file_system_protocol,
647
 			&efi_disk_io_protocol_guid,
647
 			&efi_disk_io_protocol_guid,

Loading…
Отказ
Запис