diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-08-29 15:12:57 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-08-29 15:12:57 +0100 |
commit | 6c7222e071ffe7d20c138faac0da1d708e0a7779 (patch) | |
tree | 86ad5d55f60b42b648fbdfc4183e160aacd5ef6c /lib/output | |
parent | Add -Wuseless-cast (diff) | |
download | mygrate-6c7222e071ffe7d20c138faac0da1d708e0a7779.tar.bz2 mygrate-6c7222e071ffe7d20c138faac0da1d708e0a7779.tar.xz mygrate-6c7222e071ffe7d20c138faac0da1d708e0a7779.zip |
Add -Wold-style-cast
Diffstat (limited to 'lib/output')
-rw-r--r-- | lib/output/pq/pqConn.cpp | 7 | ||||
-rw-r--r-- | lib/output/pq/pqRecordSet.cpp | 8 | ||||
-rw-r--r-- | lib/output/pq/pqStmt.cpp | 6 | ||||
-rw-r--r-- | lib/output/pq/writePqCopyStrm.cpp | 2 |
4 files changed, 12 insertions, 11 deletions
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); }); } } |