eliminate VS implicit conversion warnings

This commit is contained in:
Alex Fabijanic
2017-10-05 18:25:08 -05:00
parent 71531d1a75
commit 2e9aecb160
18 changed files with 44 additions and 42 deletions

View File

@@ -184,7 +184,7 @@ std::string ECKeyImpl::getCurveName(int nid)
std::string curveName; std::string curveName;
size_t len = EC_get_builtin_curves(NULL, 0); size_t len = EC_get_builtin_curves(NULL, 0);
EC_builtin_curve* pCurves = EC_builtin_curve* pCurves =
(EC_builtin_curve*) OPENSSL_malloc(sizeof(EC_builtin_curve) * len); (EC_builtin_curve*) OPENSSL_malloc(static_cast<int>(sizeof(EC_builtin_curve) * len));
if (!pCurves) return curveName; if (!pCurves) return curveName;
if (!EC_get_builtin_curves(pCurves, len)) if (!EC_get_builtin_curves(pCurves, len))
@@ -209,7 +209,7 @@ int ECKeyImpl::getCurveNID(std::string& name)
std::string curveName; std::string curveName;
size_t len = EC_get_builtin_curves(NULL, 0); size_t len = EC_get_builtin_curves(NULL, 0);
EC_builtin_curve* pCurves = EC_builtin_curve* pCurves =
(EC_builtin_curve*)OPENSSL_malloc(sizeof(EC_builtin_curve) * len); (EC_builtin_curve*)OPENSSL_malloc(static_cast<int>(sizeof(EC_builtin_curve) * len));
if (!pCurves) return -1; if (!pCurves) return -1;
if (!EC_get_builtin_curves(pCurves, len)) if (!EC_get_builtin_curves(pCurves, len))

View File

@@ -113,7 +113,7 @@ void Binder::bind(std::size_t pos, const DateTime& val, Direction dir, const Whe
void Binder::bind(std::size_t pos, const NullData&, Direction, const std::type_info& bindType) void Binder::bind(std::size_t pos, const NullData&, Direction, const std::type_info& bindType)
{ {
sqlite3_bind_null(_pStmt, pos); sqlite3_bind_null(_pStmt, static_cast<int>(pos));
} }

View File

@@ -228,7 +228,7 @@ bool Extractor::isNull(std::size_t pos, std::size_t)
if (!_nulls[pos].first) if (!_nulls[pos].first)
{ {
_nulls[pos].first = true; _nulls[pos].first = true;
_nulls[pos].second = (SQLITE_NULL == sqlite3_column_type(_pStmt, pos)); _nulls[pos].second = (SQLITE_NULL == sqlite3_column_type(_pStmt, static_cast<int>(pos)));
} }
return _nulls[pos].second; return _nulls[pos].second;

View File

@@ -277,7 +277,7 @@ std::size_t SQLiteStatementImpl::next()
if (_affectedRowCount == POCO_SQLITE_INV_ROW_CNT) _affectedRowCount = 0; if (_affectedRowCount == POCO_SQLITE_INV_ROW_CNT) _affectedRowCount = 0;
if (extracts.size()) if (extracts.size())
_affectedRowCount += (*extracts.begin())->numOfRowsHandled(); _affectedRowCount += static_cast<int>((*extracts.begin())->numOfRowsHandled());
else else
{ {
_stepCalled = true; _stepCalled = true;

View File

@@ -183,7 +183,7 @@ void SessionImpl::open(const std::string& connect)
{ {
ActiveConnector connector(connectionString(), &_pDB); ActiveConnector connector(connectionString(), &_pDB);
ActiveResult<int> result = connector.connect(); ActiveResult<int> result = connector.connect();
if (!result.tryWait(getLoginTimeout() * 1000)) if (!result.tryWait(static_cast<long>(getLoginTimeout()) * 1000))
throw ConnectionFailedException("Timed out."); throw ConnectionFailedException("Timed out.");
int rc = result.data(); int rc = result.data();
@@ -244,7 +244,7 @@ void SessionImpl::setConnectionTimeout(std::size_t timeout)
{ {
if(timeout <= std::numeric_limits<int>::max()/1000) if(timeout <= std::numeric_limits<int>::max()/1000)
{ {
int tout = 1000 * timeout; int tout = 1000 * static_cast<int>(timeout);
int rc = sqlite3_busy_timeout(_pDB, tout); int rc = sqlite3_busy_timeout(_pDB, tout);
if (rc != 0) Utility::throwException(rc); if (rc != 0) Utility::throwException(rc);
_timeout = tout; _timeout = tout;

View File

@@ -1177,7 +1177,7 @@ void DataTest::testSimpleRowFormatter()
std::streamsize sp = rf.getSpacing(); std::streamsize sp = rf.getSpacing();
std::string line(std::string::size_type(sz * 5 + sp * 4), '-'); std::string line(std::string::size_type(sz * 5 + sp * 4), '-');
std::string spacer(sp, ' '); std::string spacer(static_cast<std::size_t>(sp), ' ');
std::ostringstream os; std::ostringstream os;
os << std::left os << std::left
<< std::setw(sz) << "field0" << std::setw(sz) << "field0"

View File

@@ -59,7 +59,7 @@ Int64 Document::getInteger(const std::string& name) const
if (ElementTraits<double>::TypeId == element->type()) if (ElementTraits<double>::TypeId == element->type())
{ {
ConcreteElement<double>* concrete = dynamic_cast<ConcreteElement<double>*>(element.get()); ConcreteElement<double>* concrete = dynamic_cast<ConcreteElement<double>*>(element.get());
if (concrete) return concrete->value(); if (concrete) return static_cast<Int64>(concrete->value());
} }
else if (ElementTraits<Int32>::TypeId == element->type()) else if (ElementTraits<Int32>::TypeId == element->type())
{ {

View File

@@ -245,7 +245,7 @@ void MongoDBTest::testCursorRequest()
Poco::MongoDB::ResponseMessage& response = cursor.next(*_mongo); Poco::MongoDB::ResponseMessage& response = cursor.next(*_mongo);
while(1) while(1)
{ {
n += response.documents().size(); n += static_cast<int>(response.documents().size());
if ( response.cursorID() == 0 ) if ( response.cursorID() == 0 )
break; break;
response = cursor.next(*_mongo); response = cursor.next(*_mongo);

View File

@@ -54,7 +54,7 @@ namespace
int n; int n;
do do
{ {
n = ws.receiveFrame(pBuffer.get(), _bufSize, flags); n = ws.receiveFrame(pBuffer.get(), static_cast<int>(_bufSize), flags);
if (n == 0) if (n == 0)
break; break;
ws.sendFrame(pBuffer.get(), n, flags); ws.sendFrame(pBuffer.get(), n, flags);

View File

@@ -435,7 +435,7 @@ int SecureSocketImpl::receiveBytes(void* buffer, int length, int flags)
} }
else else
{ {
rc = overflowSize; rc = static_cast<int>(overflowSize);
std::memcpy(buffer, _overflowBuffer.begin(), rc); std::memcpy(buffer, _overflowBuffer.begin(), rc);
_overflowBuffer.resize(0); _overflowBuffer.resize(0);
} }
@@ -1283,7 +1283,7 @@ void SecureSocketImpl::verifyCertificateChainClient(PCCERT_CONTEXT pServerCert)
BOOL ok = CertVerifyRevocation( BOOL ok = CertVerifyRevocation(
X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
CERT_CONTEXT_REVOCATION_TYPE, CERT_CONTEXT_REVOCATION_TYPE,
certs.size(), static_cast<DWORD>(certs.size()),
(void**) &certs[0], (void**) &certs[0],
CERT_VERIFY_REV_CHAIN_FLAG, CERT_VERIFY_REV_CHAIN_FLAG,
NULL, NULL,
@@ -1390,7 +1390,7 @@ void SecureSocketImpl::serverVerifyCertificate()
BOOL ok = CertVerifyRevocation( BOOL ok = CertVerifyRevocation(
X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
CERT_CONTEXT_REVOCATION_TYPE, CERT_CONTEXT_REVOCATION_TYPE,
certs.size(), static_cast<DWORD>(certs.size()),
(void**) &certs[0], (void**) &certs[0],
CERT_VERIFY_REV_CHAIN_FLAG, CERT_VERIFY_REV_CHAIN_FLAG,
NULL, NULL,

View File

@@ -233,7 +233,7 @@ void X509Certificate::extractNames(std::string& cmnName, std::set<std::string>&
flags |= CRYPT_DECODE_ENABLE_PUNYCODE_FLAG; flags |= CRYPT_DECODE_ENABLE_PUNYCODE_FLAG;
#endif #endif
Poco::Buffer<char> buffer(256); Poco::Buffer<char> buffer(256);
DWORD bufferSize = buffer.sizeBytes(); DWORD bufferSize = static_cast<DWORD>(buffer.sizeBytes());
BOOL rc = CryptDecodeObjectEx( BOOL rc = CryptDecodeObjectEx(
X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
pExt->pszObjId, pExt->pszObjId,

View File

@@ -54,7 +54,7 @@ namespace
int n; int n;
do do
{ {
n = ws.receiveFrame(pBuffer.get(), _bufSize, flags); n = ws.receiveFrame(pBuffer.get(), static_cast<int>(_bufSize), flags);
if (n == 0) if (n == 0)
break; break;
ws.sendFrame(pBuffer.get(), n, flags); ws.sendFrame(pBuffer.get(), n, flags);

View File

@@ -43,13 +43,13 @@ RedisStreamBuf::~RedisStreamBuf()
int RedisStreamBuf::readFromDevice(char* buffer, std::streamsize len) int RedisStreamBuf::readFromDevice(char* buffer, std::streamsize len)
{ {
return _redis.receiveBytes(buffer, len); return _redis.receiveBytes(buffer, static_cast<int>(len));
} }
int RedisStreamBuf::writeToDevice(const char* buffer, std::streamsize length) int RedisStreamBuf::writeToDevice(const char* buffer, std::streamsize length)
{ {
return _redis.sendBytes(buffer, length); return _redis.sendBytes(buffer, static_cast<int>(length));
} }

View File

@@ -289,7 +289,7 @@ void RedisTest::testDECR()
Poco::Int64 result = _redis.execute<Poco::Int64>(decr); Poco::Int64 result = _redis.execute<Poco::Int64>(decr);
fail("This must fail"); fail("This must fail");
} }
catch (RedisException& e) catch (RedisException&)
{ {
// ERR value is not an integer or out of range // ERR value is not an integer or out of range
} }
@@ -338,7 +338,7 @@ void RedisTest::testError()
BulkString result = _redis.execute<BulkString>(command); BulkString result = _redis.execute<BulkString>(command);
fail("Invalid command must throw RedisException"); fail("Invalid command must throw RedisException");
} }
catch (RedisException& e) catch (RedisException&)
{ {
// Must fail // Must fail
} }

View File

@@ -932,14 +932,15 @@ ENTROPY_DEBUG(const char * label, unsigned long entropy) {
static unsigned long static unsigned long
generate_hash_secret_salt(XML_Parser parser) generate_hash_secret_salt(XML_Parser parser)
{ {
Poco::UInt64 entropy;
(void)parser;
#if defined(EXPAT_POCO) #if defined(EXPAT_POCO)
Poco::UInt64 entropy;
Poco::RandomInputStream rstr; Poco::RandomInputStream rstr;
Poco::BinaryReader rrdr(rstr); Poco::BinaryReader rrdr(rstr);
rrdr >> entropy; rrdr >> entropy;
return ENTROPY_DEBUG("RandomInputStream", entropy); return ENTROPY_DEBUG("RandomInputStream", (unsigned long)entropy);
#else #else
unsigned long entropy;
(void)parser;
#if defined(HAVE_ARC4RANDOM_BUF) || defined(__CloudABI__) #if defined(HAVE_ARC4RANDOM_BUF) || defined(__CloudABI__)
(void)gather_time_entropy; (void)gather_time_entropy;
arc4random_buf(&entropy, sizeof(entropy)); arc4random_buf(&entropy, sizeof(entropy));

View File

@@ -62,7 +62,7 @@ int AutoDetectStreamBuf::readFromDevice(char* buffer, std::streamsize length)
std::streamsize n = (_prefix.size() > length) ? length : static_cast<std::streamsize>(_prefix.size()); std::streamsize n = (_prefix.size() > length) ? length : static_cast<std::streamsize>(_prefix.size());
std::memcpy(buffer, _prefix.data(), n); std::memcpy(buffer, _prefix.data(), n);
_prefix.erase(0, n); _prefix.erase(0, n);
return n; return static_cast<int>(n);
} }
if (_eofDetected) if (_eofDetected)
@@ -72,7 +72,7 @@ int AutoDetectStreamBuf::readFromDevice(char* buffer, std::streamsize length)
std::streamsize n = (_postfix.size() > length) ? length : static_cast<std::streamsize>(_postfix.size()); std::streamsize n = (_postfix.size() > length) ? length : static_cast<std::streamsize>(_postfix.size());
std::memcpy(buffer, _postfix.data(), n); std::memcpy(buffer, _postfix.data(), n);
_postfix.erase(0, n); _postfix.erase(0, n);
return n; return static_cast<int>(n);
} }
else return -1; else return -1;
} }
@@ -135,7 +135,7 @@ int AutoDetectStreamBuf::readFromDevice(char* buffer, std::streamsize length)
_postfix.erase(0, offset); _postfix.erase(0, offset);
} }
return offset; return static_cast<int>(offset);
} }
} }
else else
@@ -159,7 +159,7 @@ int AutoDetectStreamBuf::readFromDevice(char* buffer, std::streamsize length)
_postfix.erase(0, offset); _postfix.erase(0, offset);
} }
return offset; return static_cast<int>(offset);
} }
} }
@@ -185,7 +185,7 @@ int AutoDetectStreamBuf::readFromDevice(char* buffer, std::streamsize length)
} }
_length += offset; _length += offset;
return offset; return static_cast<int>(offset);
} }

View File

@@ -74,7 +74,7 @@ int PartialStreamBuf::readFromDevice(char* buffer, std::streamsize length)
std::streamsize tmp = (_prefix.size() > length)? length: static_cast<std::streamsize>(_prefix.size()); std::streamsize tmp = (_prefix.size() > length)? length: static_cast<std::streamsize>(_prefix.size());
std::memcpy(buffer, _prefix.c_str(), tmp); std::memcpy(buffer, _prefix.c_str(), tmp);
_prefix = _prefix.substr(tmp); _prefix = _prefix.substr(tmp);
return tmp; return static_cast<int>(tmp);
} }
if (_numBytes == 0) if (_numBytes == 0)
@@ -84,7 +84,7 @@ int PartialStreamBuf::readFromDevice(char* buffer, std::streamsize length)
std::streamsize tmp = (_postfix.size() > length)? length: static_cast<std::streamsize>(_postfix.size()); std::streamsize tmp = (_postfix.size() > length)? length: static_cast<std::streamsize>(_postfix.size());
std::memcpy(buffer, _postfix.c_str(), tmp); std::memcpy(buffer, _postfix.c_str(), tmp);
_postfix = _postfix.substr(tmp); _postfix = _postfix.substr(tmp);
return tmp; return static_cast<int>(tmp);
} }
else else
return -1; return -1;
@@ -99,7 +99,7 @@ int PartialStreamBuf::readFromDevice(char* buffer, std::streamsize length)
_pIstr->read(buffer, length); _pIstr->read(buffer, length);
std::streamsize bytesRead = _pIstr->gcount(); std::streamsize bytesRead = _pIstr->gcount();
_numBytes -= bytesRead; _numBytes -= bytesRead;
return bytesRead; return static_cast<int>(bytesRead);
} }
@@ -121,7 +121,7 @@ int PartialStreamBuf::writeToDevice(const char* buffer, std::streamsize length)
{ {
_ignoreStart -= length; _ignoreStart -= length;
// fake return values // fake return values
return length; return static_cast<int>(length);
} }
else else
{ {
@@ -136,10 +136,10 @@ int PartialStreamBuf::writeToDevice(const char* buffer, std::streamsize length)
cnt += static_cast<std::streamsize>(_ignoreStart); cnt += static_cast<std::streamsize>(_ignoreStart);
_ignoreStart = 0; _ignoreStart = 0;
poco_assert (cnt < length); poco_assert (cnt < length);
_bufferOffset = length - cnt; _bufferOffset = static_cast<Poco::UInt32>(length - cnt);
std::memcpy(_buffer.begin(), buffer + cnt, _bufferOffset); std::memcpy(_buffer.begin(), buffer + cnt, _bufferOffset);
return length; return static_cast<int>(length);
} }
} }
if (_buffer.size() > 0) if (_buffer.size() > 0)
@@ -148,7 +148,8 @@ int PartialStreamBuf::writeToDevice(const char* buffer, std::streamsize length)
// thus first fill the buffer with the last n bytes of the msg // thus first fill the buffer with the last n bytes of the msg
// how much of the already cached data do we need to write? // how much of the already cached data do we need to write?
Poco::Int32 cache = _bufferOffset + length - _buffer.size(); Poco::Int32 cache = static_cast<Poco::Int32>(_bufferOffset +
static_cast<Poco::Int32>(length) - static_cast<Poco::Int32>(_buffer.size()));
if (cache > 0) if (cache > 0)
{ {
if (cache > _bufferOffset) if (cache > _bufferOffset)
@@ -184,7 +185,7 @@ int PartialStreamBuf::writeToDevice(const char* buffer, std::streamsize length)
} }
if (_pOstr->good()) if (_pOstr->good())
return length; return static_cast<int>(length);
throw Poco::IOException("Failed to write to output stream"); throw Poco::IOException("Failed to write to output stream");
} }

View File

@@ -61,7 +61,7 @@ ZipStreamBuf::ZipStreamBuf(std::istream& istr, const ZipLocalFileHeader& fileEnt
std::string crc(4, ' '); std::string crc(4, ' ');
if (fileEntry.searchCRCAndSizesAfterData()) if (fileEntry.searchCRCAndSizesAfterData())
{ {
_ptrHelper = new AutoDetectInputStream(istr, init, crc, reposition, start, fileEntry.needsZip64()); _ptrHelper = new AutoDetectInputStream(istr, init, crc, reposition, static_cast<Poco::UInt32>(start), fileEntry.needsZip64());
} }
else else
{ {
@@ -73,7 +73,7 @@ ZipStreamBuf::ZipStreamBuf(std::istream& istr, const ZipLocalFileHeader& fileEnt
{ {
if (fileEntry.searchCRCAndSizesAfterData()) if (fileEntry.searchCRCAndSizesAfterData())
{ {
_ptrBuf = new AutoDetectInputStream(istr, "", "", reposition, start, fileEntry.needsZip64()); _ptrBuf = new AutoDetectInputStream(istr, "", "", reposition, static_cast<Poco::UInt32>(start), fileEntry.needsZip64());
} }
else else
{ {
@@ -155,7 +155,7 @@ int ZipStreamBuf::readFromDevice(char* buffer, std::streamsize length)
{ {
if (!_ptrBuf) return 0; // directory entry if (!_ptrBuf) return 0; // directory entry
_ptrBuf->read(buffer, length); _ptrBuf->read(buffer, length);
int cnt = _ptrBuf->gcount(); int cnt = static_cast<int>(_ptrBuf->gcount());
if (cnt > 0) if (cnt > 0)
{ {
_crc32.update(buffer, cnt); _crc32.update(buffer, cnt);
@@ -193,14 +193,14 @@ int ZipStreamBuf::writeToDevice(const char* buffer, std::streamsize length)
return 0; return 0;
_bytesWritten += length; _bytesWritten += length;
_ptrOBuf->write(buffer, length); _ptrOBuf->write(buffer, length);
_crc32.update(buffer, length); _crc32.update(buffer, static_cast<unsigned int>(length));
return length; return static_cast<int>(length);
} }
void ZipStreamBuf::close(Poco::UInt64& extraDataSize) void ZipStreamBuf::close(Poco::UInt64& extraDataSize)
{ {
extraDataSize = 0; extraDataSize = 0;
if (_ptrOBuf && _pHeader) if (_ptrOBuf && _pHeader)
{ {
_ptrOBuf->flush(); _ptrOBuf->flush();