Replace C-style casts with C++ ones

This commit is contained in:
Eugene Shalygin
2017-05-29 14:10:31 +02:00
parent e3671050d1
commit 74cecb1b6c
20 changed files with 41 additions and 39 deletions

View File

@@ -41,7 +41,7 @@ InfoHash::InfoHash(const libtorrent::sha1_hash &nativeHash)
, m_nativeHash(nativeHash)
{
char out[(libtorrent::sha1_hash::size * 2) + 1];
libtorrent::to_hex((char const*)&m_nativeHash[0], libtorrent::sha1_hash::size, out);
libtorrent::to_hex(reinterpret_cast<const char*>(&m_nativeHash[0]), libtorrent::sha1_hash::size, out);
m_hashString = QString(out);
}
@@ -51,7 +51,7 @@ InfoHash::InfoHash(const QString &hashString)
{
QByteArray raw = m_hashString.toLatin1();
if (raw.size() == 40)
m_valid = libtorrent::from_hex(raw.constData(), 40, (char*)&m_nativeHash[0]);
m_valid = libtorrent::from_hex(raw.constData(), 40, reinterpret_cast<char*>(&m_nativeHash[0]));
}

View File

@@ -417,7 +417,7 @@ int FilterParserThread::parseP2BFilterFile()
unsigned char version;
if (!stream.readRawData(buf, sizeof(buf))
|| memcmp(buf, "\xFF\xFF\xFF\xFFP2B", 7)
|| !stream.readRawData((char*)&version, sizeof(version))) {
|| !stream.readRawData(reinterpret_cast<char*>(&version), sizeof(version))) {
LogMsg(tr("Parsing Error: The filter file is not a valid PeerGuardian P2B file."), Log::CRITICAL);
return ruleCount;
}
@@ -428,8 +428,8 @@ int FilterParserThread::parseP2BFilterFile()
std::string name;
while(getlineInStream(stream, name, '\0') && !m_abort) {
if (!stream.readRawData((char*)&start, sizeof(start))
|| !stream.readRawData((char*)&end, sizeof(end))) {
if (!stream.readRawData(reinterpret_cast<char*>(&start), sizeof(start))
|| !stream.readRawData(reinterpret_cast<char*>(&end), sizeof(end))) {
LogMsg(tr("Parsing Error: The filter file is not a valid PeerGuardian P2B file."), Log::CRITICAL);
return ruleCount;
}
@@ -450,7 +450,7 @@ int FilterParserThread::parseP2BFilterFile()
else if (version == 3) {
qDebug ("p2b version 3");
unsigned int namecount;
if (!stream.readRawData((char*)&namecount, sizeof(namecount))) {
if (!stream.readRawData(reinterpret_cast<char*>(&namecount), sizeof(namecount))) {
LogMsg(tr("Parsing Error: The filter file is not a valid PeerGuardian P2B file."), Log::CRITICAL);
return ruleCount;
}
@@ -469,7 +469,7 @@ int FilterParserThread::parseP2BFilterFile()
// Reading the ranges
unsigned int rangecount;
if (!stream.readRawData((char*)&rangecount, sizeof(rangecount))) {
if (!stream.readRawData(reinterpret_cast<char*>(&rangecount), sizeof(rangecount))) {
LogMsg(tr("Parsing Error: The filter file is not a valid PeerGuardian P2B file."), Log::CRITICAL);
return ruleCount;
}
@@ -477,9 +477,9 @@ int FilterParserThread::parseP2BFilterFile()
rangecount = ntohl(rangecount);
unsigned int name, start, end;
for (unsigned int i = 0; i < rangecount; ++i) {
if (!stream.readRawData((char*)&name, sizeof(name))
|| !stream.readRawData((char*)&start, sizeof(start))
|| !stream.readRawData((char*)&end, sizeof(end))) {
if (!stream.readRawData(reinterpret_cast<char*>(&name), sizeof(name))
|| !stream.readRawData(reinterpret_cast<char*>(&start), sizeof(start))
|| !stream.readRawData(reinterpret_cast<char*>(&end), sizeof(end))) {
LogMsg(tr("Parsing Error: The filter file is not a valid PeerGuardian P2B file."), Log::CRITICAL);
return ruleCount;
}

View File

@@ -555,7 +555,7 @@ qreal TorrentHandle::progress() const
if (m_nativeStatus.total_wanted_done == m_nativeStatus.total_wanted)
return 1.;
float progress = (float) m_nativeStatus.total_wanted_done / (float) m_nativeStatus.total_wanted;
float progress = static_cast<float>(m_nativeStatus.total_wanted_done) / m_nativeStatus.total_wanted;
Q_ASSERT((progress >= 0.f) && (progress <= 1.f));
return progress;
}