From 810896c94c9a1d9d1853ca19979b87027974b51b Mon Sep 17 00:00:00 2001 From: An Tao Date: Sun, 1 Mar 2020 11:50:47 +0800 Subject: [PATCH] Fix warnings on Windows (#368) --- drogon_ctl/create_model.cc | 8 +++-- drogon_ctl/create_model.h | 5 ++- drogon_ctl/create_project.cc | 10 +++++- drogon_ctl/press.cc | 2 +- lib/inc/drogon/CacheMap.h | 8 ++--- lib/inc/drogon/DrObject.h | 4 +++ lib/src/CacheFile.cc | 15 ++++++++ lib/src/ConfigLoader.cc | 6 +++- lib/src/HttpAppFrameworkImpl.cc | 10 ++++-- lib/src/HttpControllersRouter.cc | 3 +- lib/src/HttpResponseImpl.cc | 13 ++++--- lib/src/HttpServer.cc | 4 +-- lib/src/HttpSimpleControllersRouter.cc | 3 +- lib/src/Utilities.cc | 39 ++++++++++++--------- lib/src/WebSocketConnectionImpl.cc | 8 +++-- orm_lib/inc/drogon/orm/Field.h | 25 +------------ orm_lib/inc/drogon/orm/Row.h | 2 +- orm_lib/inc/drogon/orm/SqlBinder.h | 29 +++++++++++++-- orm_lib/src/SqlBinder.cc | 8 ++--- orm_lib/src/postgresql_impl/PgConnection.cc | 8 ++--- trantor | 2 +- 21 files changed, 132 insertions(+), 80 deletions(-) diff --git a/drogon_ctl/create_model.cc b/drogon_ctl/create_model.cc index a56ce6a7..ddeebca7 100644 --- a/drogon_ctl/create_model.cc +++ b/drogon_ctl/create_model.cc @@ -116,7 +116,7 @@ void create_model::createModelClassFromPG( << std::endl; return; } - for (size_t i = 0; i < r.size(); ++i) + for (Result::SizeType i = 0; i < r.size(); ++i) { auto row = r[i]; ColumnInfo info; @@ -977,13 +977,17 @@ void create_model::createModel(const std::string &path, closedir(dp); #endif auto configFile = path + "/model.json"; +#ifdef _WIN32 + if (_access(configFile.c_str(), 0) != 0) +#else if (access(configFile.c_str(), 0) != 0) +#endif { std::cerr << "Config file " << configFile << " not found!" << std::endl; exit(1); } #ifdef _WIN32 - if (access(configFile.c_str(), 04) != 0) + if (_access(configFile.c_str(), 04) != 0) #else if (access(configFile.c_str(), R_OK) != 0) #endif diff --git a/drogon_ctl/create_model.h b/drogon_ctl/create_model.h index 7776a346..d340cb37 100644 --- a/drogon_ctl/create_model.h +++ b/drogon_ctl/create_model.h @@ -150,7 +150,10 @@ class Relationship else { char message[128]; - sprintf(message, "Invalid relationship type: %s", type.data()); + snprintf(message, + sizeof(message), + "Invalid relationship type: %s", + type.data()); throw std::runtime_error(message); } originalTableName_ = diff --git a/drogon_ctl/create_project.cc b/drogon_ctl/create_project.cc index 9979d223..0ce72cbf 100644 --- a/drogon_ctl/create_project.cc +++ b/drogon_ctl/create_project.cc @@ -69,7 +69,11 @@ static void newModelConfigFile(std::ofstream &configFile) } void create_project::createProject(const std::string &projectName) { +#ifdef _WIN32 + if (_access(projectName.data(), 0) == 0) +#else if (access(projectName.data(), 0) == 0) +#endif { std::cerr << "The directory already exists, please use another project name!" @@ -79,8 +83,12 @@ void create_project::createProject(const std::string &projectName) std::cout << "create a project named " << projectName << std::endl; drogon::utils::createPath(projectName); - // 1.create CMakeLists.txt +// 1.create CMakeLists.txt +#ifdef _WIN32 + auto r = _chdir(projectName.data()); +#else auto r = chdir(projectName.data()); +#endif (void)(r); std::ofstream cmakeFile("CMakeLists.txt", std::ofstream::out); newCmakeFile(cmakeFile, projectName); diff --git a/drogon_ctl/press.cc b/drogon_ctl/press.cc index d379eb3f..725852d9 100644 --- a/drogon_ctl/press.cc +++ b/drogon_ctl/press.cc @@ -294,7 +294,7 @@ void press::outputResults() auto microSecs = now.microSecondsSinceEpoch() - statistics_.startDate_.microSecondsSinceEpoch(); double seconds = (double)microSecs / 1000000.0; - size_t rps = statistics_.numOfGoodResponse_ / seconds; + size_t rps = static_cast(statistics_.numOfGoodResponse_ / seconds); std::cout << std::endl; std::cout << "TOTALS: " << numOfConnections_ << " connect, " << numOfRequests_ << " requests, " diff --git a/lib/inc/drogon/CacheMap.h b/lib/inc/drogon/CacheMap.h index 6a5b6f1d..34c92aef 100644 --- a/lib/inc/drogon/CacheMap.h +++ b/lib/inc/drogon/CacheMap.h @@ -133,9 +133,9 @@ class CacheMap } { std::lock_guard lock(bucketMutex_); - for (int i = wheels_.size() - 1; i >= 0; --i) + for (auto iter = wheels_.rbegin(); iter != wheels_.rend(); ++iter) { - wheels_[i].clear(); + iter->clear(); } } LOG_TRACE << "CacheMap destruct!"; @@ -265,7 +265,7 @@ class CacheMap */ bool findAndFetch(const T1 &key, T2 &value) { - int timeout = 0; + size_t timeout = 0; bool flag = false; std::lock_guard lock(mtx_); auto iter = map_.find(key); @@ -326,7 +326,7 @@ class CacheMap // protected by bucketMutex; if (delay <= 0) return; - delay = delay / tickInterval_ + 1; + delay = static_cast(delay / tickInterval_ + 1); size_t t = ticksCounter_; for (size_t i = 0; i < wheelsNumber_; ++i) { diff --git a/lib/inc/drogon/DrObject.h b/lib/inc/drogon/DrObject.h index ef31465a..1d305f98 100644 --- a/lib/inc/drogon/DrObject.h +++ b/lib/inc/drogon/DrObject.h @@ -19,6 +19,10 @@ #include #include +#ifdef _MSC_VER +#pragma warning(disable : 4250) +#endif + namespace drogon { /** diff --git a/lib/src/CacheFile.cc b/lib/src/CacheFile.cc index 6b1d159d..a8de675d 100644 --- a/lib/src/CacheFile.cc +++ b/lib/src/CacheFile.cc @@ -26,7 +26,14 @@ using namespace drogon; CacheFile::CacheFile(const std::string &path, bool autoDelete) : autoDelete_(autoDelete), path_(path) { +#ifndef _MSC_VER file_ = fopen(path_.data(), "wb+"); +#else + if (fopen_s(&file_, path_.data(), "wb+") != 0) + { + file_ = nullptr; + } +#endif } CacheFile::~CacheFile() @@ -38,7 +45,11 @@ CacheFile::~CacheFile() if (autoDelete_ && file_) { fclose(file_); +#ifdef _WIN32 + _unlink(path_.data()); +#else unlink(path_.data()); +#endif } else if (file_) { @@ -66,7 +77,11 @@ char *CacheFile::data() if (!data_) { fflush(file_); +#ifdef _WIN32 + auto fd = _fileno(file_); +#else auto fd = fileno(file_); +#endif dataLength_ = length(); data_ = static_cast( mmap(nullptr, dataLength_, PROT_READ, MAP_SHARED, fd, 0)); diff --git a/lib/src/ConfigLoader.cc b/lib/src/ConfigLoader.cc index d5cf2e3e..6794e7d4 100644 --- a/lib/src/ConfigLoader.cc +++ b/lib/src/ConfigLoader.cc @@ -94,13 +94,17 @@ static bool bytesSize(std::string &sizeStr, size_t &size) } ConfigLoader::ConfigLoader(const std::string &configFile) { +#ifdef _WIN32 + if (_access(configFile.c_str(), 0) != 0) +#else if (access(configFile.c_str(), 0) != 0) +#endif { std::cerr << "Config file " << configFile << " not found!" << std::endl; exit(1); } #ifdef _WIN32 - if (access(configFile.c_str(), 04) != 0) + if (_access(configFile.c_str(), 04) != 0) #else if (access(configFile.c_str(), R_OK) != 0) #endif diff --git a/lib/src/HttpAppFrameworkImpl.cc b/lib/src/HttpAppFrameworkImpl.cc index a32779a7..d75c125f 100644 --- a/lib/src/HttpAppFrameworkImpl.cc +++ b/lib/src/HttpAppFrameworkImpl.cc @@ -320,13 +320,17 @@ HttpAppFramework &HttpAppFrameworkImpl::setLogPath( { if (logPath == "") return *this; +#ifdef _WIN32 + if (_access(logPath.c_str(), 0) != 0) +#else if (access(logPath.c_str(), 0) != 0) +#endif { std::cerr << "Log path dose not exist!\n"; exit(1); } #ifdef _WIN32 - if (access(logPath.c_str(), 06) != 0) + if (_access(logPath.c_str(), 06) != 0) #else if (access(logPath.c_str(), R_OK | W_OK) != 0) #endif @@ -362,7 +366,7 @@ void HttpAppFrameworkImpl::run() for (int i = 0; i < 256; ++i) { char dirName[4]; - sprintf(dirName, "%02x", i); + snprintf(dirName, sizeof(dirName), "%02x", i); std::transform(dirName, dirName + 2, dirName, toupper); utils::createPath(getUploadPath() + "/tmp/" + dirName); } @@ -405,7 +409,7 @@ void HttpAppFrameworkImpl::run() if (!logPath_.empty()) { #ifdef _WIN32 - if (access(logPath_.c_str(), 06) != 0) + if (_access(logPath_.c_str(), 06) != 0) #else if (access(logPath_.c_str(), R_OK | W_OK) != 0) #endif diff --git a/lib/src/HttpControllersRouter.cc b/lib/src/HttpControllersRouter.cc index 8ea90b64..59df70ed 100644 --- a/lib/src/HttpControllersRouter.cc +++ b/lib/src/HttpControllersRouter.cc @@ -540,7 +540,8 @@ void HttpControllersRouter::doControllerHandler( { if (responsePtr->expiredTime() == 0 || (trantor::Date::now() < - responsePtr->creationDate().after(responsePtr->expiredTime()))) + responsePtr->creationDate().after( + static_cast(responsePtr->expiredTime())))) { // use cached response! LOG_TRACE << "Use cached response"; diff --git a/lib/src/HttpResponseImpl.cc b/lib/src/HttpResponseImpl.cc index a6b198d6..9cd53cb3 100644 --- a/lib/src/HttpResponseImpl.cc +++ b/lib/src/HttpResponseImpl.cc @@ -225,13 +225,13 @@ void HttpResponseImpl::makeHeaderString( { if (sendfileName_.empty()) { - long unsigned int bodyLength = + size_t bodyLength = bodyPtr_ ? bodyPtr_->length() : (bodyViewPtr_ ? bodyViewPtr_->length() : 0); len = snprintf(buf, sizeof buf, "Content-Length: %lu\r\n", - bodyLength); + static_cast(bodyLength)); } else { @@ -311,13 +311,13 @@ void HttpResponseImpl::renderToBuffer(trantor::MsgBuffer &buffer) { if (sendfileName_.empty()) { - long unsigned int bodyLength = + auto bodyLength = bodyPtr_ ? bodyPtr_->length() : (bodyViewPtr_ ? bodyViewPtr_->length() : 0); len = snprintf(buf, sizeof buf, "Content-Length: %lu\r\n", - bodyLength); + static_cast(bodyLength)); } else { @@ -329,9 +329,8 @@ void HttpResponseImpl::renderToBuffer(trantor::MsgBuffer &buffer) } len = snprintf(buf, sizeof buf, - "Content-Length: %llu\r\n", - static_cast( - filestat.st_size)); + "Content-Length: %lu\r\n", + static_cast(filestat.st_size)); } buffer.append(buf, len); diff --git a/lib/src/HttpServer.cc b/lib/src/HttpServer.cc index d9b4b0e4..d758b06c 100644 --- a/lib/src/HttpServer.cc +++ b/lib/src/HttpServer.cc @@ -340,7 +340,7 @@ void HttpServer::onRequests( { /* * A client that supports persistent connections MAY - * “pipeline” its requests (i.e., send multiple requests + * "pipeline" its requests (i.e., send multiple requests * without waiting for each response). A server MUST send * its responses to those requests in the same order that * the requests were received. rfc2616-8.1.1.2 @@ -524,4 +524,4 @@ void HttpServer::sendResponses( conn->send(buffer); } buffer.retrieveAll(); -} +} \ No newline at end of file diff --git a/lib/src/HttpSimpleControllersRouter.cc b/lib/src/HttpSimpleControllersRouter.cc index 3eaf1630..f7a942f4 100644 --- a/lib/src/HttpSimpleControllersRouter.cc +++ b/lib/src/HttpSimpleControllersRouter.cc @@ -203,7 +203,8 @@ void HttpSimpleControllersRouter::doControllerHandler( { if (responsePtr->expiredTime() == 0 || (trantor::Date::now() < - responsePtr->creationDate().after(responsePtr->expiredTime()))) + responsePtr->creationDate().after( + static_cast(responsePtr->expiredTime())))) { // use cached response! LOG_TRACE << "Use cached response"; diff --git a/lib/src/Utilities.cc b/lib/src/Utilities.cc index 4979c2f6..128afa59 100644 --- a/lib/src/Utilities.cc +++ b/lib/src/Utilities.cc @@ -69,9 +69,11 @@ std::string genRandomString(int length) static const char char_space[] = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; static std::once_flag once; - static const int len = strlen(char_space); - static const int randMax = RAND_MAX - (RAND_MAX % len); - std::call_once(once, []() { std::srand(time(nullptr)); }); + static const size_t len = strlen(char_space); + static const size_t randMax = RAND_MAX - (RAND_MAX % len); + std::call_once(once, []() { + std::srand(static_cast(time(nullptr))); + }); int i; std::string str; @@ -381,7 +383,7 @@ std::string base64Encode(const unsigned char *bytes_to_encode, std::vector base64DecodeToVector(const std::string &encoded_string) { - int in_len = encoded_string.size(); + auto in_len = encoded_string.size(); int i = 0; int in_{0}; char char_array_4[4], char_array_3[3]; @@ -396,7 +398,8 @@ std::vector base64DecodeToVector(const std::string &encoded_string) if (i == 4) { for (i = 0; i < 4; ++i) - char_array_4[i] = base64Chars.find(char_array_4[i]); + char_array_4[i] = + static_cast(base64Chars.find(char_array_4[i])); char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); @@ -416,7 +419,8 @@ std::vector base64DecodeToVector(const std::string &encoded_string) char_array_4[j] = 0; for (int j = 0; j < 4; ++j) - char_array_4[j] = base64Chars.find(char_array_4[j]); + char_array_4[j] = + static_cast(base64Chars.find(char_array_4[j])); char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); @@ -433,7 +437,7 @@ std::vector base64DecodeToVector(const std::string &encoded_string) std::string base64Decode(const std::string &encoded_string) { - int in_len = encoded_string.size(); + auto in_len = encoded_string.size(); int i = 0; int in_{0}; unsigned char char_array_4[4], char_array_3[3]; @@ -447,7 +451,8 @@ std::string base64Decode(const std::string &encoded_string) if (i == 4) { for (i = 0; i < 4; ++i) - char_array_4[i] = base64Chars.find(char_array_4[i]); + char_array_4[i] = static_cast( + base64Chars.find(char_array_4[i])); char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); @@ -467,7 +472,8 @@ std::string base64Decode(const std::string &encoded_string) char_array_4[j] = 0; for (int j = 0; j < 4; ++j) - char_array_4[j] = base64Chars.find(char_array_4[j]); + char_array_4[j] = + static_cast(base64Chars.find(char_array_4[j])); char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); @@ -778,9 +784,9 @@ std::string gzipCompress(const char *data, const size_t ndata) return std::string{}; } std::string outstr; - outstr.resize(compressBound(ndata)); + outstr.resize(compressBound(static_cast(ndata))); strm.next_in = (Bytef *)data; - strm.avail_in = ndata; + strm.avail_in = static_cast(ndata); int ret; do { @@ -789,7 +795,7 @@ std::string gzipCompress(const char *data, const size_t ndata) outstr.resize(strm.total_out * 2); } assert(outstr.size() >= strm.total_out); - strm.avail_out = outstr.size() - strm.total_out; + strm.avail_out = static_cast(outstr.size() - strm.total_out); strm.next_out = (Bytef *)outstr.data() + strm.total_out; ret = deflate(&strm, Z_FINISH); /* no bad return value */ if (ret == Z_STREAM_ERROR) @@ -820,7 +826,7 @@ std::string gzipDecompress(const char *data, const size_t ndata) z_stream strm = {0}; strm.next_in = (Bytef *)data; - strm.avail_in = ndata; + strm.avail_in = static_cast(ndata); strm.total_out = 0; strm.zalloc = Z_NULL; strm.zfree = Z_NULL; @@ -837,7 +843,8 @@ std::string gzipDecompress(const char *data, const size_t ndata) decompressed.resize(decompressed.length() * 2); } strm.next_out = (Bytef *)decompressed.data() + strm.total_out; - strm.avail_out = decompressed.length() - strm.total_out; + strm.avail_out = + static_cast(decompressed.length() - strm.total_out); // Inflate another chunk. int status = inflate(&strm, Z_SYNC_FLUSH); if (status == Z_STREAM_END) @@ -938,7 +945,7 @@ int createPath(const std::string &path) auto tmpPath = path; std::stack pathStack; #ifdef _WIN32 - while (access(tmpPath.c_str(), 06) != 0) + while (_access(tmpPath.c_str(), 06) != 0) #else while (access(tmpPath.c_str(), F_OK) != 0) #endif @@ -980,7 +987,7 @@ int createPath(const std::string &path) pathStack.pop(); #ifdef _WIN32 - if (mkdir(tmpPath.c_str()) == -1) + if (_mkdir(tmpPath.c_str()) == -1) #else if (mkdir(tmpPath.c_str(), 0755) == -1) #endif diff --git a/lib/src/WebSocketConnectionImpl.cc b/lib/src/WebSocketConnectionImpl.cc index a162a58b..4a2143dd 100644 --- a/lib/src/WebSocketConnectionImpl.cc +++ b/lib/src/WebSocketConnectionImpl.cc @@ -75,7 +75,7 @@ void WebSocketConnectionImpl::sendWsData(const char *msg, if (len <= 125) { - bytesFormatted[1] = len; + bytesFormatted[1] = static_cast(len); indexStartRawData = 2; } else if (len <= 65535) @@ -105,7 +105,9 @@ void WebSocketConnectionImpl::sendWsData(const char *msg, { // Add masking key; static std::once_flag once; - std::call_once(once, []() { std::srand(time(nullptr)); }); + std::call_once(once, []() { + std::srand(static_cast(time(nullptr))); + }); int random = std::rand(); bytesFormatted[1] = (bytesFormatted[1] | 0x80); @@ -278,7 +280,7 @@ bool WebSocketMessageParser::parse(trantor::MsgBuffer *buffer) if (buffer->readableBytes() >= (indexFirstMask + 4 + length)) { auto masks = buffer->peek() + indexFirstMask; - int indexFirstDataByte = indexFirstMask + 4; + auto indexFirstDataByte = indexFirstMask + 4; auto rawData = buffer->peek() + indexFirstDataByte; auto oldLen = message_.length(); message_.resize(oldLen + length); diff --git a/orm_lib/inc/drogon/orm/Field.h b/orm_lib/inc/drogon/orm/Field.h index 21db23ab..8dce4316 100644 --- a/orm_lib/inc/drogon/orm/Field.h +++ b/orm_lib/inc/drogon/orm/Field.h @@ -30,29 +30,6 @@ #include #endif -#if (defined __linux__) | (defined __MINGW32__) -inline uint64_t ntohll(const uint64_t &input) -{ - uint64_t rval; - uint8_t *data = (uint8_t *)&rval; - - data[0] = input >> 56; - data[1] = input >> 48; - data[2] = input >> 40; - data[3] = input >> 32; - data[4] = input >> 24; - data[5] = input >> 16; - data[6] = input >> 8; - data[7] = input >> 0; - - return rval; -} - -inline uint64_t htonll(const uint64_t &input) -{ - return (ntohll(input)); -} -#endif namespace drogon { namespace orm @@ -202,7 +179,7 @@ inline float Field::as() const { if (isNull()) return 0.0; - return atof(result_.getValue(row_, column_)); + return std::stof(result_.getValue(row_, column_)); } template <> diff --git a/orm_lib/inc/drogon/orm/Row.h b/orm_lib/inc/drogon/orm/Row.h index f8ea15e8..7f5400a6 100644 --- a/orm_lib/inc/drogon/orm/Row.h +++ b/orm_lib/inc/drogon/orm/Row.h @@ -84,7 +84,7 @@ class Row * are related to regular iterators, it must be allowed to underflow to -1. */ long index_{0}; - size_t end_{0}; + Row::SizeType end_{0}; friend class Result; Row(const Result &r, SizeType index) noexcept; }; diff --git a/orm_lib/inc/drogon/orm/SqlBinder.h b/orm_lib/inc/drogon/orm/SqlBinder.h index e2b0e59d..dd459654 100644 --- a/orm_lib/inc/drogon/orm/SqlBinder.h +++ b/orm_lib/inc/drogon/orm/SqlBinder.h @@ -33,6 +33,29 @@ #include #endif +#ifdef __linux__ +#include // __BYTE_ORDER __LITTLE_ENDIAN +#include // std::reverse() + +template +constexpr T htonT(T value) noexcept +{ +#if __BYTE_ORDER == __LITTLE_ENDIAN + char *ptr = reinterpret_cast(&value); + std::reverse(ptr, ptr + sizeof(T)); +#endif + return value; +} +inline uint64_t htonll(uint64_t value) +{ + return htonT(value); +} +inline uint64_t ntohll(uint64_t value) +{ + return htonll(value); +} +#endif + namespace drogon { namespace orm @@ -307,13 +330,13 @@ class SqlBinder switch (sizeof(T)) { case 2: - *std::static_pointer_cast(obj) = ntohs(parameter); + *std::static_pointer_cast(obj) = htons(parameter); break; case 4: - *std::static_pointer_cast(obj) = ntohl(parameter); + *std::static_pointer_cast(obj) = htonl(parameter); break; case 8: - *std::static_pointer_cast(obj) = ntohll(parameter); + *std::static_pointer_cast(obj) = htonll(parameter); break; case 1: default: diff --git a/orm_lib/src/SqlBinder.cc b/orm_lib/src/SqlBinder.cc index 800cae40..f429d2f5 100644 --- a/orm_lib/src/SqlBinder.cc +++ b/orm_lib/src/SqlBinder.cc @@ -137,7 +137,7 @@ SqlBinder &SqlBinder::operator<<(const std::string &str) objs_.push_back(obj); ++parametersNumber_; parameters_.push_back((char *)obj->c_str()); - lengths_.push_back(obj->length()); + lengths_.push_back(static_cast(obj->length())); if (type_ == ClientType::PostgreSQL) { formats_.push_back(0); @@ -162,7 +162,7 @@ SqlBinder &SqlBinder::operator<<(std::string &&str) objs_.push_back(obj); ++parametersNumber_; parameters_.push_back((char *)obj->c_str()); - lengths_.push_back(obj->length()); + lengths_.push_back(static_cast(obj->length())); if (type_ == ClientType::PostgreSQL) { formats_.push_back(0); @@ -187,7 +187,7 @@ SqlBinder &SqlBinder::operator<<(const std::vector &v) objs_.push_back(obj); ++parametersNumber_; parameters_.push_back((char *)obj->data()); - lengths_.push_back(obj->size()); + lengths_.push_back(static_cast(obj->size())); if (type_ == ClientType::PostgreSQL) { formats_.push_back(1); @@ -211,7 +211,7 @@ SqlBinder &SqlBinder::operator<<(std::vector &&v) objs_.push_back(obj); ++parametersNumber_; parameters_.push_back((char *)obj->data()); - lengths_.push_back(obj->size()); + lengths_.push_back(static_cast(obj->size())); if (type_ == ClientType::PostgreSQL) { formats_.push_back(1); diff --git a/orm_lib/src/postgresql_impl/PgConnection.cc b/orm_lib/src/postgresql_impl/PgConnection.cc index 5c4f7701..79c83c22 100644 --- a/orm_lib/src/postgresql_impl/PgConnection.cc +++ b/orm_lib/src/postgresql_impl/PgConnection.cc @@ -232,7 +232,7 @@ void PgConnection::execSqlInLoop( isRreparingStatement_ = false; if (PQsendQueryPrepared(connectionPtr_.get(), iter->second.c_str(), - paraNum, + static_cast(paraNum), parameters.data(), length.data(), format.data(), @@ -258,8 +258,8 @@ void PgConnection::execSqlInLoop( if (PQsendPrepare(connectionPtr_.get(), statementName_.c_str(), sql_.data(), - paraNum, - NULL) == 0) + static_cast(paraNum), + nullptr) == 0) { LOG_ERROR << "send query error: " << PQerrorMessage(connectionPtr_.get()); @@ -272,7 +272,7 @@ void PgConnection::execSqlInLoop( } return; } - parametersNumber_ = paraNum; + parametersNumber_ = static_cast(paraNum); parameters_ = std::move(parameters); lengths_ = std::move(length); formats_ = std::move(format); diff --git a/trantor b/trantor index f9a4de58..b46138e0 160000 --- a/trantor +++ b/trantor @@ -1 +1 @@ -Subproject commit f9a4de585fc996cb94c5edcadbec0d7d874a1aa1 +Subproject commit b46138e0cd281bc42f061bf9c51755e96ad9f3f6