summaryrefslogtreecommitdiff
path: root/libmysqlpp
diff options
context:
space:
mode:
Diffstat (limited to 'libmysqlpp')
-rw-r--r--libmysqlpp/Jamfile.jam15
-rw-r--r--libmysqlpp/my-column.cpp4
-rw-r--r--libmysqlpp/my-column.h3
-rw-r--r--libmysqlpp/my-command.cpp16
-rw-r--r--libmysqlpp/my-command.h3
-rw-r--r--libmysqlpp/my-connection.cpp16
-rw-r--r--libmysqlpp/my-connection.h3
-rw-r--r--libmysqlpp/my-error.h3
-rw-r--r--libmysqlpp/my-mock.cpp2
-rw-r--r--libmysqlpp/my-modifycommand.cpp4
-rw-r--r--libmysqlpp/unittests/testmysql.cpp8
11 files changed, 51 insertions, 26 deletions
diff --git a/libmysqlpp/Jamfile.jam b/libmysqlpp/Jamfile.jam
index 6ddd57d..8894db4 100644
--- a/libmysqlpp/Jamfile.jam
+++ b/libmysqlpp/Jamfile.jam
@@ -16,6 +16,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
<toolset>tidy:<xcheckxx>misc-non-private-member-variables-in-classes
;
diff --git a/libmysqlpp/my-column.cpp b/libmysqlpp/my-column.cpp
index c205439..4a5cdbf 100644
--- a/libmysqlpp/my-column.cpp
+++ b/libmysqlpp/my-column.cpp
@@ -89,7 +89,9 @@ namespace MySQL {
h.null();
}
else {
- h.timestamp(boost::posix_time::ptime(boost::gregorian::date(value.year, value.month, value.day),
+ h.timestamp(boost::posix_time::ptime(
+ boost::gregorian::date(static_cast<short unsigned int>(value.year),
+ static_cast<short unsigned int>(value.month), static_cast<short unsigned int>(value.day)),
boost::posix_time::time_duration(value.hour, value.minute, value.second)
+ boost::posix_time::microseconds(value.second_part)));
}
diff --git a/libmysqlpp/my-column.h b/libmysqlpp/my-column.h
index 2726830..966216c 100644
--- a/libmysqlpp/my-column.h
+++ b/libmysqlpp/my-column.h
@@ -2,7 +2,10 @@
#define MY_COLUMN_H
#include <column.h>
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wold-style-cast"
#include <mysql.h>
+#pragma GCC diagnostic pop
namespace MySQL {
class SelectCommand;
diff --git a/libmysqlpp/my-command.cpp b/libmysqlpp/my-command.cpp
index 7e7275a..114e526 100644
--- a/libmysqlpp/my-command.cpp
+++ b/libmysqlpp/my-command.cpp
@@ -124,10 +124,10 @@ MySQL::Command::bindParamT(unsigned int n, const boost::posix_time::ptime & v)
ts.year = v.date().year();
ts.month = v.date().month();
ts.day = v.date().day();
- ts.hour = v.time_of_day().hours();
- ts.minute = v.time_of_day().minutes();
- ts.second = v.time_of_day().seconds();
- ts.second_part = v.time_of_day().total_microseconds() % 1000000;
+ ts.hour = static_cast<unsigned int>(v.time_of_day().hours());
+ ts.minute = static_cast<unsigned int>(v.time_of_day().minutes());
+ ts.second = static_cast<unsigned int>(v.time_of_day().seconds());
+ ts.second_part = static_cast<long unsigned int>(v.time_of_day().total_microseconds() % 1000000U);
ts.neg = false;
}
void
@@ -140,10 +140,10 @@ MySQL::Command::bindParamT(unsigned int n, const boost::posix_time::time_duratio
ts.year = 0;
ts.month = 0;
ts.day = 0;
- ts.hour = v.hours();
- ts.minute = v.minutes();
- ts.second = v.seconds();
- ts.second_part = v.total_microseconds() % 1000000;
+ ts.hour = static_cast<unsigned int>(v.hours());
+ ts.minute = static_cast<unsigned int>(v.minutes());
+ ts.second = static_cast<unsigned int>(v.seconds());
+ ts.second_part = static_cast<long unsigned int>(v.total_microseconds() % 1000000U);
ts.neg = (v.is_negative() ? 1 : 0);
}
void
diff --git a/libmysqlpp/my-command.h b/libmysqlpp/my-command.h
index 1161b77..87347cf 100644
--- a/libmysqlpp/my-command.h
+++ b/libmysqlpp/my-command.h
@@ -2,7 +2,10 @@
#define MY_COMMAND_H
#include <command.h>
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wold-style-cast"
#include <mysql.h>
+#pragma GCC diagnostic pop
#include <vector>
namespace MySQL {
diff --git a/libmysqlpp/my-connection.cpp b/libmysqlpp/my-connection.cpp
index 5828986..22ba809 100644
--- a/libmysqlpp/my-connection.cpp
+++ b/libmysqlpp/my-connection.cpp
@@ -8,22 +8,18 @@
#include <runtimeContext.h>
#include <ucontext.h>
-NAMEDFACTORY("mysql", MySQL::Connection, DB::ConnectionFactory);
+NAMEDFACTORY("mysql", MySQL::Connection, DB::ConnectionFactory)
MySQL::ConnectionError::ConnectionError(MYSQL * m) : MySQL::Error(m) { }
class Opts {
public:
- Opts()
- {
- port = 3306;
- }
using OptString = std::optional<std::string>;
OptString server;
OptString user;
OptString password;
OptString database;
- unsigned int port;
+ unsigned int port {3306};
OptString unix_socket;
OptString options;
};
@@ -158,13 +154,13 @@ namespace MySQL {
ctx->swapContext();
if (ctx->loadBufLen == ctx->bufOff) {
// Nothing to do or error
- return ctx->bufOff;
+ return static_cast<int>(ctx->bufOff);
}
}
auto copy = std::min<size_t>(ctx->loadBufLen - ctx->bufOff, bufSize);
memcpy(buf, ctx->loadBuf + ctx->bufOff, copy);
ctx->bufOff += copy;
- return copy;
+ return static_cast<int>(copy);
}
static void
@@ -215,7 +211,7 @@ MySQL::Connection::endBulkUpload(const char * msg)
}
ctx->loadBuf = nullptr;
ctx->loadBufLen = 0;
- ctx->bufOff = msg ? -1 : 0;
+ ctx->bufOff = msg ? static_cast<size_t>(-1) : 0;
// switch context with empty buffer fires finished
ctx->swapContext();
// Check result
@@ -245,5 +241,5 @@ MySQL::Connection::bulkUploadData(const char * data, size_t len) const
int64_t
MySQL::Connection::insertId()
{
- return mysql_insert_id(&conn);
+ return static_cast<int64_t>(mysql_insert_id(&conn));
}
diff --git a/libmysqlpp/my-connection.h b/libmysqlpp/my-connection.h
index 184dafe..f0edacc 100644
--- a/libmysqlpp/my-connection.h
+++ b/libmysqlpp/my-connection.h
@@ -4,7 +4,10 @@
#include "my-error.h"
#include <connection.h>
#include <memory>
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wold-style-cast"
#include <mysql.h>
+#pragma GCC diagnostic pop
namespace MySQL {
class ConnectionError : public virtual Error, public virtual DB::ConnectionError {
diff --git a/libmysqlpp/my-error.h b/libmysqlpp/my-error.h
index 85fff63..2dfc99b 100644
--- a/libmysqlpp/my-error.h
+++ b/libmysqlpp/my-error.h
@@ -3,7 +3,10 @@
#include <error.h>
#include <exception.h>
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wold-style-cast"
#include <mysql.h>
+#pragma GCC diagnostic pop
namespace MySQL {
class Error : public AdHoc::Exception<DB::Error> {
diff --git a/libmysqlpp/my-mock.cpp b/libmysqlpp/my-mock.cpp
index 52d4899..27e9df2 100644
--- a/libmysqlpp/my-mock.cpp
+++ b/libmysqlpp/my-mock.cpp
@@ -2,7 +2,7 @@
#include "my-connection.h"
#include <compileTimeFormatter.h>
-NAMEDFACTORY("mysql", MySQL::Mock, DB::MockDatabaseFactory);
+NAMEDFACTORY("mysql", MySQL::Mock, DB::MockDatabaseFactory)
namespace MySQL {
diff --git a/libmysqlpp/my-modifycommand.cpp b/libmysqlpp/my-modifycommand.cpp
index dd607b3..9714638 100644
--- a/libmysqlpp/my-modifycommand.cpp
+++ b/libmysqlpp/my-modifycommand.cpp
@@ -15,9 +15,9 @@ MySQL::ModifyCommand::execute(bool anc)
if (mysql_stmt_execute(stmt.get())) {
throw Error(stmt.get());
}
- int rows = mysql_stmt_affected_rows(stmt.get());
+ auto rows = mysql_stmt_affected_rows(stmt.get());
if (rows == 0 && !anc) {
throw DB::NoRowsAffected();
}
- return rows;
+ return static_cast<unsigned int>(rows);
}
diff --git a/libmysqlpp/unittests/testmysql.cpp b/libmysqlpp/unittests/testmysql.cpp
index 2f60e68..fdfb0a8 100644
--- a/libmysqlpp/unittests/testmysql.cpp
+++ b/libmysqlpp/unittests/testmysql.cpp
@@ -21,7 +21,7 @@ public:
BOOST_GLOBAL_FIXTURE(StandardMockDatabase);
-BOOST_FIXTURE_TEST_SUITE(Core, DB::TestCore);
+BOOST_FIXTURE_TEST_SUITE(Core, DB::TestCore)
BOOST_AUTO_TEST_CASE(transactions)
{
@@ -111,7 +111,7 @@ BOOST_AUTO_TEST_CASE(bulkload)
}
std::array<char, BUFSIZ> buf {};
for (std::streamsize r; (r = in.readsome(buf.data(), buf.size())) > 0;) {
- ro->bulkUploadData(buf.data(), r);
+ ro->bulkUploadData(buf.data(), static_cast<size_t>(r));
}
ro->endBulkUpload(nullptr);
assertScalarValueHelper(*count, 800);
@@ -133,7 +133,7 @@ BOOST_AUTO_TEST_CASE(insertId)
{
auto ro = DB::MockDatabase::openConnectionTo("mysqlmock");
auto ins = ro->modify("INSERT INTO inserts(num) VALUES(?)");
- int prevId = 0;
+ int64_t prevId = 0;
for (int n : {4, 40, -4}) {
ins->bindParamI(0, n);
ins->execute();
@@ -150,4 +150,4 @@ BOOST_AUTO_TEST_CASE(errors)
BOOST_REQUIRE_THROW((void)DB::ConnectionFactory::createNew("mysql", "server=nohost"), DB::ConnectionError);
}
-BOOST_AUTO_TEST_SUITE_END();
+BOOST_AUTO_TEST_SUITE_END()