summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-08-29 15:12:57 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2021-08-29 15:12:57 +0100
commit6c7222e071ffe7d20c138faac0da1d708e0a7779 (patch)
tree86ad5d55f60b42b648fbdfc4183e160aacd5ef6c /lib
parentAdd -Wuseless-cast (diff)
downloadmygrate-6c7222e071ffe7d20c138faac0da1d708e0a7779.tar.bz2
mygrate-6c7222e071ffe7d20c138faac0da1d708e0a7779.tar.xz
mygrate-6c7222e071ffe7d20c138faac0da1d708e0a7779.zip
Add -Wold-style-cast
Diffstat (limited to 'lib')
-rw-r--r--lib/compileTimeFormatter.h2
-rw-r--r--lib/input/mysqlBindings.cpp3
-rw-r--r--lib/output/pq/pqConn.cpp7
-rw-r--r--lib/output/pq/pqRecordSet.cpp8
-rw-r--r--lib/output/pq/pqStmt.cpp6
-rw-r--r--lib/output/pq/writePqCopyStrm.cpp2
-rw-r--r--lib/row.cpp3
-rw-r--r--lib/streamSupport.cpp3
8 files changed, 18 insertions, 16 deletions
diff --git a/lib/compileTimeFormatter.h b/lib/compileTimeFormatter.h
index 647fb30..7d69d4b 100644
--- a/lib/compileTimeFormatter.h
+++ b/lib/compileTimeFormatter.h
@@ -344,7 +344,7 @@ namespace MyGrate {
static inline void
write(stream & s, Obj * const ptr, const Pn &... pn)
{
- s << std::showbase << std::hex << (long unsigned int)ptr;
+ s << std::showbase << std::hex << static_cast<long unsigned int>(ptr);
s.copyfmt(std::ios(nullptr));
StreamWriter::next(s, pn...);
}
diff --git a/lib/input/mysqlBindings.cpp b/lib/input/mysqlBindings.cpp
index 3895821..089ced5 100644
--- a/lib/input/mysqlBindings.cpp
+++ b/lib/input/mysqlBindings.cpp
@@ -22,7 +22,6 @@ namespace MyGrate::Input {
MYSQL_TIME &
operator<<(MYSQL_TIME & t, const DateTime & dt)
{
- return t << (Date)dt << (Time)dt;
+ return t << static_cast<Date>(dt) << static_cast<Time>(dt);
}
-
}
diff --git a/lib/output/pq/pqConn.cpp b/lib/output/pq/pqConn.cpp
index 983271e..6d89fb7 100644
--- a/lib/output/pq/pqConn.cpp
+++ b/lib/output/pq/pqConn.cpp
@@ -34,7 +34,8 @@ namespace MyGrate::Output::Pq {
PqConn::query(const char * const q, const std::initializer_list<DbValue> & vs)
{
Bindings b {vs};
- ResPtr res {PQexecParams(conn.get(), q, (int)vs.size(), nullptr, b.values.data(), b.lengths.data(), nullptr, 0),
+ ResPtr res {PQexecParams(conn.get(), q, static_cast<int>(vs.size()), nullptr, b.values.data(), b.lengths.data(),
+ nullptr, 0),
&PQclear};
verify<PqErr>(PQresultStatus(res.get()) == PGRES_COMMAND_OK, q, res.get());
}
@@ -72,8 +73,8 @@ namespace MyGrate::Output::Pq {
{nullptr,
[](void * cookie, const char * buf, size_t size) {
auto conn = static_cast<PqConn *>(cookie)->conn.get();
- verify<PqErr>(PQputCopyData(conn, buf, (int)size) == 1, "copy data", conn);
- return (ssize_t)size;
+ verify<PqErr>(PQputCopyData(conn, buf, static_cast<int>(size)) == 1, "copy data", conn);
+ return static_cast<ssize_t>(size);
},
nullptr,
[](void * cookie) {
diff --git a/lib/output/pq/pqRecordSet.cpp b/lib/output/pq/pqRecordSet.cpp
index 4d5349f..9eeb3cd 100644
--- a/lib/output/pq/pqRecordSet.cpp
+++ b/lib/output/pq/pqRecordSet.cpp
@@ -30,12 +30,12 @@ namespace MyGrate::Output::Pq {
DbValue
PqRecordSet::at(std::size_t row, std::size_t col) const
{
- if (PQgetisnull(res.get(), (int)row, (int)col)) {
+ if (PQgetisnull(res.get(), static_cast<int>(row), static_cast<int>(col))) {
return nullptr;
}
- const auto value {PQgetvalue(res.get(), (int)row, (int)col)};
- const auto size {static_cast<size_t>(PQgetlength(res.get(), (int)row, (int)col))};
- const auto type {PQftype(res.get(), (int)col)};
+ const auto value {PQgetvalue(res.get(), static_cast<int>(row), static_cast<int>(col))};
+ const auto size {static_cast<size_t>(PQgetlength(res.get(), static_cast<int>(row), static_cast<int>(col)))};
+ const auto type {PQftype(res.get(), static_cast<int>(col))};
switch (type) {
// case BITOID: TODO bool
// case BOOLOID: TODO bool
diff --git a/lib/output/pq/pqStmt.cpp b/lib/output/pq/pqStmt.cpp
index c6399e4..bb7a79c 100644
--- a/lib/output/pq/pqStmt.cpp
+++ b/lib/output/pq/pqStmt.cpp
@@ -22,8 +22,8 @@ namespace MyGrate::Output::Pq {
PqPrepStmt::execute(const std::span<const DbValue> vs)
{
Bindings b {vs};
- res = {PQexecPrepared(
- conn, name.c_str(), (int)vs.size(), b.values.data(), b.lengths.data(), b.formats.data(), 0),
+ res = {PQexecPrepared(conn, name.c_str(), static_cast<int>(vs.size()), b.values.data(), b.lengths.data(),
+ b.formats.data(), 0),
&PQclear};
verify<PqErr>(PQresultStatus(res.get()) == PGRES_COMMAND_OK || PQresultStatus(res.get()) == PGRES_TUPLES_OK,
name, conn);
@@ -54,7 +54,7 @@ namespace MyGrate::Output::Pq {
return i->second;
}
auto nam {scprintf<"pst%0lx">(c->stmts.size())};
- ResPtr res {PQprepare(c->conn.get(), nam.c_str(), q, (int)n, nullptr), PQclear};
+ ResPtr res {PQprepare(c->conn.get(), nam.c_str(), q, static_cast<int>(n), nullptr), PQclear};
verify<PqErr>(PQresultStatus(res.get()) == PGRES_COMMAND_OK, q, c->conn.get());
return c->stmts.emplace(q, std::move(nam)).first->second;
}
diff --git a/lib/output/pq/writePqCopyStrm.cpp b/lib/output/pq/writePqCopyStrm.cpp
index 984b4fd..9d52a46 100644
--- a/lib/output/pq/writePqCopyStrm.cpp
+++ b/lib/output/pq/writePqCopyStrm.cpp
@@ -84,7 +84,7 @@ namespace MyGrate::Output::Pq {
}()};
fputs("\\\\x", out);
std::for_each(v.begin(), v.end(), [this](auto b) {
- fwrite(hex[(uint8_t)b].data(), 2, 1, out);
+ fwrite(hex[static_cast<uint8_t>(b)].data(), 2, 1, out);
});
}
}
diff --git a/lib/row.cpp b/lib/row.cpp
index ba8045d..54e2728 100644
--- a/lib/row.cpp
+++ b/lib/row.cpp
@@ -21,7 +21,8 @@ namespace MyGrate {
auto colIter {columnFlags.begin()};
for (auto c {0U}; c < tm.column_count; c++) {
if (*colIter) {
- const enum_field_types type {(enum_field_types)(unsigned char)tm.column_types.str[c]};
+ const enum_field_types type {
+ static_cast<enum_field_types>(static_cast<unsigned char>(tm.column_types.str[c]))};
const auto null {*nullIter};
if (null) {
switch (type) {
diff --git a/lib/streamSupport.cpp b/lib/streamSupport.cpp
index 433fb83..f80f2fa 100644
--- a/lib/streamSupport.cpp
+++ b/lib/streamSupport.cpp
@@ -49,7 +49,8 @@ namespace std {
std::ostream &
operator<<(std::ostream & s, const MyGrate::DateTime & dt)
{
- return MyGrate::scprintf<"%? %?">(s, (const MyGrate::Date)dt, (const MyGrate::Time)dt);
+ return MyGrate::scprintf<"%? %?">(
+ s, static_cast<const MyGrate::Date>(dt), static_cast<const MyGrate::Time>(dt));
}
std::ostream &