diff options
23 files changed, 80 insertions, 70 deletions
diff --git a/Jamroot.jam b/Jamroot.jam index 04c973d..5bf8c98 100644 --- a/Jamroot.jam +++ b/Jamroot.jam @@ -17,6 +17,21 @@ project <variant>release:<lto>on <variant>debug:<warnings>extra <variant>debug:<warnings-as-errors>on + <variant>debug:<cflags>-Wnon-virtual-dtor + <variant>debug:<cflags>-Wold-style-cast + <variant>debug:<cflags>-Wcast-align + <variant>debug:<cflags>-Wunused + <variant>debug:<cflags>-Woverloaded-virtual + <variant>debug:<cflags>-Wpedantic + <variant>debug:<cflags>-Wconversion + <variant>debug:<cflags>-Wsign-conversion + <variant>debug:<cflags>-Wnull-dereference + <variant>debug:<cflags>-Wdouble-promotion + <variant>debug:<cflags>-Wformat=2 + <toolset>gcc,<variant>debug:<cflags>-Wduplicated-cond + <toolset>gcc,<variant>debug:<cflags>-Wduplicated-branches + <toolset>gcc,<variant>debug:<cflags>-Wlogical-op + <toolset>gcc,<variant>debug:<cflags>-Wuseless-cast <variant>coverage:<coverage>on <variant>coverage:<define>COVERAGE <toolset>tidy:<exclude>icetray/bin/logWriter.h @@ -27,6 +42,7 @@ project <toolset>tidy:<checkxx>boost-* <toolset>tidy:<checkxx>bugprone-* <toolset>tidy:<xcheckxx>bugprone-macro-parentheses + <toolset>tidy:<xcheckxx>bugprone-easily-swappable-parameters <toolset>tidy:<checkxx>clang-* <toolset>tidy:<checkxx>misc-* <toolset>tidy:<xcheckxx>misc-non-private-member-variables-in-classes @@ -38,6 +54,8 @@ project <toolset>tidy:<xcheckxx>hicpp-named-parameter <toolset>tidy:<checkxx>performance-* <toolset>tidy:<define>ICE_IGNORE_VERSION + <toolset>tidy:<librarydef>boost + <toolset>tidy:<librarydef>std ; build-project icetray ; diff --git a/icetray/dryice/mockPool.cpp b/icetray/dryice/mockPool.cpp index a244953..6ad91d2 100644 --- a/icetray/dryice/mockPool.cpp +++ b/icetray/dryice/mockPool.cpp @@ -4,12 +4,12 @@ namespace IceTray { MockPool::MockPool(const std::string & name, const std::string &, const Ice::PropertiesPtr & p) : - MockPool(name, p->getPropertyAsIntWithDefault(name + ".Database.PoolMax", 10), - p->getPropertyAsIntWithDefault(name + ".Database.PoolKeep", 2)) + MockPool(name, static_cast<unsigned int>(p->getPropertyAsIntWithDefault(name + ".Database.PoolMax", 10)), + static_cast<unsigned int>(p->getPropertyAsIntWithDefault(name + ".Database.PoolKeep", 2))) { } - MockPool::MockPool(std::string name, int size, int keep) : + MockPool::MockPool(std::string name, unsigned int size, unsigned int keep) : DB::BasicConnectionPool(size, keep), name(std::move(name)) { } @@ -20,5 +20,5 @@ namespace IceTray { return DB::MockDatabase::openConnectionTo(name); } - FACTORY(MockPool, PoolProvider); -}; + FACTORY(MockPool, PoolProvider) +} diff --git a/icetray/dryice/mockPool.h b/icetray/dryice/mockPool.h index 4a4e70a..1cf35bd 100644 --- a/icetray/dryice/mockPool.h +++ b/icetray/dryice/mockPool.h @@ -9,7 +9,7 @@ namespace IceTray { class DLL_PUBLIC MockPool : public DB::BasicConnectionPool { public: MockPool(const std::string & name, const std::string &, const Ice::PropertiesPtr & p); - MockPool(std::string name, int size, int keep); + MockPool(std::string name, unsigned int size, unsigned int keep); DB::ConnectionPtr createResource() const override; diff --git a/icetray/icetray/abstractDatabaseClient.h b/icetray/icetray/abstractDatabaseClient.h index 8c0814c..3a835cb 100644 --- a/icetray/icetray/abstractDatabaseClient.h +++ b/icetray/icetray/abstractDatabaseClient.h @@ -3,12 +3,12 @@ #include "sqlSource.h" #include <Ice/BuiltinSequences.h> +#include <command.h> #include <connectionPool.h> #include <db/sqlSelectDeserializer.h> +#include <selectcommand.h> #include <slicer/slicer.h> #include <visibility.h> -#include <command.h> -#include <selectcommand.h> namespace IceTray { class DLL_PUBLIC AbstractDatabaseClient { @@ -54,7 +54,7 @@ namespace IceTray { bind(offset + 1, cmd, params...); } - static void inline bind(int, DB::Command *) { } + static void inline bind(unsigned int, DB::Command *) { } DB::ConnectionPoolPtr db; }; diff --git a/icetray/icetray/defaultPool.cpp b/icetray/icetray/defaultPool.cpp index f99ed2e..12da668 100644 --- a/icetray/icetray/defaultPool.cpp +++ b/icetray/icetray/defaultPool.cpp @@ -3,12 +3,12 @@ namespace IceTray { DefaultPool::DefaultPool(const std::string & name, const std::string & type, const Ice::PropertiesPtr & p) : - DB::ConnectionPool(p->getPropertyAsIntWithDefault(name + ".Database.PoolMax", 10), - p->getPropertyAsIntWithDefault(name + ".Database.PoolKeep", 2), + DB::ConnectionPool(static_cast<unsigned int>(p->getPropertyAsIntWithDefault(name + ".Database.PoolMax", 10)), + static_cast<unsigned int>(p->getPropertyAsIntWithDefault(name + ".Database.PoolKeep", 2)), p->getPropertyWithDefault(name + ".Database.Type", type), p->getProperty(name + ".Database.ConnectionString")) { } - FACTORY(DefaultPool, PoolProvider); + FACTORY(DefaultPool, PoolProvider) } diff --git a/icetray/icetray/icecube.cpp b/icetray/icetray/icecube.cpp index e8b500c..69b7984 100644 --- a/icetray/icetray/icecube.cpp +++ b/icetray/icetray/icecube.cpp @@ -1,4 +1,4 @@ #include "icecube.h" #include <plugins.impl.h> -INSTANTIATEPLUGINOF(IceTray::CubePlugIn); +INSTANTIATEPLUGINOF(IceTray::CubePlugIn) diff --git a/icetray/icetray/icetrayService.cpp b/icetray/icetray/icetrayService.cpp index 0005be0..831ea29 100644 --- a/icetray/icetray/icetrayService.cpp +++ b/icetray/icetray/icetrayService.cpp @@ -98,5 +98,5 @@ createIceTrayService(Ice::CommunicatorPtr ic) } } -INSTANTIATEPLUGINOF(IceTray::ServiceFactory); -INSTANTIATEFACTORY(DB::BasicConnectionPool, const std::string &, const std::string &, const Ice::PropertiesPtr &); +INSTANTIATEPLUGINOF(IceTray::ServiceFactory) +INSTANTIATEFACTORY(DB::BasicConnectionPool, const std::string &, const std::string &, const Ice::PropertiesPtr &) diff --git a/icetray/icetray/logWriterConsole.cpp b/icetray/icetray/logWriterConsole.cpp index 65f9694..be5d6ae 100644 --- a/icetray/icetray/logWriterConsole.cpp +++ b/icetray/icetray/logWriterConsole.cpp @@ -26,6 +26,6 @@ namespace IceTray { { return LogMsg::write(s, Slicer::ModelPartForEnum<LogLevel>::lookup(priority), width, domain, message); } - FACTORY(ConsoleLogWriter, LogWriterFactory); + FACTORY(ConsoleLogWriter, LogWriterFactory) } } diff --git a/icetray/icetray/logWriterSyslog.cpp b/icetray/icetray/logWriterSyslog.cpp index f47b4c5..55c3abf 100644 --- a/icetray/icetray/logWriterSyslog.cpp +++ b/icetray/icetray/logWriterSyslog.cpp @@ -25,9 +25,9 @@ namespace IceTray { void SyslogLogWriter::message(LogLevel priority, Domain domain, const std::string_view message, const Ice::Current &) { - syslog((int)priority, "%s", LogMsg::get(width, domain, message).c_str()); + syslog(static_cast<int>(priority), "%s", LogMsg::get(width, domain, message).c_str()); } - FACTORY(SyslogLogWriter, LogWriterFactory); + FACTORY(SyslogLogWriter, LogWriterFactory) } } diff --git a/icetray/icetray/logger.cpp b/icetray/icetray/logger.cpp index 6a54991..cb27d2d 100644 --- a/icetray/icetray/logger.cpp +++ b/icetray/icetray/logger.cpp @@ -8,7 +8,7 @@ #include <lockHelpers.h> #include <slicer/modelPartsTypes.h> -INSTANTIATEFACTORY(IceTray::Logging::LogWriter, const Ice::PropertiesPtr &); +INSTANTIATEFACTORY(IceTray::Logging::LogWriter, const Ice::PropertiesPtr &) template class ::AdHoc::GlobalStatic<::IceTray::Logging::LogManager>; @@ -62,31 +62,25 @@ namespace IceTray { va_list v; // NOLINTNEXTLINE(hicpp-vararg,hicpp-no-array-decay) va_start(v, msgfmt); + char * msg; // NOLINTNEXTLINE(hicpp-no-array-decay) - vmessagef(fl, priority, msgfmt, v); + int len = vasprintf(&msg, msgfmt, v); + if (len > 0) { + message(fl, priority, msg); + } + // NOLINTNEXTLINE(hicpp-no-malloc) + free(msg); // NOLINTNEXTLINE(hicpp-no-array-decay) va_end(v); } } - void - Logger::vmessagef(LogLevelWriters::const_iterator fl, LogLevel priority, const char * msgfmt, va_list va) const - { - char * msg; - int len = vasprintf(&msg, msgfmt, va); - if (len > 0) { - message(fl, priority, msg); - } - // NOLINTNEXTLINE(hicpp-no-malloc) - free(msg); - } - LogLevelWriters::const_iterator Logger::firstFor(LogLevel priority) const { SharedLock(_lock); auto i = logs.begin(); - i += (int)priority; + i += static_cast<int>(priority); while (i != logs.end()) { if (!i->empty()) { return i; @@ -123,7 +117,7 @@ namespace IceTray { for (const auto & log : logWriters) { auto level = log->level(domain); if (level) { - logs[(int)*level].insert(log); + logs[static_cast<size_t>(*level)].insert(log); } } return logs; @@ -217,7 +211,7 @@ namespace IceTray { AbstractLogWriter::splitDomain(const std::string & domain) { if (domain.empty()) { - return Ice::StringSeq(); + return {}; } Ice::StringSeq domainTokens; @@ -228,19 +222,20 @@ namespace IceTray { AdHocFormatter(DomainFmt, ".%?"); void - AbstractLogWriter::writeDomain(std::ostream & s, ssize_t width, const IceTray::Logging::Domain & domain) + AbstractLogWriter::writeDomain( + std::ostream & s, std::optional<size_t> width, const IceTray::Logging::Domain & domain) { if (auto di = domain.begin(); di != domain.end()) { - if (width == -1) { + if (!width) { s << *di++; while (di != domain.end()) { DomainFmt::write(s, *di++); } } else { - auto target = width; + auto target = *width; while (di != domain.end()) { - auto total = di == domain.begin() ? -1 : 0; + auto total = di == domain.begin() ? std::string::npos : 0; for (auto dic = di; dic != domain.end(); dic++) { total += 1 + dic->length(); } diff --git a/icetray/icetray/logger.h b/icetray/icetray/logger.h index 44bbc98..ebee7e5 100644 --- a/icetray/icetray/logger.h +++ b/icetray/icetray/logger.h @@ -66,7 +66,6 @@ namespace IceTray { private: void message(LogLevelWriters::const_iterator fl, LogLevel priority, const std::string & msg) const; - void vmessagef(LogLevelWriters::const_iterator fl, LogLevel priority, const char * msgfmt, va_list) const; template<typename Arg, typename... OtherArgs> void messagebf(LogLevelWriters::const_iterator fl, LogLevel priority, boost::format & f, const Arg & arg, @@ -119,7 +118,7 @@ namespace IceTray { public: static Domain splitDomain(const std::string &); - static void writeDomain(std::ostream &, ssize_t, const Domain &); + static void writeDomain(std::ostream &, std::optional<size_t>, const Domain &); }; using LogWriterFactory = AdHoc::Factory<LogWriter, const Ice::PropertiesPtr &>; @@ -136,7 +135,8 @@ namespace AdHoc { static void write(stream & s, ssize_t width, const IceTray::Logging::Domain & domain, const Pn &... pn) { - IceTray::Logging::AbstractLogWriter::writeDomain(s, width, domain); + IceTray::Logging::AbstractLogWriter::writeDomain( + s, width >= 0 ? std::make_optional(width) : std::nullopt, domain); StreamWriter::next(s, pn...); } }; diff --git a/icetray/icetray/mimeImpl.cpp b/icetray/icetray/mimeImpl.cpp index 388828c..3f30112 100644 --- a/icetray/icetray/mimeImpl.cpp +++ b/icetray/icetray/mimeImpl.cpp @@ -55,7 +55,7 @@ namespace IceTray::Mime { else if (ch == ' ' || ch == '\t') { if (nextCh == '\r' || nextCh == '\n') { wrapIfNeeded(3); - fprintf(ms, "=%02X", (uint8_t)ch); + fprintf(ms, "=%02X", static_cast<uint8_t>(ch)); line += 3; } else { @@ -71,7 +71,7 @@ namespace IceTray::Mime { } else { wrapIfNeeded(3); - fprintf(ms, "=%02X", (uint8_t)ch); + fprintf(ms, "=%02X", static_cast<uint8_t>(ch)); line += 3; } } diff --git a/icetray/icetray/options.cpp b/icetray/icetray/options.cpp index 0eb9887..23346ab 100644 --- a/icetray/icetray/options.cpp +++ b/icetray/icetray/options.cpp @@ -1,8 +1,8 @@ #include "options.h" #include <factory.impl.h> -INSTANTIATEVOIDFACTORY(IceTray::Options); -INSTANTIATEPLUGINOF(IceTray::Options); +INSTANTIATEVOIDFACTORY(IceTray::Options) +INSTANTIATEPLUGINOF(IceTray::Options) namespace po = boost::program_options; diff --git a/icetray/icetray/options.h b/icetray/icetray/options.h index 34d20c2..e7d5e29 100644 --- a/icetray/icetray/options.h +++ b/icetray/icetray/options.h @@ -62,7 +62,7 @@ namespace IceTray { #define ICETRAY_OPTIONS_DECLARE void ICETRAY_OPTIONS_FUNC override; #define ICETRAY_OPTIONS_INLINE(OptsDef) void ICETRAY_OPTIONS_FUNC override ICETRAY_OPTIONS_BODY(OptsDef) #define ICETRAY_OPTIONS(Class, OptsDef) \ - FACTORY(Class, IceTray::OptionsFactory); \ + FACTORY(Class, IceTray::OptionsFactory) \ void Class::ICETRAY_OPTIONS_FUNC ICETRAY_OPTIONS_BODY(OptsDef) #endif diff --git a/icetray/unittests/testIceBoxInterface.cpp b/icetray/unittests/testIceBoxInterface.cpp index a004331..d5132d4 100644 --- a/icetray/unittests/testIceBoxInterface.cpp +++ b/icetray/unittests/testIceBoxInterface.cpp @@ -8,9 +8,7 @@ BOOST_AUTO_TEST_CASE(IceBoxInterface) { using SetupFunction = IceTray::Service * (*)(Ice::CommunicatorPtr); - void * i = dlsym(nullptr, "createIceTrayService"); - BOOST_REQUIRE(i); - auto sf = (SetupFunction)i; + auto sf = reinterpret_cast<SetupFunction>(dlsym(nullptr, "createIceTrayService")); BOOST_REQUIRE(sf); auto service = sf(nullptr); BOOST_REQUIRE(service); diff --git a/icetray/unittests/testIceTray.cpp b/icetray/unittests/testIceTray.cpp index 25e8212..864904a 100644 --- a/icetray/unittests/testIceTray.cpp +++ b/icetray/unittests/testIceTray.cpp @@ -27,7 +27,7 @@ public: TestIceTray::TestIceTrayServicePrxPtr p; }; -BOOST_FIXTURE_TEST_SUITE(client, Client); +BOOST_FIXTURE_TEST_SUITE(client, Client) BOOST_AUTO_TEST_CASE(services) { @@ -61,7 +61,7 @@ BOOST_AUTO_TEST_CASE(getIceComponents) BOOST_REQUIRE(getAdapter()); } -BOOST_AUTO_TEST_SUITE_END(); +BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_CASE(sqlModify) { diff --git a/icetray/unittests/testIceTrayLogger.cpp b/icetray/unittests/testIceTrayLogger.cpp index f667ede..2b658e8 100644 --- a/icetray/unittests/testIceTrayLogger.cpp +++ b/icetray/unittests/testIceTrayLogger.cpp @@ -35,7 +35,7 @@ public: std::vector<LogEntry> msgs; }; -FACTORY(TestLogWriter, LogWriterFactory); +FACTORY(TestLogWriter, LogWriterFactory) namespace std { ostream & @@ -103,7 +103,7 @@ private: Ice::ObjectAdapterPtr adp; }; -BOOST_FIXTURE_TEST_SUITE(li, TestLogImpl); +BOOST_FIXTURE_TEST_SUITE(li, TestLogImpl) BOOST_AUTO_TEST_CASE(no_writers) { @@ -297,9 +297,9 @@ BOOST_AUTO_TEST_CASE(domains_fromProperties_badLevel) BOOST_REQUIRE_THROW({ TestLogWriter tlw("TestLogWriter", p); }, Slicer::InvalidEnumerationSymbol); } -BOOST_AUTO_TEST_SUITE_END(); +BOOST_AUTO_TEST_SUITE_END() -BOOST_FIXTURE_TEST_SUITE(ts, TestService); +BOOST_FIXTURE_TEST_SUITE(ts, TestService) BOOST_AUTO_TEST_CASE(getLogger) { @@ -322,7 +322,7 @@ BOOST_AUTO_TEST_CASE(getLoggerForType) BOOST_REQUIRE_EQUAL(expected, logger->getDomain()); } -BOOST_AUTO_TEST_SUITE_END(); +BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_CASE(syslog) { diff --git a/icetray/unittests/testIceTrayMail.cpp b/icetray/unittests/testIceTrayMail.cpp index 7ec1a75..b4394fb 100644 --- a/icetray/unittests/testIceTrayMail.cpp +++ b/icetray/unittests/testIceTrayMail.cpp @@ -103,7 +103,7 @@ const std::string html_content = "<html lang=\"en\">\r\n" "</head>\r\n" "<html>\r\n"; -BOOST_FIXTURE_TEST_SUITE(base, TestBase); +BOOST_FIXTURE_TEST_SUITE(base, TestBase) BOOST_AUTO_TEST_CASE(single_part) { @@ -165,14 +165,13 @@ BOOST_AUTO_TEST_CASE(send_real_mail_fail) } } -BOOST_AUTO_TEST_SUITE_END(); +BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_CASE(send_real_mail #ifndef COVERAGE - , - *boost::unit_test::disabled() +BOOST_AUTO_TEST_CASE(send_real_mail, *boost::unit_test::disabled()) +#else +BOOST_AUTO_TEST_CASE(send_real_mail) #endif -) { auto e = std::make_shared<Email>(); e->from = {__FUNCTION__, "dan@randomdan.homeip.net"}; diff --git a/icetray/unittests/testIceTrayReplace.cpp b/icetray/unittests/testIceTrayReplace.cpp index 724700e..7d5371a 100644 --- a/icetray/unittests/testIceTrayReplace.cpp +++ b/icetray/unittests/testIceTrayReplace.cpp @@ -39,7 +39,7 @@ public: TestIceTray::TestIceTrayServicePrxPtr p; }; -BOOST_FIXTURE_TEST_SUITE(client, Client); +BOOST_FIXTURE_TEST_SUITE(client, Client) BOOST_AUTO_TEST_CASE(services) { @@ -49,4 +49,4 @@ BOOST_AUTO_TEST_CASE(services) p->method2(1, "test"); } -BOOST_AUTO_TEST_SUITE_END(); +BOOST_AUTO_TEST_SUITE_END() diff --git a/icetray/unittests/testIceTrayServiceI.cpp b/icetray/unittests/testIceTrayServiceI.cpp index af6994c..5c95a97 100644 --- a/icetray/unittests/testIceTrayServiceI.cpp +++ b/icetray/unittests/testIceTrayServiceI.cpp @@ -93,5 +93,5 @@ namespace TestIceTray { IceTray::Cube::add<TestIceTray::TestCube, TestIceTray::TestCubeI>(); } - NAMEDFACTORY("default", TestService, IceTray::ServiceFactory); + NAMEDFACTORY("default", TestService, IceTray::ServiceFactory) } diff --git a/icetray/unittests/testOptions.cpp b/icetray/unittests/testOptions.cpp index e077d44..4151b32 100644 --- a/icetray/unittests/testOptions.cpp +++ b/icetray/unittests/testOptions.cpp @@ -5,7 +5,7 @@ TestOptions::TestOptions() : IceTray::Options("Test options"), testInt(0) { } ICETRAY_OPTIONS(TestOptions, ("testInt", boost::program_options::value(&testInt), "testInt")("testString", boost::program_options::value(&testString)->default_value("some string"), - "testString")("vec", boost::program_options::value(&testVec), "vector")); + "testString")("vec", boost::program_options::value(&testVec), "vector")) class TestOptionsInline : public IceTray::Options { public: @@ -15,4 +15,4 @@ public: int testInt {0}; }; -FACTORY(TestOptionsInline, IceTray::OptionsFactory); +FACTORY(TestOptionsInline, IceTray::OptionsFactory) diff --git a/icetray/unittests/testOptions.h b/icetray/unittests/testOptions.h index 7f6e640..7271fb7 100644 --- a/icetray/unittests/testOptions.h +++ b/icetray/unittests/testOptions.h @@ -7,7 +7,7 @@ class DLL_PUBLIC TestOptions : public IceTray::Options { public: TestOptions(); - ICETRAY_OPTIONS_DECLARE; + ICETRAY_OPTIONS_DECLARE int testInt; std::string testString; diff --git a/icetray/unittests/testService.cpp b/icetray/unittests/testService.cpp index a19e6a0..baeecf6 100644 --- a/icetray/unittests/testService.cpp +++ b/icetray/unittests/testService.cpp @@ -9,4 +9,4 @@ TestService::addObjects( IceTray::OptionsResolver<TestOptions> myOpts; } -FACTORY(TestService, IceTray::ServiceFactory); +FACTORY(TestService, IceTray::ServiceFactory) |