Browse Source

[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 years ago
parent
commit
e662912c53
1 changed files with 5 additions and 1 deletions
  1. 5
    1
      src/arch/x86/prefix/efiprefix.c

+ 5
- 1
src/arch/x86/prefix/efiprefix.c View File

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

Loading…
Cancel
Save