diff options
-rw-r--r-- | Jamroot.jam | 2 | ||||
-rw-r--r-- | slicer/db/sqlInsertSerializer.cpp | 18 | ||||
-rw-r--r-- | slicer/db/sqlInsertSerializer.h | 12 | ||||
-rw-r--r-- | slicer/db/sqlUpdateSerializer.cpp | 4 | ||||
-rw-r--r-- | slicer/ice/serializer.cpp | 2 | ||||
-rw-r--r-- | slicer/ice/testSpecifics.cpp | 10 | ||||
-rw-r--r-- | slicer/test/conversions.cpp | 7 | ||||
-rw-r--r-- | slicer/tool/icemetadata.cpp | 2 |
8 files changed, 32 insertions, 25 deletions
diff --git a/Jamroot.jam b/Jamroot.jam index 8e63adb..b1dc307 100644 --- a/Jamroot.jam +++ b/Jamroot.jam @@ -23,6 +23,8 @@ project <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 diff --git a/slicer/db/sqlInsertSerializer.cpp b/slicer/db/sqlInsertSerializer.cpp index 4061b17..f18df73 100644 --- a/slicer/db/sqlInsertSerializer.cpp +++ b/slicer/db/sqlInsertSerializer.cpp @@ -1,6 +1,6 @@ +#include "sqlInsertSerializer.h" #include "sqlBinder.h" #include "sqlCommon.h" -#include "sqlInsertSerializer.h" #include <boost/numeric/conversion/cast.hpp> #include <common.h> #include <compileTimeFormatter.h> @@ -56,7 +56,7 @@ namespace Slicer { void SqlInsertSerializer::bindObjectAndExecute(const Slicer::ModelPartPtr & cmp, DB::ModifyCommand * ins) const { - int paramNo = 0; + unsigned int paramNo = 0; cmp->OnEachChild([this, ¶mNo, ins](auto &&, auto && PH2, auto && PH3) { bindObjectAndExecuteField(paramNo, ins, PH2, PH3); }); @@ -109,8 +109,8 @@ namespace Slicer { } void - SqlInsertSerializer::bindObjectAndExecuteField( - int & paramNo, DB::ModifyCommand * ins, const Slicer::ModelPartPtr & cmp, const HookCommon * h) const + SqlInsertSerializer::bindObjectAndExecuteField(unsigned int & paramNo, DB::ModifyCommand * ins, + const Slicer::ModelPartPtr & cmp, const HookCommon * h) const { if (isBind(h)) { if (!cmp->GetValue(SqlBinder(*ins, paramNo))) { @@ -121,8 +121,8 @@ namespace Slicer { } void - SqlAutoIdInsertSerializer::bindObjectAndExecuteField( - int & paramNo, DB::ModifyCommand * ins, const Slicer::ModelPartPtr & cmp, const HookCommon * h) const + SqlAutoIdInsertSerializer::bindObjectAndExecuteField(unsigned int & paramNo, DB::ModifyCommand * ins, + const Slicer::ModelPartPtr & cmp, const HookCommon * h) const { if (isNotAuto(h)) { SqlInsertSerializer::bindObjectAndExecuteField(paramNo, ins, cmp, h); @@ -135,7 +135,7 @@ namespace Slicer { using namespace AdHoc::literals; std::stringstream insert; "INSERT INTO %?("_fmt(insert, tableName); - int fieldNo = 0; + unsigned int fieldNo = 0; mp->OnEachChild([this, &fieldNo, &insert](auto && PH1, auto &&, auto && PH3) { createInsertField(fieldNo, insert, PH1, PH3); }); @@ -149,7 +149,7 @@ namespace Slicer { void SqlInsertSerializer::createInsertField( - int & fieldNo, std::ostream & insert, const std::string & name, const HookCommon * h) const + unsigned int & fieldNo, std::ostream & insert, const std::string & name, const HookCommon * h) const { if (isBind(h)) { if (fieldNo++) { @@ -161,7 +161,7 @@ namespace Slicer { void SqlAutoIdInsertSerializer::createInsertField( - int & fieldNo, std::ostream & insert, const std::string & name, const HookCommon * h) const + unsigned int & fieldNo, std::ostream & insert, const std::string & name, const HookCommon * h) const { if (isNotAuto(h)) { if (fieldNo++) { diff --git a/slicer/db/sqlInsertSerializer.h b/slicer/db/sqlInsertSerializer.h index b964b5e..8a72b68 100644 --- a/slicer/db/sqlInsertSerializer.h +++ b/slicer/db/sqlInsertSerializer.h @@ -18,10 +18,10 @@ namespace Slicer { void SerializeSequence(const Slicer::ModelPartPtr &) const; DB::ModifyCommandPtr createInsert(const Slicer::ModelPartPtr &) const; virtual void createInsertField( - int & fieldNo, std::ostream & insert, const std::string & name, const HookCommon * h) const; + unsigned int & fieldNo, std::ostream & insert, const std::string & name, const HookCommon * h) const; virtual void bindObjectAndExecute(const Slicer::ModelPartPtr &, DB::ModifyCommand *) const; virtual void bindObjectAndExecuteField( - int & paramNo, DB::ModifyCommand *, const Slicer::ModelPartPtr &, const HookCommon *) const; + unsigned int & paramNo, DB::ModifyCommand *, const Slicer::ModelPartPtr &, const HookCommon *) const; DB::Connection * const connection; const std::string tableName; @@ -32,10 +32,10 @@ namespace Slicer { template<typename... P> explicit SqlAutoIdInsertSerializer(const P &... p) : SqlInsertSerializer(p...) { } protected: - virtual void createInsertField( - int & fieldNo, std::ostream & insert, const std::string & name, const HookCommon * h) const override; - virtual void bindObjectAndExecuteField( - int & paramNo, DB::ModifyCommand *, const Slicer::ModelPartPtr &, const HookCommon *) const override; + virtual void createInsertField(unsigned int & fieldNo, std::ostream & insert, const std::string & name, + const HookCommon * h) const override; + virtual void bindObjectAndExecuteField(unsigned int & paramNo, DB::ModifyCommand *, + const Slicer::ModelPartPtr &, const HookCommon *) const override; }; class DLL_PUBLIC SqlFetchIdInsertSerializer : public SqlAutoIdInsertSerializer { diff --git a/slicer/db/sqlUpdateSerializer.cpp b/slicer/db/sqlUpdateSerializer.cpp index 29d9da7..a2de6a7 100644 --- a/slicer/db/sqlUpdateSerializer.cpp +++ b/slicer/db/sqlUpdateSerializer.cpp @@ -1,6 +1,6 @@ +#include "sqlUpdateSerializer.h" #include "sqlBinder.h" #include "sqlCommon.h" -#include "sqlUpdateSerializer.h" #include <common.h> #include <compileTimeFormatter.h> #include <functional> @@ -54,7 +54,7 @@ namespace Slicer { void SqlUpdateSerializer::bindObjectAndExecute(const Slicer::ModelPartPtr & cmp, DB::ModifyCommand * upd) { - int paramNo = 0; + unsigned int paramNo = 0; cmp->OnEachChild([&upd, ¶mNo](const std::string &, const ModelPartPtr & cmp, const HookCommon * h) { if (isValue(h)) { if (!cmp->GetValue(SqlBinder(*upd, paramNo))) { diff --git a/slicer/ice/serializer.cpp b/slicer/ice/serializer.cpp index 8f83352..523b977 100644 --- a/slicer/ice/serializer.cpp +++ b/slicer/ice/serializer.cpp @@ -30,7 +30,7 @@ namespace Slicer { IceStreamSerializer::Serialize(ModelPartForRootPtr mp) { IceBlobSerializer::Serialize(mp); - strm.write(reinterpret_cast<const char *>(blob.data()), blob.size()); + strm.write(reinterpret_cast<const char *>(blob.data()), static_cast<std::streamsize>(blob.size())); } IceBlobDeserializer::IceBlobDeserializer(const Ice::ByteSeq & b) : refblob(b) { } diff --git a/slicer/ice/testSpecifics.cpp b/slicer/ice/testSpecifics.cpp index d24fd00..50742e4 100644 --- a/slicer/ice/testSpecifics.cpp +++ b/slicer/ice/testSpecifics.cpp @@ -43,8 +43,8 @@ BOOST_AUTO_TEST_CASE(builtins) testCompare<Ice::Int>(3434090); testCompare<Ice::Long>(-4000033); testCompare<Ice::Long>(343409898900); - testCompare<Ice::Float>(-3.14); - testCompare<Ice::Float>(3.14); + testCompare<Ice::Float>(-3.14F); + testCompare<Ice::Float>(3.14F); testCompare<Ice::Double>(-3.14159); testCompare<Ice::Double>(3.14159); } @@ -78,8 +78,8 @@ BOOST_AUTO_TEST_CASE(optionalBuiltins) testCompareOptional<Ice::Int>(3434090); testCompareOptional<Ice::Long>(-4000033); testCompareOptional<Ice::Long>(343409898900); - testCompareOptional<Ice::Float>(-3.14); - testCompareOptional<Ice::Float>(3.14); + testCompareOptional<Ice::Float>(-3.14F); + testCompareOptional<Ice::Float>(3.14F); testCompareOptional<Ice::Double>(-3.14159); testCompareOptional<Ice::Double>(3.14159); } @@ -92,7 +92,7 @@ BOOST_AUTO_TEST_CASE(classes) x->mshort = 31434; x->mint = 324324234; x->mlong = 343242342343243; - x->mfloat = 3434.32432; + x->mfloat = 3434.32432F; x->mdouble = 3423423423.42342342343; x->mstring = "sdfsf432423"; testCompare<TestModule::BuiltInsPtr>(x, [](const auto & a, const auto & b) { diff --git a/slicer/test/conversions.cpp b/slicer/test/conversions.cpp index 502975e..ff4371a 100644 --- a/slicer/test/conversions.cpp +++ b/slicer/test/conversions.cpp @@ -2,13 +2,18 @@ #include <boost/numeric/conversion/cast.hpp> #define SHORT(x) boost::numeric_cast<::Ice::Short, int64_t>(x) +inline auto +USHORT(std::integral auto x) +{ + return boost::numeric_cast<unsigned short int>(x); +} namespace Slicer { DLL_PUBLIC boost::posix_time::ptime dateTimeToPTime(const ::TestModule::DateTime & dt) { - return boost::posix_time::ptime(boost::gregorian::date(dt.year, dt.month, dt.day), + return boost::posix_time::ptime(boost::gregorian::date(USHORT(dt.year), USHORT(dt.month), USHORT(dt.day)), boost::posix_time::time_duration(dt.hour, dt.minute, dt.second)); } diff --git a/slicer/tool/icemetadata.cpp b/slicer/tool/icemetadata.cpp index 0d8d7bc..b575707 100644 --- a/slicer/tool/icemetadata.cpp +++ b/slicer/tool/icemetadata.cpp @@ -38,7 +38,7 @@ namespace Slicer { size_t IceMetaData::countSlicerMetaData() const { - return std::count_if(_begin, _end, isSlicerMetaData); + return static_cast<size_t>(std::count_if(_begin, _end, isSlicerMetaData)); } bool |