diff options
author | Peter Wu <peter@lekensteyn.nl> | 2018-10-21 11:53:19 +0200 |
---|---|---|
committer | Peter Wu <peter@lekensteyn.nl> | 2018-10-21 11:46:40 +0000 |
commit | 9f74af24f1c7e37b1dfce9041a71cc2ac2ed89f9 (patch) | |
tree | 7b77f6b97b3d7df5e8ed80ccf477039276b73351 | |
parent | 95614f219f4af7160423dfca8a8b316964d64c3b (diff) |
lemon: fix GCC/Clang warnings pre CMake 3.11, silence VSCA warnings
The COMPILE_OPTIONS source file property was introduced with CMake 3.11,
disable warnings via a target property instead (available since 2.8.12).
Disable some VS Code Analysis warnings. These flags seem to be accepted
since VS2015, so they can be added unconditionally.
Change-Id: Idfbf154caf8c1168f1f871a640a25b816a2cfab8
Fixes: v2.9.0rc0-2274-g7ce9081fdc ("lemon: sync with upstream (2018-09-08)")
Reviewed-on: https://code.wireshark.org/review/30298
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
-rw-r--r-- | tools/lemon/CMakeLists.txt | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/tools/lemon/CMakeLists.txt b/tools/lemon/CMakeLists.txt index 856d226ea6..f730ba058a 100644 --- a/tools/lemon/CMakeLists.txt +++ b/tools/lemon/CMakeLists.txt @@ -7,11 +7,26 @@ # SPDX-License-Identifier: GPL-2.0-or-later # +add_executable(lemon lemon.c) + # To keep lemon.c as close to upstream as possible, deliberately ignore # some stylistic issues. set(lemon_cflags) -if(NOT CMAKE_C_COMPILER_ID MATCHES "MSVC") - # Includes warnings from ENABLE_EXTRA_COMPILER_WARNINGS as well +if(CMAKE_C_COMPILER_ID MATCHES "MSVC") + # Normal MSVC has no warnings, but VS Code Analysis finds a bunch + # (when ENABLE_CODE_ANALYSIS is set). + set(lemon_cflags + /wd6001 # Using uninitialized memory '*zBuf'. + /wd6011 # Dereferencing NULL pointer 'cp'. + /wd6308 # realloc may return NULL and leak original memory. + /wd6385 # Buffer overrun (read) in Parse, related to 'cp' + /wd6386 # Buffer overrun (write) in Parse, related to 'filebuf' + /wd6387 # strlen(argv[0]) could receive a NULL pointer. + /wd28182 # Dereferencing NULL pointer. 'ap2' contains the same NULL value as 'ap' did. + /wd28183 # passing 0 (from realloc) to memcpy + /wd28199 # Using possibly uninitialized memory + ) +else() set(lemon_cflags_test # GCC 8.2.1 is not smart enough to recognize "Fall thru ..." -Wimplicit-fallthrough @@ -45,11 +60,7 @@ if(NOT CMAKE_C_COMPILER_ID MATCHES "MSVC") endif() endforeach() endif() -set_source_files_properties(lemon.c - PROPERTIES - COMPILE_OPTIONS "${lemon_cflags}" -) -add_executable(lemon lemon.c) +target_compile_options(lemon PRIVATE ${lemon_cflags}) # # Editor modelines - https://www.wireshark.org/tools/modelines.html |