Add the ANALYZER_NORETURN attribute to CpuDeadLoop() and CpuBreakpoint() to avoid false 'possible NULL-dereference' warnings when dereferencing pointers after having validated them with ASSERT(). As the ANALYZER-prefixed versions are being used, the code following the calls will not be optimized away.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Marvin Haeuser <[email protected]> --- MdePkg/Library/BaseLib/CpuDeadLoop.c | 3 +++ MdePkg/Library/BaseLib/Ebc/CpuBreakpoint.c | 3 +++ MdePkg/Library/BaseLib/Ia32/CpuBreakpoint.c | 3 +++ MdePkg/Library/BaseLib/Ipf/CpuBreakpoint.c | 3 +++ MdePkg/Library/BaseLib/Ipf/CpuBreakpointMsc.c | 3 +++ MdePkg/Library/BaseLib/X64/CpuBreakpoint.c | 3 +++ MdePkg/Library/BaseLib/X64/GccInline.c | 3 +++ MdePkg/Include/Library/BaseLib.h | 2 ++ MdePkg/Library/BaseLib/AArch64/CpuBreakpoint.S | 1 + MdePkg/Library/BaseLib/Arm/CpuBreakpoint.S | 1 + MdePkg/Library/BaseLib/Arm/CpuBreakpoint.asm | 1 + MdePkg/Library/BaseLib/Ia32/CpuBreakpoint.asm | 1 + MdePkg/Library/BaseLib/X64/CpuBreakpoint.asm | 1 + 13 files changed, 28 insertions(+) diff --git a/MdePkg/Library/BaseLib/CpuDeadLoop.c b/MdePkg/Library/BaseLib/CpuDeadLoop.c index 3f9440547d4d..7e386eab61a3 100644 --- a/MdePkg/Library/BaseLib/CpuDeadLoop.c +++ b/MdePkg/Library/BaseLib/CpuDeadLoop.c @@ -28,6 +28,7 @@ **/ VOID EFIAPI +ANALYZER_NORETURN CpuDeadLoop ( VOID ) @@ -35,4 +36,6 @@ CpuDeadLoop ( volatile UINTN Index; for (Index = 0; Index == 0;); + + ANALYZER_UNREACHABLE (); } diff --git a/MdePkg/Library/BaseLib/Ebc/CpuBreakpoint.c b/MdePkg/Library/BaseLib/Ebc/CpuBreakpoint.c index 9b7d875664bd..bd8da8a671d1 100644 --- a/MdePkg/Library/BaseLib/Ebc/CpuBreakpoint.c +++ b/MdePkg/Library/BaseLib/Ebc/CpuBreakpoint.c @@ -29,11 +29,14 @@ _break ( **/ VOID EFIAPI +ANALYZER_NORETURN CpuBreakpoint ( VOID ) { _break (3); + + ANALYZER_UNREACHABLE (); } /** diff --git a/MdePkg/Library/BaseLib/Ia32/CpuBreakpoint.c b/MdePkg/Library/BaseLib/Ia32/CpuBreakpoint.c index f5df7f2883c6..d68fd770ce3d 100644 --- a/MdePkg/Library/BaseLib/Ia32/CpuBreakpoint.c +++ b/MdePkg/Library/BaseLib/Ia32/CpuBreakpoint.c @@ -32,10 +32,13 @@ void __debugbreak (); **/ VOID EFIAPI +ANALYZER_NORETURN CpuBreakpoint ( VOID ) { __debugbreak (); + + ANALYZER_UNREACHABLE (); } diff --git a/MdePkg/Library/BaseLib/Ipf/CpuBreakpoint.c b/MdePkg/Library/BaseLib/Ipf/CpuBreakpoint.c index 302974bd5c98..29456b5f867d 100644 --- a/MdePkg/Library/BaseLib/Ipf/CpuBreakpoint.c +++ b/MdePkg/Library/BaseLib/Ipf/CpuBreakpoint.c @@ -24,11 +24,14 @@ **/ VOID EFIAPI +ANALYZER_NORETURN CpuBreakpoint ( VOID ) { __break (0); + + ANALYZER_UNREACHABLE (); } /** diff --git a/MdePkg/Library/BaseLib/Ipf/CpuBreakpointMsc.c b/MdePkg/Library/BaseLib/Ipf/CpuBreakpointMsc.c index 89b0acfd801b..2b098d462bee 100644 --- a/MdePkg/Library/BaseLib/Ipf/CpuBreakpointMsc.c +++ b/MdePkg/Library/BaseLib/Ipf/CpuBreakpointMsc.c @@ -29,11 +29,14 @@ **/ VOID EFIAPI +ANALYZER_NORETURN CpuBreakpoint ( VOID ) { __break (0); + + ANALYZER_UNREACHABLE (); } /** diff --git a/MdePkg/Library/BaseLib/X64/CpuBreakpoint.c b/MdePkg/Library/BaseLib/X64/CpuBreakpoint.c index d654f845716f..72055c2acfaa 100644 --- a/MdePkg/Library/BaseLib/X64/CpuBreakpoint.c +++ b/MdePkg/Library/BaseLib/X64/CpuBreakpoint.c @@ -30,10 +30,13 @@ void __debugbreak (); **/ VOID EFIAPI +ANALYZER_NORETURN CpuBreakpoint ( VOID ) { __debugbreak (); + + ANALYZER_UNREACHABLE (); } diff --git a/MdePkg/Library/BaseLib/X64/GccInline.c b/MdePkg/Library/BaseLib/X64/GccInline.c index 3d175ee9314e..b3443c55cb27 100644 --- a/MdePkg/Library/BaseLib/X64/GccInline.c +++ b/MdePkg/Library/BaseLib/X64/GccInline.c @@ -99,11 +99,14 @@ CpuPause ( **/ VOID EFIAPI +ANALYZER_NORETURN CpuBreakpoint ( VOID ) { __asm__ __volatile__ ("int $3"); + + ANALYZER_UNREACHABLE (); } diff --git a/MdePkg/Include/Library/BaseLib.h b/MdePkg/Include/Library/BaseLib.h index 79f421a97111..87f1e39d61db 100644 --- a/MdePkg/Include/Library/BaseLib.h +++ b/MdePkg/Include/Library/BaseLib.h @@ -3960,6 +3960,7 @@ SwitchStack ( **/ VOID EFIAPI +ANALYZER_NORETURN CpuBreakpoint ( VOID ); @@ -3976,6 +3977,7 @@ CpuBreakpoint ( **/ VOID EFIAPI +ANALYZER_NORETURN CpuDeadLoop ( VOID ); diff --git a/MdePkg/Library/BaseLib/AArch64/CpuBreakpoint.S b/MdePkg/Library/BaseLib/AArch64/CpuBreakpoint.S index 6323cffaa981..e4008ec1d3fd 100644 --- a/MdePkg/Library/BaseLib/AArch64/CpuBreakpoint.S +++ b/MdePkg/Library/BaseLib/AArch64/CpuBreakpoint.S @@ -28,6 +28,7 @@ GCC_ASM_EXPORT(CpuBreakpoint) #**/ #VOID #EFIAPI +#ANALYZER_NORETURN #CpuBreakpoint ( # VOID # ); diff --git a/MdePkg/Library/BaseLib/Arm/CpuBreakpoint.S b/MdePkg/Library/BaseLib/Arm/CpuBreakpoint.S index b6b80a1326d0..accb6f1b3287 100644 --- a/MdePkg/Library/BaseLib/Arm/CpuBreakpoint.S +++ b/MdePkg/Library/BaseLib/Arm/CpuBreakpoint.S @@ -27,6 +27,7 @@ GCC_ASM_EXPORT(CpuBreakpoint) #**/ #VOID #EFIAPI +#ANALYZER_NORETURN #CpuBreakpoint ( # VOID # ); diff --git a/MdePkg/Library/BaseLib/Arm/CpuBreakpoint.asm b/MdePkg/Library/BaseLib/Arm/CpuBreakpoint.asm index 8a8065159bf2..5d51d13930f3 100644 --- a/MdePkg/Library/BaseLib/Arm/CpuBreakpoint.asm +++ b/MdePkg/Library/BaseLib/Arm/CpuBreakpoint.asm @@ -27,6 +27,7 @@ ;**/ ;VOID ;EFIAPI +;ANALYZER_NORETURN ;CpuBreakpoint ( ; VOID ; ); diff --git a/MdePkg/Library/BaseLib/Ia32/CpuBreakpoint.asm b/MdePkg/Library/BaseLib/Ia32/CpuBreakpoint.asm index e4364055e8ee..e48a0fa92517 100644 --- a/MdePkg/Library/BaseLib/Ia32/CpuBreakpoint.asm +++ b/MdePkg/Library/BaseLib/Ia32/CpuBreakpoint.asm @@ -28,6 +28,7 @@ ;------------------------------------------------------------------------------ ; VOID ; EFIAPI +; ANALYZER_NORETURN ; CpuBreakpoint ( ; VOID ; ); diff --git a/MdePkg/Library/BaseLib/X64/CpuBreakpoint.asm b/MdePkg/Library/BaseLib/X64/CpuBreakpoint.asm index 25dd9b48e808..f0e4e93714fb 100644 --- a/MdePkg/Library/BaseLib/X64/CpuBreakpoint.asm +++ b/MdePkg/Library/BaseLib/X64/CpuBreakpoint.asm @@ -25,6 +25,7 @@ ;------------------------------------------------------------------------------ ; VOID ; EFIAPI +; ANALYZER_NORETURN ; CpuBreakpoint ( ; VOID ; ); -- 2.7.4.windows.1 _______________________________________________ edk2-devel mailing list [email protected] https://lists.01.org/mailman/listinfo/edk2-devel

