diff --git a/.cirrus.yml b/.cirrus.yml index c5a0280a78..036c10e176 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -10,13 +10,12 @@ btest_jobs: &BTEST_JOBS 4 btest_retries: &BTEST_RETRIES 2 memory: &MEMORY 16GB -config: &CONFIG --build-type=release --disable-broker-tests --prefix=$CIRRUS_WORKING_DIR/install --ccache -no_spicy_config: &NO_SPICY_CONFIG --build-type=release --disable-broker-tests --disable-spicy --prefix=$CIRRUS_WORKING_DIR/install --ccache -static_config: &STATIC_CONFIG --build-type=release --disable-broker-tests --enable-static-broker --enable-static-binpac --prefix=$CIRRUS_WORKING_DIR/install --ccache -asan_sanitizer_config: &ASAN_SANITIZER_CONFIG --build-type=debug --disable-broker-tests --sanitizers=address --enable-fuzzers --enable-coverage --disable-spicy --ccache -ubsan_sanitizer_config: &UBSAN_SANITIZER_CONFIG --build-type=debug --disable-broker-tests --sanitizers=undefined --enable-fuzzers --disable-spicy --ccache -tsan_sanitizer_config: &TSAN_SANITIZER_CONFIG --build-type=debug --disable-broker-tests --sanitizers=thread --enable-fuzzers --disable-spicy --ccache -openssl30_config: &OPENSSL30_CONFIG --build-type=release --disable-broker-tests --with-openssl=/opt/openssl --prefix=$CIRRUS_WORKING_DIR/install --ccache +config: &CONFIG --build-type=release --disable-broker-tests --prefix=$CIRRUS_WORKING_DIR/install --ccache --enable-werror +no_spicy_config: &NO_SPICY_CONFIG --build-type=release --disable-broker-tests --disable-spicy --prefix=$CIRRUS_WORKING_DIR/install --ccache --enable-werror +static_config: &STATIC_CONFIG --build-type=release --disable-broker-tests --enable-static-broker --enable-static-binpac --prefix=$CIRRUS_WORKING_DIR/install --ccache --enable-werror +asan_sanitizer_config: &ASAN_SANITIZER_CONFIG --build-type=debug --disable-broker-tests --sanitizers=address --enable-fuzzers --enable-coverage --disable-spicy --ccache --enable-werror +ubsan_sanitizer_config: &UBSAN_SANITIZER_CONFIG --build-type=debug --disable-broker-tests --sanitizers=undefined --enable-fuzzers --disable-spicy --ccache --enable-werror +tsan_sanitizer_config: &TSAN_SANITIZER_CONFIG --build-type=debug --disable-broker-tests --sanitizers=thread --enable-fuzzers --disable-spicy --ccache --enable-werror resources_template: &RESOURCES_TEMPLATE cpu: *CPUS diff --git a/CHANGES b/CHANGES index c69ace71e0..bb86891257 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,36 @@ +6.2.0-dev.337 | 2024-01-08 14:10:44 -0700 + + * Merge branch 'topic/timw/werror' (Tim Wojtulewicz, Corelight) + + * topic/timw/werror: + CI: Remove unused openssl30_config + CPP-gen: Don't emit extra braces if only one element + Use instead of + ZAM: Create ListValPtr directly instead of a stack object + Bump zeekjs to pick up dprintf warning fix + Avoid unused-result warning in Supervisor + Update src/3rdparty submodule to fix sprintf warning in modp + Fix warning with attribute string lookup + Set -Werror / /WX via target_compile_options to force warnings as errors + + * CI: Remove unused openssl30_config (Tim Wojtulewicz, Corelight) + + * CPP-gen: Don't emit extra braces if only one element (Tim Wojtulewicz, Corelight) + + * Use instead of (Tim Wojtulewicz, Corelight) + + * ZAM: Create ListValPtr directly instead of a stack object (Tim Wojtulewicz, Corelight) + + * Bump zeekjs to pick up dprintf warning fix (Tim Wojtulewicz, Corelight) + + * Avoid unused-result warning in Supervisor (Tim Wojtulewicz, Corelight) + + * Update src/3rdparty submodule to fix sprintf warning in modp (Tim Wojtulewicz, Corelight) + + * Fix warning with attribute string lookup (Tim Wojtulewicz, Corelight) + + * Set -Werror / /WX via target_compile_options to force warnings as errors (Tim Wojtulewicz, Corelight) + 6.2.0-dev.327 | 2024-01-08 10:04:49 -0700 * Update broker to pick up Windows 2-minute exception fix (Tim Wojtulewicz, Corelight) diff --git a/CMakeLists.txt b/CMakeLists.txt index 94119d4c96..eeffce462e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -165,8 +165,18 @@ if (MSVC) # Disable Spicy as it is not yet supported in Windows. set(DISABLE_SPICY true) + + if (BUILD_WITH_WERROR) + # TODO: This is disabled for now because there a bunch of known + # compiler warnings on Windows that we don't have good fixes for. + #set(WERROR_FLAG "/WX") + #set(WERROR_FLAG "/WX") + endif () else () include(GNUInstallDirs) + if (BUILD_WITH_WERROR) + set(WERROR_FLAG "-Werror") + endif () endif () include(cmake/CommonCMakeConfig.cmake) @@ -254,6 +264,7 @@ endif () foreach (name zeek_exe zeek_lib zeek_fuzzer_shared) if (TARGET ${name}) target_compile_definitions(${name} PRIVATE ZEEK_CONFIG_SKIP_VERSION_H) + target_compile_options(${name} PRIVATE ${WERROR_FLAG}) endif () endforeach () @@ -347,6 +358,7 @@ function (zeek_add_subdir_library name) add_dependencies(${target_name} zeek_autogen_files) target_link_libraries(${target_name} PRIVATE $) add_clang_tidy_files(${FN_ARGS_SOURCES}) + target_compile_options(${target_name} PRIVATE ${WERROR_FLAG}) # Take care of compiling BIFs. if (FN_ARGS_BIFS) diff --git a/VERSION b/VERSION index 02f5cf2513..63744007c5 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -6.2.0-dev.327 +6.2.0-dev.337 diff --git a/auxil/zeekjs b/auxil/zeekjs index 867e90b47f..70d88f4b10 160000 --- a/auxil/zeekjs +++ b/auxil/zeekjs @@ -1 +1 @@ -Subproject commit 867e90b47f657b92d03808af0475bfd34cc9bcef +Subproject commit 70d88f4b10e36f8715eb0f2a25eb0fc0eb4fce37 diff --git a/cmake b/cmake index 507d120121..01fcb68300 160000 --- a/cmake +++ b/cmake @@ -1 +1 @@ -Subproject commit 507d1201213a7b308298e0c5d6ac0c9f870e2bb8 +Subproject commit 01fcb683005e3c3a71ae867aa983b772a77e32d1 diff --git a/configure b/configure index e74d38280e..18f019b29c 100755 --- a/configure +++ b/configure @@ -64,6 +64,7 @@ Usage: $0 [OPTION]... [VAR=VALUE]... --enable-perftools-debug use Google's perftools for debugging --enable-static-binpac build binpac statically (ignored if --with-binpac is specified) --enable-static-broker build Broker statically (ignored if --with-broker is specified) + --enable-werror build with -Werror --disable-af-packet don't include native AF_PACKET support (Linux only) --disable-archiver don't build or install zeek-archiver tool --disable-auxtools don't build or install auxiliary tools @@ -275,6 +276,9 @@ while [ $# -ne 0 ]; do --enable-static-broker) append_cache_entry BUILD_STATIC_BROKER BOOL true ;; + --enable-werror) + append_cache_entry BUILD_WITH_WERROR BOOL true + ;; --disable-af-packet) append_cache_entry DISABLE_AF_PACKET BOOL true ;; diff --git a/src/3rdparty b/src/3rdparty index c2763e952e..06d7496bfa 160000 --- a/src/3rdparty +++ b/src/3rdparty @@ -1 +1 @@ -Subproject commit c2763e952ea899f86bec2b60f840d38861cefd03 +Subproject commit 06d7496bfadf333e121409604eb55460f09cfcae diff --git a/src/Attr.cc b/src/Attr.cc index f3a5ab6b9e..e080bfcfd6 100644 --- a/src/Attr.cc +++ b/src/Attr.cc @@ -45,7 +45,10 @@ const char* attr_name(AttrTag t) { }; // clang-format on - return attr_names[int(t)]; + if ( int(t) >= 0 && int(t) < NUM_ATTRS ) + return attr_names[int(t)]; + else + return ""; } Attr::Attr(AttrTag t, ExprPtr e) : expr(std::move(e)) { diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 27f0834715..4101e97be1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -41,8 +41,16 @@ set(BISON_FLAGS "--debug") if (MSVC) set(SIGN_COMPARE_FLAG "/wd4018") + if (BUILD_WITH_WERROR) + # TODO: This is disabled for now because there a bunch of known + # compiler warnings on Windows that we don't have good fixes for. + #set(WERROR_FLAG "/WX") + endif () else () set(SIGN_COMPARE_FLAG "-Wno-sign-compare") + if (BUILD_WITH_WERROR) + set(WERROR_FLAG "-Werror") + endif () endif () # Rule parser/scanner @@ -517,6 +525,7 @@ collect_headers(zeek_HEADERS ${zeek_SRCS}) add_library(zeek_objs OBJECT ${zeek_SRCS}) target_compile_features(zeek_objs PRIVATE ${ZEEK_CXX_STD}) +target_compile_options(zeek_objs PRIVATE ${WERROR_FLAG}) set_target_properties(zeek_objs PROPERTIES CXX_EXTENSIONS OFF) target_link_libraries(zeek_objs PRIVATE $) target_compile_definitions(zeek_objs PRIVATE ZEEK_CONFIG_SKIP_VERSION_H) @@ -530,6 +539,7 @@ endif () if (TARGET zeek_exe) target_sources(zeek_exe PRIVATE main.cc ${zeek_HEADERS}) + target_compile_options(zeek_exe PRIVATE ${WERROR_FLAG}) # npcap/winpcap need to be loaded in delayed mode so that we can set the load # path correctly at runtime. See @@ -553,6 +563,7 @@ endif () if (TARGET zeek_lib) target_sources(zeek_lib PRIVATE ${zeek_HEADERS}) + target_compile_options(zeek_lib PRIVATE ${WERROR_FLAG}) target_link_libraries(zeek_lib PUBLIC ${zeekdeps} ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) endif () diff --git a/src/DNS_Mgr.cc b/src/DNS_Mgr.cc index 53727290ae..a707d8ead0 100644 --- a/src/DNS_Mgr.cc +++ b/src/DNS_Mgr.cc @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/script_opt/CPP/InitsInfo.cc b/src/script_opt/CPP/InitsInfo.cc index 3dc3536edc..c8150dbe96 100644 --- a/src/script_opt/CPP/InitsInfo.cc +++ b/src/script_opt/CPP/InitsInfo.cc @@ -47,9 +47,13 @@ void CPP_InitsInfo::GenerateInitializers(CPPCompile* c) { if ( ++n > 1 ) c->Emit(""); - c->Emit("{"); - BuildCohort(c, cohort); - c->Emit("},"); + if ( cohort.size() == 1 ) + BuildCohort(c, cohort); + else { + c->Emit("{"); + BuildCohort(c, cohort); + c->Emit("},"); + } } c->Emit("}"); diff --git a/src/script_opt/ZAM/Ops.in b/src/script_opt/ZAM/Ops.in index bda9bd91dd..66bb15c8fb 100644 --- a/src/script_opt/ZAM/Ops.in +++ b/src/script_opt/ZAM/Ops.in @@ -770,10 +770,9 @@ eval auto op1 = frame[z.v1].ToVal(z.t); # the main instruction type, as always. macro EvalVal2InTableCore(op1, op2) - ListVal lv(TYPE_ANY); - lv.Append(op1); - lv.Append(op2); - ListValPtr lvp = {NewRef{}, &lv}; + auto lvp = zeek::make_intrusive(TYPE_ANY); + lvp->Append(op1); + lvp->Append(op2); macro EvalVal2InTableAssignCore(slot) frame[z.v1].int_val = frame[z.slot].table_val->Find(std::move(lvp)) != nullptr; diff --git a/src/supervisor/Supervisor.cc b/src/supervisor/Supervisor.cc index 9921c9b15d..a176f033e3 100644 --- a/src/supervisor/Supervisor.cc +++ b/src/supervisor/Supervisor.cc @@ -42,7 +42,7 @@ extern "C" { #ifdef DEBUG #define DBG_STEM(...) stem->LogDebug(__VA_ARGS__); #else -#define DBG_STEM +#define DBG_STEM(...) #endif using namespace zeek;