From: Michael Altizer (mialtize) Date: Wed, 8 Jan 2020 23:55:09 +0000 (+0000) Subject: Merge pull request #1925 in SNORT/snort3 from ~MIALTIZE/snort3:f31_warnings to master X-Git-Tag: 3.0.0-268~66 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=24deb0a3649b1a8c50779f9b9cdcc281d3363afc;p=thirdparty%2Fsnort3.git Merge pull request #1925 in SNORT/snort3 from ~MIALTIZE/snort3:f31_warnings to master Squashed commit of the following: commit f267210213b61f6beaf8c11ee14975da410db3bc Author: Michael Altizer Date: Wed Jan 8 16:29:57 2020 -0500 catch: Update to Catch v2.11.1 commit 12eb31c6584eb73e3b473ae65034f40d04367166 Author: Michael Altizer Date: Wed Jan 8 14:40:16 2020 -0500 build: Fix more Clang 9 compiler warnings --- diff --git a/src/catch/catch.hpp b/src/catch/catch.hpp index b4eccfc14..6c1756a6c 100644 --- a/src/catch/catch.hpp +++ b/src/catch/catch.hpp @@ -1,6 +1,6 @@ /* - * Catch v2.11.0 - * Generated: 2019-11-15 15:01:56.628356 + * Catch v2.11.1 + * Generated: 2019-12-28 21:22:11.930976 * ---------------------------------------------------------- * This file has been merged from multiple headers. Please don't edit it directly * Copyright (c) 2019 Two Blue Cubes Ltd. All rights reserved. @@ -15,7 +15,7 @@ #define CATCH_VERSION_MAJOR 2 #define CATCH_VERSION_MINOR 11 -#define CATCH_VERSION_PATCH 0 +#define CATCH_VERSION_PATCH 1 #ifdef __clang__ # pragma clang system_header @@ -241,9 +241,12 @@ namespace Catch { // MSVC traditional preprocessor needs some workaround for __VA_ARGS__ // _MSVC_TRADITIONAL == 0 means new conformant preprocessor // _MSVC_TRADITIONAL == 1 means old traditional non-conformant preprocessor -# if !defined(_MSVC_TRADITIONAL) || (defined(_MSVC_TRADITIONAL) && _MSVC_TRADITIONAL) -# define CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR -# endif +# if !defined(__clang__) // Handle Clang masquerading for msvc +# if !defined(_MSVC_TRADITIONAL) || (defined(_MSVC_TRADITIONAL) && _MSVC_TRADITIONAL) +# define CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR +# endif // MSVC_TRADITIONAL +# endif // __clang__ + #endif // _MSC_VER #if defined(_REENTRANT) || defined(_MSC_VER) @@ -3907,7 +3910,6 @@ namespace Generators { class SingleValueGenerator final : public IGenerator { T m_value; public: - SingleValueGenerator(T const& value) : m_value( value ) {} SingleValueGenerator(T&& value) : m_value(std::move(value)) {} T const& get() const override { @@ -3970,21 +3972,21 @@ namespace Generators { m_generators.emplace_back(std::move(generator)); } void populate(T&& val) { - m_generators.emplace_back(value(std::move(val))); + m_generators.emplace_back(value(std::forward(val))); } template void populate(U&& val) { - populate(T(std::move(val))); + populate(T(std::forward(val))); } template - void populate(U&& valueOrGenerator, Gs... moreGenerators) { + void populate(U&& valueOrGenerator, Gs &&... moreGenerators) { populate(std::forward(valueOrGenerator)); populate(std::forward(moreGenerators)...); } public: template - Generators(Gs... moreGenerators) { + Generators(Gs &&... moreGenerators) { m_generators.reserve(sizeof...(Gs)); populate(std::forward(moreGenerators)...); } @@ -4015,7 +4017,7 @@ namespace Generators { struct as {}; template - auto makeGenerators( GeneratorWrapper&& generator, Gs... moreGenerators ) -> Generators { + auto makeGenerators( GeneratorWrapper&& generator, Gs &&... moreGenerators ) -> Generators { return Generators(std::move(generator), std::forward(moreGenerators)...); } template @@ -4023,11 +4025,11 @@ namespace Generators { return Generators(std::move(generator)); } template - auto makeGenerators( T&& val, Gs... moreGenerators ) -> Generators { + auto makeGenerators( T&& val, Gs &&... moreGenerators ) -> Generators { return makeGenerators( value( std::forward( val ) ), std::forward( moreGenerators )... ); } template - auto makeGenerators( as, U&& val, Gs... moreGenerators ) -> Generators { + auto makeGenerators( as, U&& val, Gs &&... moreGenerators ) -> Generators { return makeGenerators( value( T( std::forward( val ) ) ), std::forward( moreGenerators )... ); } @@ -4053,11 +4055,11 @@ namespace Generators { } // namespace Catch #define GENERATE( ... ) \ - Catch::Generators::generate( CATCH_INTERNAL_LINEINFO, [ ]{ using namespace Catch::Generators; return makeGenerators( __VA_ARGS__ ); } ) + Catch::Generators::generate( CATCH_INTERNAL_LINEINFO, [ ]{ using namespace Catch::Generators; return makeGenerators( __VA_ARGS__ ); } ) //NOLINT(google-build-using-namespace) #define GENERATE_COPY( ... ) \ - Catch::Generators::generate( CATCH_INTERNAL_LINEINFO, [=]{ using namespace Catch::Generators; return makeGenerators( __VA_ARGS__ ); } ) + Catch::Generators::generate( CATCH_INTERNAL_LINEINFO, [=]{ using namespace Catch::Generators; return makeGenerators( __VA_ARGS__ ); } ) //NOLINT(google-build-using-namespace) #define GENERATE_REF( ... ) \ - Catch::Generators::generate( CATCH_INTERNAL_LINEINFO, [&]{ using namespace Catch::Generators; return makeGenerators( __VA_ARGS__ ); } ) + Catch::Generators::generate( CATCH_INTERNAL_LINEINFO, [&]{ using namespace Catch::Generators; return makeGenerators( __VA_ARGS__ ); } ) //NOLINT(google-build-using-namespace) // end catch_generators.hpp // start catch_generators_generic.hpp @@ -7320,60 +7322,65 @@ namespace Catch { #include namespace Catch { - namespace Detail { - template - struct ObjectStorage - { - using TStorage = typename std::aligned_storage::value>::type; + namespace Benchmark { + namespace Detail { + template + struct ObjectStorage + { + using TStorage = typename std::aligned_storage::value>::type; - ObjectStorage() : data() {} + ObjectStorage() : data() {} - ObjectStorage(const ObjectStorage& other) - { - new(&data) T(other.stored_object()); - } + ObjectStorage(const ObjectStorage& other) + { + new(&data) T(other.stored_object()); + } - ObjectStorage(ObjectStorage&& other) - { - new(&data) T(std::move(other.stored_object())); - } + ObjectStorage(ObjectStorage&& other) + { + new(&data) T(std::move(other.stored_object())); + } - ~ObjectStorage() { destruct_on_exit(); } + ~ObjectStorage() { destruct_on_exit(); } - template - void construct(Args&&... args) - { - new (&data) T(std::forward(args)...); - } + template + void construct(Args&&... args) + { + new (&data) T(std::forward(args)...); + } - template - typename std::enable_if::type destruct() - { - stored_object().~T(); - } + template + typename std::enable_if::type destruct() + { + stored_object().~T(); + } - private: - // If this is a constructor benchmark, destruct the underlying object - template - void destruct_on_exit(typename std::enable_if::type* = 0) { destruct(); } - // Otherwise, don't - template - void destruct_on_exit(typename std::enable_if::type* = 0) { } - - T& stored_object() - { - return *static_cast(static_cast(&data)); - } + private: + // If this is a constructor benchmark, destruct the underlying object + template + void destruct_on_exit(typename std::enable_if::type* = 0) { destruct(); } + // Otherwise, don't + template + void destruct_on_exit(typename std::enable_if::type* = 0) { } + + T& stored_object() { + return *static_cast(static_cast(&data)); + } - TStorage data; - }; - } + T const& stored_object() const { + return *static_cast(static_cast(&data)); + } - template - using storage_for = Detail::ObjectStorage; + TStorage data; + }; + } - template - using destructable_object = Detail::ObjectStorage; + template + using storage_for = Detail::ObjectStorage; + + template + using destructable_object = Detail::ObjectStorage; + } } // end catch_constructor.hpp @@ -7854,6 +7861,17 @@ namespace Catch { #define CATCH_TRAP() __asm__("int $3\n" : : ) /* NOLINT */ +#elif defined(CATCH_PLATFORM_IPHONE) + + // use inline assembler + #if defined(__i386__) || defined(__x86_64__) + #define CATCH_TRAP() __asm__("int $3") + #elif defined(__aarch64__) + #define CATCH_TRAP() __asm__(".inst 0xd4200000") + #elif defined(__arm__) + #define CATCH_TRAP() __asm__(".inst 0xe7f001f0") + #endif + #elif defined(CATCH_PLATFORM_LINUX) // If we can use inline assembler, do it because this allows us to break // directly at the location of the failing check instead of breaking inside @@ -10094,7 +10112,7 @@ namespace { bool useColourOnPlatform() { return -#ifdef CATCH_PLATFORM_MAC +#if defined(CATCH_PLATFORM_MAC) || defined(CATCH_PLATFORM_IPHONE) !isDebuggerActive() && #endif #if !(defined(__DJGPP__) && defined(__STRICT_ANSI__)) @@ -10271,7 +10289,7 @@ namespace Catch { // end catch_debug_console.cpp // start catch_debugger.cpp -#ifdef CATCH_PLATFORM_MAC +#if defined(CATCH_PLATFORM_MAC) || defined(CATCH_PLATFORM_IPHONE) # include # include @@ -15050,7 +15068,7 @@ namespace Catch { } Version const& libraryVersion() { - static Version version( 2, 11, 0, "", 0 ); + static Version version( 2, 11, 1, "", 0 ); return version; } diff --git a/src/catch/unit_test.cc b/src/catch/unit_test.cc index 9929443ed..b1a1924b4 100644 --- a/src/catch/unit_test.cc +++ b/src/catch/unit_test.cc @@ -65,7 +65,7 @@ int catch_test() // This isn't in snort_catch.cc because the linker may exclude the file if no static components // reference TestCaseInstaller SO_PUBLIC TestCaseInstaller::TestCaseInstaller(void(*fun)(), const char* name) -{ REGISTER_TEST_CASE(fun, name); } +{ REGISTER_TEST_CASE(fun, name) } SO_PUBLIC TestCaseInstaller::TestCaseInstaller(void(*fun)(), const char* name, const char* group) -{ REGISTER_TEST_CASE(fun, name, group); } +{ REGISTER_TEST_CASE(fun, name, group) } diff --git a/src/detection/ips_context.cc b/src/detection/ips_context.cc index 15196214e..dc6f1883f 100644 --- a/src/detection/ips_context.cc +++ b/src/detection/ips_context.cc @@ -181,8 +181,8 @@ TEST_CASE("IpsContext basic", "[IpsContext]") CHECK(TestData::count == num_data); } -IpsContext* post_val; -void test_post(IpsContext* c) +static IpsContext* post_val; +static void test_post(IpsContext* c) { post_val = c; } TEST_CASE("IpsContext post detection", "[IpsContext]") diff --git a/src/network_inspectors/appid/client_plugins/client_app_aim.cc b/src/network_inspectors/appid/client_plugins/client_app_aim.cc index a8127410b..0d439d6c8 100644 --- a/src/network_inspectors/appid/client_plugins/client_app_aim.cc +++ b/src/network_inspectors/appid/client_plugins/client_app_aim.cc @@ -110,7 +110,6 @@ static inline bool check_username( { const uint8_t* const end = data + tlv->len; char* ptr = buf; - *buf_end = '\0'; for ( const uint8_t* cur = data; cur < end; ++cur ) { @@ -123,6 +122,8 @@ static inline bool check_username( return false; } + *ptr = '\0'; + return true; } @@ -196,7 +197,7 @@ int AimClientDetector::validate(AppIdDiscoveryArgs& args) constexpr auto USERNAME_LEN = 256; char username[USERNAME_LEN]; - if ( check_username(cur, tlv, username, username + USERNAME_LEN) ) + if ( check_username(cur, tlv, username, username + USERNAME_LEN - 1) ) add_user(args.asd, username, APP_ID_AOL_INSTANT_MESSENGER, true); } break; diff --git a/src/network_inspectors/reputation/reputation_parse.cc b/src/network_inspectors/reputation/reputation_parse.cc index 8938f3c67..6a9dd5ade 100644 --- a/src/network_inspectors/reputation/reputation_parse.cc +++ b/src/network_inspectors/reputation/reputation_parse.cc @@ -679,7 +679,7 @@ static void load_list_file(ListFile* list_info, ReputationConfig* config) static int num_lines_in_file(char* fname) { FILE* fp; - uint32_t numlines = 0; + int numlines = 0; char buf[MAX_ADDR_LINE_LENGTH]; fp = fopen(fname, "rb"); diff --git a/src/piglet_plugins/pp_codec.cc b/src/piglet_plugins/pp_codec.cc index a7b017391..bdff1c647 100644 --- a/src/piglet_plugins/pp_codec.cc +++ b/src/piglet_plugins/pp_codec.cc @@ -46,9 +46,9 @@ private: }; CodecPiglet::CodecPiglet( - Lua::State& state, const std::string& target, Module* m, SnortConfig* sc) : - BasePlugin(state, target, m, sc) -{ wrapper = CodecManager::instantiate(target.c_str(), module, snort_conf); } + Lua::State& state, const std::string& tgt, Module* m, SnortConfig* sc) : + BasePlugin(state, tgt, m, sc) +{ wrapper = CodecManager::instantiate(tgt.c_str(), module, snort_conf); } CodecPiglet::~CodecPiglet() { diff --git a/src/piglet_plugins/pp_inspector.cc b/src/piglet_plugins/pp_inspector.cc index 21f75ca6f..5aa5f7170 100644 --- a/src/piglet_plugins/pp_inspector.cc +++ b/src/piglet_plugins/pp_inspector.cc @@ -46,15 +46,15 @@ private: }; InspectorPiglet::InspectorPiglet( - Lua::State& state, const std::string& target, Module* m, SnortConfig* sc) : - BasePlugin(state, target, m, sc) + Lua::State& state, const std::string& tgt, Module* m, SnortConfig* sc) : + BasePlugin(state, tgt, m, sc) { FlushBucket::set(0); assert(module); assert(snort_conf); - instance = InspectorManager::instantiate(target.c_str(), module, snort_conf); + instance = InspectorManager::instantiate(tgt.c_str(), module, snort_conf); } diff --git a/src/piglet_plugins/pp_ips_action.cc b/src/piglet_plugins/pp_ips_action.cc index 7f5d34f7a..b97e3a8f8 100644 --- a/src/piglet_plugins/pp_ips_action.cc +++ b/src/piglet_plugins/pp_ips_action.cc @@ -42,11 +42,11 @@ private: }; IpsActionPiglet::IpsActionPiglet( - Lua::State& state, const std::string& target, Module* m, SnortConfig* sc) : - BasePlugin(state, target, m, sc) + Lua::State& state, const std::string& tgt, Module* m, SnortConfig* sc) : + BasePlugin(state, tgt, m, sc) { if ( module ) - wrapper = ActionManager::instantiate(target.c_str(), m); + wrapper = ActionManager::instantiate(tgt.c_str(), m); } IpsActionPiglet::~IpsActionPiglet() diff --git a/src/piglet_plugins/pp_ips_option.cc b/src/piglet_plugins/pp_ips_option.cc index eeb7c4592..012ffd37c 100644 --- a/src/piglet_plugins/pp_ips_option.cc +++ b/src/piglet_plugins/pp_ips_option.cc @@ -45,8 +45,8 @@ private: }; IpsOptionPiglet::IpsOptionPiglet( - Lua::State& state, const std::string& target, Module* m) : - BasePlugin(state, target, m) + Lua::State& state, const std::string& tgt, Module* m) : + BasePlugin(state, tgt, m) { if ( !module ) return; @@ -56,7 +56,7 @@ IpsOptionPiglet::IpsOptionPiglet( if ( !otn ) return; - wrapper = IpsManager::instantiate(target.c_str(), m, otn); + wrapper = IpsManager::instantiate(tgt.c_str(), m, otn); } IpsOptionPiglet::~IpsOptionPiglet() diff --git a/src/piglet_plugins/pp_logger.cc b/src/piglet_plugins/pp_logger.cc index dfaa646d0..69a320179 100644 --- a/src/piglet_plugins/pp_logger.cc +++ b/src/piglet_plugins/pp_logger.cc @@ -45,12 +45,12 @@ private: }; LoggerPiglet::LoggerPiglet( - Lua::State& state, const std::string& target, Module* m, SnortConfig* sc) : - BasePlugin(state, target, m, sc) + Lua::State& state, const std::string& tgt, Module* m, SnortConfig* sc) : + BasePlugin(state, tgt, m, sc) { // FIXIT-M does Logger need module? if ( module ) - wrapper = EventManager::instantiate(target.c_str(), m, sc); + wrapper = EventManager::instantiate(tgt.c_str(), m, sc); } LoggerPiglet::~LoggerPiglet() diff --git a/src/piglet_plugins/pp_search_engine.cc b/src/piglet_plugins/pp_search_engine.cc index af641d41a..503487b2e 100644 --- a/src/piglet_plugins/pp_search_engine.cc +++ b/src/piglet_plugins/pp_search_engine.cc @@ -40,9 +40,9 @@ private: }; SearchEnginePiglet::SearchEnginePiglet( - Lua::State& state, const std::string& target, Module* m, SnortConfig* sc) : - BasePlugin(state, target, m, sc) -{ wrapper = MpseManager::instantiate(target.c_str(), module, snort_conf); } + Lua::State& state, const std::string& tgt, Module* m, SnortConfig* sc) : + BasePlugin(state, tgt, m, sc) +{ wrapper = MpseManager::instantiate(tgt.c_str(), module, snort_conf); } SearchEnginePiglet::~SearchEnginePiglet() { diff --git a/src/piglet_plugins/pp_so_rule.cc b/src/piglet_plugins/pp_so_rule.cc index bcb3fa94b..3386643cc 100644 --- a/src/piglet_plugins/pp_so_rule.cc +++ b/src/piglet_plugins/pp_so_rule.cc @@ -38,8 +38,8 @@ public: }; SoRulePiglet::SoRulePiglet( - Lua::State& state, const std::string& target, Module* m, SnortConfig* sc) : - BasePlugin(state, target, m, sc) { } + Lua::State& state, const std::string& tgt, Module* m, SnortConfig* sc) : + BasePlugin(state, tgt, m, sc) { } bool SoRulePiglet::setup() diff --git a/src/piglet_plugins/pp_test.cc b/src/piglet_plugins/pp_test.cc index dd1f06025..fdd0c8df6 100644 --- a/src/piglet_plugins/pp_test.cc +++ b/src/piglet_plugins/pp_test.cc @@ -40,8 +40,8 @@ using namespace snort; class TestPiglet : public Piglet::BasePlugin { public: - TestPiglet(Lua::State& state, const std::string& target) : - BasePlugin(state, target) { } + TestPiglet(Lua::State& state, const std::string& tgt) : + BasePlugin(state, tgt) { } bool setup() override; }; diff --git a/src/profiler/rule_profiler.cc b/src/profiler/rule_profiler.cc index 5012896db..52e415f87 100644 --- a/src/profiler/rule_profiler.cc +++ b/src/profiler/rule_profiler.cc @@ -524,21 +524,21 @@ TEST_CASE( "rule entry", "[profiler][rule_profiler]" ) SECTION( "avg_match" ) { auto ticks = entry.avg_match(); - INFO( ticks.count() << " == " << (1_ticks).count() ); + INFO( ticks.count() << " == " << (1_ticks).count() ) CHECK( (ticks == 1_ticks) ); } SECTION( "avg_no_match" ) { auto ticks = entry.avg_no_match(); - INFO( ticks.count() << " == " << (1_ticks).count() ); + INFO( ticks.count() << " == " << (1_ticks).count() ) CHECK( (ticks == 1_ticks) ); } SECTION( "avg_check" ) { auto ticks = entry.avg_check(); - INFO( ticks.count() << " == " << (1_ticks).count() ); + INFO( ticks.count() << " == " << (1_ticks).count() ) CHECK( (ticks == 1_ticks) ); } } @@ -697,10 +697,10 @@ TEST_CASE( "rule profiler time context", "[profiler][rule_profiler]" ) avoid_optimization(); } - INFO( "elapsed: " << stats.elapsed.count() ); + INFO( "elapsed: " << stats.elapsed.count() ) CHECK( (stats.elapsed > 0_ticks) ); CHECK( stats.checks == 1 ); - INFO( "elapsed_match: " << stats.elapsed_match.count() ); + INFO( "elapsed_match: " << stats.elapsed_match.count() ) CHECK( (stats.elapsed_match == 0_ticks) ); } @@ -715,7 +715,7 @@ TEST_CASE( "rule profiler time context", "[profiler][rule_profiler]" ) avoid_optimization(); ctx.stop(true); - INFO( "elapsed: " << stats.elapsed.count() ); + INFO( "elapsed: " << stats.elapsed.count() ) CHECK( (stats.elapsed > 0_ticks) ); CHECK( stats.checks == 1 ); CHECK( stats.elapsed_match == stats.elapsed ); @@ -730,7 +730,7 @@ TEST_CASE( "rule profiler time context", "[profiler][rule_profiler]" ) avoid_optimization(); ctx.stop(false); - INFO( "elapsed: " << stats.elapsed.count() ); + INFO( "elapsed: " << stats.elapsed.count() ) CHECK( (stats.elapsed > 0_ticks) ); CHECK( stats.checks == 1 ); CHECK( (stats.elapsed_match == 0_ticks) ); @@ -738,7 +738,7 @@ TEST_CASE( "rule profiler time context", "[profiler][rule_profiler]" ) } } - INFO( "elapsed: " << stats.elapsed.count() ); + INFO( "elapsed: " << stats.elapsed.count() ) CHECK( stats.elapsed == save.elapsed ); CHECK( stats.elapsed_match == save.elapsed_match ); CHECK( stats.checks == save.checks );