diff options
author | Nicholas-Baron <nicholas.baron.ten@gmail.com> | 2021-04-16 15:37:24 -0700 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-04-17 01:07:36 +0200 |
commit | 4454735bf8ebddfad7fc6bc0c65b7ad52aa8fd92 (patch) | |
tree | 5f62c18d5f6907935ba7922eb16af5bfd280e454 /Kernel | |
parent | 586f10b6e17a36b045377988205230b29892be0f (diff) | |
download | serenity-4454735bf8ebddfad7fc6bc0c65b7ad52aa8fd92.zip |
Kernel: Add `-Wnull-dereference` flag
`-Wnull-dereference` has found a lot of "possible null dereferences" in userland.
However, in the kernel, no warnings occurred. To keep it that way,
preemptivly add the flag here and remove it once it is enabled system
wide.
This flag makes the compiler check statically for a null deref. It does
not take into account any human-imposed invariants and as such, may need a
`VERIFY(ptr);`, `if(ptr)`, or `if(!ptr)` before using a pointer.
However, as long as a pointer is not reassigned,
the verify will be valid, meaning that adding `VERIFY` can be done sparingly.
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/CMakeLists.txt | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Kernel/CMakeLists.txt b/Kernel/CMakeLists.txt index c97fb0cf3e..4349b51bcd 100644 --- a/Kernel/CMakeLists.txt +++ b/Kernel/CMakeLists.txt @@ -298,7 +298,7 @@ set(SOURCES ${C_SOURCES} ) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-warning-option -Wvla") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-warning-option -Wvla -Wnull-dereference") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pie -fPIE -fno-rtti -ffreestanding -fbuiltin") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mno-80387 -mno-mmx -mno-sse -mno-sse2") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-asynchronous-unwind-tables") |