소스 검색

[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 11 년 전
부모
커밋
e662912c53
1개의 변경된 파일5개의 추가작업 그리고 1개의 파일을 삭제
  1. 5
    1
      src/arch/x86/prefix/efiprefix.c

+ 5
- 1
src/arch/x86/prefix/efiprefix.c 파일 보기

@@ -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
 }

Loading…
취소
저장