Pārlūkot izejas kodu

[efi] Avoid accidentally calling main() twice

EFIRC() uses PLATFORM_TO_ERRNO(), which evaluates its argument twice
(and can't trivially use a braced-group expression or an inline
function to avoid this, since it gets used outside of function
context).

The expression "EFIRC(main())" will therefore end up calling main()
twice, which is not the intended behaviour.  Every other instance of
EFIRC() is of the simple form "EFIRC(rc)", so fix by converting this
instance to match.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 10 gadus atpakaļ
vecāks
revīzija
e662912c53
1 mainītis faili ar 5 papildinājumiem un 1 dzēšanām
  1. 5
    1
      src/arch/x86/prefix/efiprefix.c

+ 5
- 1
src/arch/x86/prefix/efiprefix.c Parādīt failu

@@ -33,11 +33,15 @@ FILE_LICENCE ( GPL2_OR_LATER );
33 33
 EFI_STATUS EFIAPI _efi_start ( EFI_HANDLE image_handle,
34 34
 			       EFI_SYSTEM_TABLE *systab ) {
35 35
 	EFI_STATUS efirc;
36
+	int rc;
36 37
 
37 38
 	/* Initialise EFI environment */
38 39
 	if ( ( efirc = efi_init ( image_handle, systab ) ) != 0 )
39 40
 		return efirc;
40 41
 
41 42
 	/* Call to main() */
42
-	return EFIRC ( main () );
43
+	if ( ( rc = main() ) != 0 )
44
+		return EFIRC ( rc );
45
+
46
+	return 0;
43 47
 }

Notiek ielāde…
Atcelt
Saglabāt