mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
chore(style): remove old style casts and cross sign comparisons
Enable warnings for both. Favour casting to signed rather than casting to unsigend for comparisons. Per isocpp's core guidelines ES.102, signed arithmetic gives more expected results. If we need one extra bit of range, using longer signed types achives that. Fix #6010 Fix #6012
This commit is contained in:
parent
f13ba3f972
commit
2c1a86482a
|
@ -85,6 +85,8 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti")
|
||||||
set(POSITION_INDEPENDENT_CODE True)
|
set(POSITION_INDEPENDENT_CODE True)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wstrict-overflow")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wstrict-overflow")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wstrict-aliasing")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wstrict-aliasing")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wold-style-cast")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsign-compare")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
|
||||||
|
|
||||||
# avoid timestamps in binary for reproducible builds, not added until GCC 4.9
|
# avoid timestamps in binary for reproducible builds, not added until GCC 4.9
|
||||||
|
|
|
@ -764,7 +764,6 @@ void OpenAL::cleanupBuffers(uint sourceId)
|
||||||
std::vector<ALuint> bufids;
|
std::vector<ALuint> bufids;
|
||||||
// should never be out of range, just to be sure
|
// should never be out of range, just to be sure
|
||||||
assert(processed >= 0);
|
assert(processed >= 0);
|
||||||
assert(processed <= SIZE_MAX);
|
|
||||||
bufids.resize(processed);
|
bufids.resize(processed);
|
||||||
alSourceUnqueueBuffers(sourceId, processed, bufids.data());
|
alSourceUnqueueBuffers(sourceId, processed, bufids.data());
|
||||||
// delete all buffers
|
// delete all buffers
|
||||||
|
|
|
@ -394,7 +394,7 @@ void ChatLog::insertChatlineAtBottom(const QList<ChatLine::Ptr>& newLines)
|
||||||
if (newLines.isEmpty())
|
if (newLines.isEmpty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (canRemove && lines.size() + DEF_NUM_MSG_TO_LOAD >= maxMessages) {
|
if (canRemove && lines.size() + static_cast<int>(DEF_NUM_MSG_TO_LOAD) >= maxMessages) {
|
||||||
removeFirsts(DEF_NUM_MSG_TO_LOAD);
|
removeFirsts(DEF_NUM_MSG_TO_LOAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -444,7 +444,7 @@ void ChatLog::insertChatlinesOnTop(const QList<ChatLine::Ptr>& newLines)
|
||||||
combLines.push_back(l);
|
combLines.push_back(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canRemove && lines.size() + DEF_NUM_MSG_TO_LOAD >= maxMessages) {
|
if (canRemove && lines.size() + static_cast<int>(DEF_NUM_MSG_TO_LOAD) >= maxMessages) {
|
||||||
removeLasts(DEF_NUM_MSG_TO_LOAD);
|
removeLasts(DEF_NUM_MSG_TO_LOAD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,7 @@ ChatMessage::Ptr ChatMessage::createChatMessage(const QString& sender, const QSt
|
||||||
QColor color = Style::getColor(Style::MainText);
|
QColor color = Style::getColor(Style::MainText);
|
||||||
if (colorizeName) {
|
if (colorizeName) {
|
||||||
QByteArray hash = QCryptographicHash::hash((sender.toUtf8()), QCryptographicHash::Sha256);
|
QByteArray hash = QCryptographicHash::hash((sender.toUtf8()), QCryptographicHash::Sha256);
|
||||||
quint8 *data = (quint8*)hash.data();
|
const auto* data = hash.data();
|
||||||
|
|
||||||
color.setHsv(data[0], 255, 196);
|
color.setHsv(data[0], 255, 196);
|
||||||
|
|
||||||
|
|
|
@ -237,7 +237,7 @@ QString FileTransferWidget::getHumanReadableSize(qint64 size)
|
||||||
int exp = 0;
|
int exp = 0;
|
||||||
|
|
||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
exp = std::min((int)(log(size) / log(1024)), (int)(sizeof(suffix) / sizeof(suffix[0]) - 1));
|
exp = std::min(static_cast<int>(log(size) / log(1024)), static_cast<int>(sizeof(suffix) / sizeof(suffix[0]) - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
return QString().setNum(size / pow(1024, exp), 'f', exp > 1 ? 2 : 0).append(suffix[exp]);
|
return QString().setNum(size / pow(1024, exp), 'f', exp > 1 ? 2 : 0).append(suffix[exp]);
|
||||||
|
|
|
@ -948,7 +948,11 @@ void Core::onGroupTitleChange(Tox*, uint32_t groupId, uint32_t peerId, const uin
|
||||||
size_t length, void* vCore)
|
size_t length, void* vCore)
|
||||||
{
|
{
|
||||||
Core* core = static_cast<Core*>(vCore);
|
Core* core = static_cast<Core*>(vCore);
|
||||||
QString author = core->getGroupPeerName(groupId, peerId);
|
QString author;
|
||||||
|
// from tox.h: "If peer_number == UINT32_MAX, then author is unknown (e.g. initial joining the conference)."
|
||||||
|
if (peerId != std::numeric_limits<uint32_t>::max()) {
|
||||||
|
author = core->getGroupPeerName(groupId, peerId);
|
||||||
|
}
|
||||||
emit core->saveRequest();
|
emit core->saveRequest();
|
||||||
emit core->groupTitleChanged(groupId, author, ToxString(cTitle, length).getQString());
|
emit core->groupTitleChanged(groupId, author, ToxString(cTitle, length).getQString());
|
||||||
}
|
}
|
||||||
|
@ -1032,7 +1036,7 @@ bool Core::sendMessageWithType(uint32_t friendId, const QString& message, Tox_Me
|
||||||
ReceiptNum& receipt)
|
ReceiptNum& receipt)
|
||||||
{
|
{
|
||||||
int size = message.toUtf8().size();
|
int size = message.toUtf8().size();
|
||||||
auto maxSize = tox_max_message_length();
|
auto maxSize = static_cast<int>(tox_max_message_length());
|
||||||
if (size > maxSize) {
|
if (size > maxSize) {
|
||||||
qCritical() << "Core::sendMessageWithType called with message of size:" << size
|
qCritical() << "Core::sendMessageWithType called with message of size:" << size
|
||||||
<< "when max is:" << maxSize << ". Ignoring.";
|
<< "when max is:" << maxSize << ". Ignoring.";
|
||||||
|
@ -1077,7 +1081,7 @@ void Core::sendGroupMessageWithType(int groupId, const QString& message, Tox_Mes
|
||||||
QMutexLocker ml{&coreLoopLock};
|
QMutexLocker ml{&coreLoopLock};
|
||||||
|
|
||||||
int size = message.toUtf8().size();
|
int size = message.toUtf8().size();
|
||||||
auto maxSize = tox_max_message_length();
|
auto maxSize = static_cast<int>(tox_max_message_length());
|
||||||
if (size > maxSize) {
|
if (size > maxSize) {
|
||||||
qCritical() << "Core::sendMessageWithType called with message of size:" << size
|
qCritical() << "Core::sendMessageWithType called with message of size:" << size
|
||||||
<< "when max is:" << maxSize << ". Ignoring.";
|
<< "when max is:" << maxSize << ". Ignoring.";
|
||||||
|
@ -1318,7 +1322,7 @@ QByteArray Core::getToxSaveData()
|
||||||
uint32_t fileSize = tox_get_savedata_size(tox.get());
|
uint32_t fileSize = tox_get_savedata_size(tox.get());
|
||||||
QByteArray data;
|
QByteArray data;
|
||||||
data.resize(fileSize);
|
data.resize(fileSize);
|
||||||
tox_get_savedata(tox.get(), (uint8_t*)data.data());
|
tox_get_savedata(tox.get(), reinterpret_cast<uint8_t*>(data.data()));
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1455,11 +1459,6 @@ QString Core::getGroupPeerName(int groupId, int peerId) const
|
||||||
{
|
{
|
||||||
QMutexLocker ml{&coreLoopLock};
|
QMutexLocker ml{&coreLoopLock};
|
||||||
|
|
||||||
// from tox.h: "If peer_number == UINT32_MAX, then author is unknown (e.g. initial joining the conference)."
|
|
||||||
if (peerId == std::numeric_limits<uint32_t>::max()) {
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
Tox_Err_Conference_Peer_Query error;
|
Tox_Err_Conference_Peer_Query error;
|
||||||
size_t length = tox_conference_peer_get_name_size(tox.get(), groupId, peerId, &error);
|
size_t length = tox_conference_peer_get_name_size(tox.get(), groupId, peerId, &error);
|
||||||
if (!PARSE_ERR(error) || !length) {
|
if (!PARSE_ERR(error) || !length) {
|
||||||
|
@ -1508,7 +1507,7 @@ QStringList Core::getGroupPeerNames(int groupId) const
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList names;
|
QStringList names;
|
||||||
for (uint32_t i = 0; i < nPeers; ++i) {
|
for (int i = 0; i < static_cast<int>(nPeers); ++i) {
|
||||||
Tox_Err_Conference_Peer_Query error;
|
Tox_Err_Conference_Peer_Query error;
|
||||||
size_t length = tox_conference_peer_get_name_size(tox.get(), groupId, i, &error);
|
size_t length = tox_conference_peer_get_name_size(tox.get(), groupId, i, &error);
|
||||||
|
|
||||||
|
@ -1526,7 +1525,7 @@ QStringList Core::getGroupPeerNames(int groupId) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(names.size() == nPeers);
|
assert(names.size() == static_cast<int>(nPeers));
|
||||||
|
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
@ -1711,7 +1710,7 @@ QStringList Core::splitMessage(const QString& message)
|
||||||
*
|
*
|
||||||
* (uint32_t tox_max_message_length(void); declared in tox.h, unable to see explicit definition)
|
* (uint32_t tox_max_message_length(void); declared in tox.h, unable to see explicit definition)
|
||||||
*/
|
*/
|
||||||
const auto maxLen = tox_max_message_length() - 50;
|
const auto maxLen = static_cast<int>(tox_max_message_length()) - 50;
|
||||||
|
|
||||||
while (ba_message.size() > maxLen) {
|
while (ba_message.size() > maxLen) {
|
||||||
int splitPos = ba_message.lastIndexOf('\n', maxLen - 1);
|
int splitPos = ba_message.lastIndexOf('\n', maxLen - 1);
|
||||||
|
|
|
@ -98,7 +98,7 @@ void CoreFile::sendAvatarFile(uint32_t friendId, const QByteArray& data)
|
||||||
uint8_t avatarHash[TOX_HASH_LENGTH];
|
uint8_t avatarHash[TOX_HASH_LENGTH];
|
||||||
if (!data.isEmpty()) {
|
if (!data.isEmpty()) {
|
||||||
static_assert(TOX_HASH_LENGTH <= TOX_FILE_ID_LENGTH, "TOX_HASH_LENGTH > TOX_FILE_ID_LENGTH!");
|
static_assert(TOX_HASH_LENGTH <= TOX_FILE_ID_LENGTH, "TOX_HASH_LENGTH > TOX_FILE_ID_LENGTH!");
|
||||||
tox_hash(avatarHash, (uint8_t*)data.data(), data.size());
|
tox_hash(avatarHash, reinterpret_cast<const uint8_t*>(data.data()), data.size());
|
||||||
filesize = data.size();
|
filesize = data.size();
|
||||||
file_id = avatarHash;
|
file_id = avatarHash;
|
||||||
file_name = avatarHash;
|
file_name = avatarHash;
|
||||||
|
@ -135,7 +135,7 @@ void CoreFile::sendAvatarFile(uint32_t friendId, const QByteArray& data)
|
||||||
file.fileKind = TOX_FILE_KIND_AVATAR;
|
file.fileKind = TOX_FILE_KIND_AVATAR;
|
||||||
file.avatarData = data;
|
file.avatarData = data;
|
||||||
file.resumeFileId.resize(TOX_FILE_ID_LENGTH);
|
file.resumeFileId.resize(TOX_FILE_ID_LENGTH);
|
||||||
tox_file_get_file_id(tox, friendId, fileNum, (uint8_t*)file.resumeFileId.data(),
|
tox_file_get_file_id(tox, friendId, fileNum, reinterpret_cast<uint8_t*>(file.resumeFileId.data()),
|
||||||
nullptr);
|
nullptr);
|
||||||
addFile(friendId, fileNum, file);
|
addFile(friendId, fileNum, file);
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ void CoreFile::sendFile(uint32_t friendId, QString filename, QString filePath,
|
||||||
ToxFile file{fileNum, friendId, fileName.getQString(), filePath, ToxFile::SENDING};
|
ToxFile file{fileNum, friendId, fileName.getQString(), filePath, ToxFile::SENDING};
|
||||||
file.filesize = filesize;
|
file.filesize = filesize;
|
||||||
file.resumeFileId.resize(TOX_FILE_ID_LENGTH);
|
file.resumeFileId.resize(TOX_FILE_ID_LENGTH);
|
||||||
tox_file_get_file_id(tox, friendId, fileNum, (uint8_t*)file.resumeFileId.data(),
|
tox_file_get_file_id(tox, friendId, fileNum, reinterpret_cast<uint8_t*>(file.resumeFileId.data()),
|
||||||
nullptr);
|
nullptr);
|
||||||
if (!file.open(false)) {
|
if (!file.open(false)) {
|
||||||
qWarning() << QString("sendFile: Can't open file, error: %1").arg(file.file->errorString());
|
qWarning() << QString("sendFile: Can't open file, error: %1").arg(file.file->errorString());
|
||||||
|
@ -355,7 +355,7 @@ void CoreFile::onFileReceiveCallback(Tox* tox, uint32_t friendId, uint32_t fileI
|
||||||
file.filesize = filesize;
|
file.filesize = filesize;
|
||||||
file.fileKind = kind;
|
file.fileKind = kind;
|
||||||
file.resumeFileId.resize(TOX_FILE_ID_LENGTH);
|
file.resumeFileId.resize(TOX_FILE_ID_LENGTH);
|
||||||
tox_file_get_file_id(tox, friendId, fileId, (uint8_t*)file.resumeFileId.data(),
|
tox_file_get_file_id(tox, friendId, fileId, reinterpret_cast<uint8_t*>(file.resumeFileId.data()),
|
||||||
nullptr);
|
nullptr);
|
||||||
coreFile->addFile(friendId, fileId, file);
|
coreFile->addFile(friendId, fileId, file);
|
||||||
if (kind != TOX_FILE_KIND_AVATAR) {
|
if (kind != TOX_FILE_KIND_AVATAR) {
|
||||||
|
@ -385,7 +385,7 @@ void CoreFile::handleAvatarOffer(uint32_t friendId, uint32_t fileId, bool accept
|
||||||
file.filesize = 0;
|
file.filesize = 0;
|
||||||
file.fileKind = TOX_FILE_KIND_AVATAR;
|
file.fileKind = TOX_FILE_KIND_AVATAR;
|
||||||
file.resumeFileId.resize(TOX_FILE_ID_LENGTH);
|
file.resumeFileId.resize(TOX_FILE_ID_LENGTH);
|
||||||
tox_file_get_file_id(tox, friendId, fileId, (uint8_t*)file.resumeFileId.data(),
|
tox_file_get_file_id(tox, friendId, fileId, reinterpret_cast<uint8_t*>(file.resumeFileId.data()),
|
||||||
nullptr);
|
nullptr);
|
||||||
addFile(friendId, fileId, file);
|
addFile(friendId, fileId, file);
|
||||||
}
|
}
|
||||||
|
@ -457,7 +457,7 @@ void CoreFile::onFileDataCallback(Tox* tox, uint32_t friendId, uint32_t fileId,
|
||||||
memcpy(data.get(), chunk.data(), nread);
|
memcpy(data.get(), chunk.data(), nread);
|
||||||
} else {
|
} else {
|
||||||
file->file->seek(pos);
|
file->file->seek(pos);
|
||||||
nread = file->file->read((char*)data.get(), length);
|
nread = file->file->read(reinterpret_cast<char*>(data.get()), length);
|
||||||
if (nread <= 0) {
|
if (nread <= 0) {
|
||||||
qWarning("onFileDataCallback: Failed to read from file");
|
qWarning("onFileDataCallback: Failed to read from file");
|
||||||
file->status = ToxFile::CANCELED;
|
file->status = ToxFile::CANCELED;
|
||||||
|
@ -467,7 +467,7 @@ void CoreFile::onFileDataCallback(Tox* tox, uint32_t friendId, uint32_t fileId,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
file->bytesSent += length;
|
file->bytesSent += length;
|
||||||
file->hashGenerator->addData((const char*)data.get(), length);
|
file->hashGenerator->addData(reinterpret_cast<const char*>(data.get()), length);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!tox_file_send_chunk(tox, friendId, fileId, pos, data.get(), nread, nullptr)) {
|
if (!tox_file_send_chunk(tox, friendId, fileId, pos, data.get(), nread, nullptr)) {
|
||||||
|
@ -520,12 +520,12 @@ void CoreFile::onFileRecvChunkCallback(Tox* tox, uint32_t friendId, uint32_t fil
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file->fileKind == TOX_FILE_KIND_AVATAR) {
|
if (file->fileKind == TOX_FILE_KIND_AVATAR) {
|
||||||
file->avatarData.append((char*)data, length);
|
file->avatarData.append(reinterpret_cast<const char*>(data), length);
|
||||||
} else {
|
} else {
|
||||||
file->file->write((char*)data, length);
|
file->file->write(reinterpret_cast<const char*>(data), length);
|
||||||
}
|
}
|
||||||
file->bytesSent += length;
|
file->bytesSent += length;
|
||||||
file->hashGenerator->addData((const char*)data, length);
|
file->hashGenerator->addData(reinterpret_cast<const char*>(data), length);
|
||||||
|
|
||||||
if (file->fileKind != TOX_FILE_KIND_AVATAR) {
|
if (file->fileKind != TOX_FILE_KIND_AVATAR) {
|
||||||
emit coreFile->fileTransferInfo(*file);
|
emit coreFile->fileTransferInfo(*file);
|
||||||
|
|
|
@ -103,11 +103,11 @@ IPC::~IPC()
|
||||||
time_t IPC::postEvent(const QString& name, const QByteArray& data, uint32_t dest)
|
time_t IPC::postEvent(const QString& name, const QByteArray& data, uint32_t dest)
|
||||||
{
|
{
|
||||||
QByteArray binName = name.toUtf8();
|
QByteArray binName = name.toUtf8();
|
||||||
if (binName.length() > (int32_t)sizeof(IPCEvent::name)) {
|
if (binName.length() > static_cast<int32_t>(sizeof(IPCEvent::name))) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.length() > (int32_t)sizeof(IPCEvent::data)) {
|
if (data.length() > static_cast<int32_t>(sizeof(IPCEvent::data))) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -352,7 +352,7 @@ void ChatHistory::loadHistoryIntoSessionChatLog(ChatLogIdx start) const
|
||||||
assert(getFirstIdx() == ChatLogIdx(0));
|
assert(getFirstIdx() == ChatLogIdx(0));
|
||||||
auto messages = history->getMessagesForFriend(f.getPublicKey(), start.get(), end.get());
|
auto messages = history->getMessagesForFriend(f.getPublicKey(), start.get(), end.get());
|
||||||
|
|
||||||
assert(messages.size() == end.get() - start.get());
|
assert(messages.size() == static_cast<int>(end.get() - start.get()));
|
||||||
ChatLogIdx nextIdx = start;
|
ChatLogIdx nextIdx = start;
|
||||||
|
|
||||||
for (const auto& message : messages) {
|
for (const auto& message : messages) {
|
||||||
|
|
|
@ -158,12 +158,12 @@ SearchResult SessionChatLog::searchForward(SearchPos startPos, const QString& ph
|
||||||
|
|
||||||
auto numMatches = 0;
|
auto numMatches = 0;
|
||||||
QRegularExpressionMatch lastMatch;
|
QRegularExpressionMatch lastMatch;
|
||||||
while (match.isValid() && numMatches <= currentPos.numMatches && match.hasNext()) {
|
while (match.isValid() && numMatches <= static_cast<int>(currentPos.numMatches) && match.hasNext()) {
|
||||||
lastMatch = match.next();
|
lastMatch = match.next();
|
||||||
numMatches++;
|
numMatches++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (numMatches > currentPos.numMatches) {
|
if (numMatches > static_cast<int>(currentPos.numMatches)) {
|
||||||
SearchResult res;
|
SearchResult res;
|
||||||
res.found = true;
|
res.found = true;
|
||||||
res.pos.logIdx = key;
|
res.pos.logIdx = key;
|
||||||
|
@ -223,13 +223,13 @@ SearchResult SessionChatLog::searchBackward(SearchPos startPos, const QString& p
|
||||||
while (match.isValid() && match.hasNext()) {
|
while (match.isValid() && match.hasNext()) {
|
||||||
auto currentMatch = match.next();
|
auto currentMatch = match.next();
|
||||||
totalMatches++;
|
totalMatches++;
|
||||||
if (currentPos.numMatches == 0 || currentPos.numMatches > numMatchesBeforePos) {
|
if (currentPos.numMatches == 0 || static_cast<int>(currentPos.numMatches) > numMatchesBeforePos) {
|
||||||
lastMatch = currentMatch;
|
lastMatch = currentMatch;
|
||||||
numMatchesBeforePos++;
|
numMatchesBeforePos++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((numMatchesBeforePos < currentPos.numMatches || currentPos.numMatches == 0)
|
if ((numMatchesBeforePos < static_cast<int>(currentPos.numMatches) || currentPos.numMatches == 0)
|
||||||
&& numMatchesBeforePos > 0) {
|
&& numMatchesBeforePos > 0) {
|
||||||
SearchResult res;
|
SearchResult res;
|
||||||
res.found = true;
|
res.found = true;
|
||||||
|
@ -285,7 +285,7 @@ std::vector<IChatLog::DateChatLogIdxPair> SessionChatLog::getDateIdxs(const QDat
|
||||||
ret.push_back(std::move(pair));
|
ret.push_back(std::move(pair));
|
||||||
|
|
||||||
dateIt = dateIt.addDays(1);
|
dateIt = dateIt.addDays(1);
|
||||||
if (startDate.daysTo(dateIt) > maxDates && maxDates != 0) {
|
if (startDate.daysTo(dateIt) > static_cast<long>(maxDates) && maxDates != 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -736,7 +736,12 @@ void RawDatabase::process()
|
||||||
}
|
}
|
||||||
for (int i = 0; i < nParams; ++i) {
|
for (int i = 0; i < nParams; ++i) {
|
||||||
const QByteArray& blob = query.blobs[curParam + i];
|
const QByteArray& blob = query.blobs[curParam + i];
|
||||||
if (sqlite3_bind_blob(stmt, i + 1, blob.data(), blob.size(), SQLITE_STATIC)
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||||
|
// SQLITE_STATIC uses old-style cast and comes from system headers, so can't be fixed by us
|
||||||
|
auto sqliteDataType = SQLITE_STATIC;
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
if (sqlite3_bind_blob(stmt, i + 1, blob.data(), blob.size(), sqliteDataType)
|
||||||
!= SQLITE_OK) {
|
!= SQLITE_OK) {
|
||||||
qWarning() << "Failed to bind param" << curParam + i << "to query"
|
qWarning() << "Failed to bind param" << curParam + i << "to query"
|
||||||
<< anonymizeQuery(query.query);
|
<< anonymizeQuery(query.query);
|
||||||
|
|
|
@ -523,8 +523,8 @@ QString Profile::avatarPath(const ToxPk& owner, bool forceUnencrypted)
|
||||||
&& hashSize <= crypto_generichash_KEYBYTES_MAX,
|
&& hashSize <= crypto_generichash_KEYBYTES_MAX,
|
||||||
"Key size not supported by libsodium");
|
"Key size not supported by libsodium");
|
||||||
QByteArray hash(hashSize, 0);
|
QByteArray hash(hashSize, 0);
|
||||||
crypto_generichash((uint8_t*)hash.data(), hashSize, (uint8_t*)idData.data(), idData.size(),
|
crypto_generichash(reinterpret_cast<uint8_t*>(hash.data()), hashSize, reinterpret_cast<uint8_t*>(idData.data()), idData.size(),
|
||||||
(uint8_t*)pubkeyData.data(), pubkeyData.size());
|
reinterpret_cast<uint8_t*>(pubkeyData.data()), pubkeyData.size());
|
||||||
return Settings::getInstance().getSettingsDirPath() + "avatars/" + hash.toHex().toUpper() + ".png";
|
return Settings::getInstance().getSettingsDirPath() + "avatars/" + hash.toHex().toUpper() + ".png";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -728,7 +728,7 @@ QByteArray Profile::getAvatarHash(const ToxPk& owner)
|
||||||
{
|
{
|
||||||
QByteArray pic = loadAvatarData(owner);
|
QByteArray pic = loadAvatarData(owner);
|
||||||
QByteArray avatarHash(TOX_HASH_LENGTH, 0);
|
QByteArray avatarHash(TOX_HASH_LENGTH, 0);
|
||||||
tox_hash((uint8_t*)avatarHash.data(), (uint8_t*)pic.data(), pic.size());
|
tox_hash(reinterpret_cast<uint8_t*>(avatarHash.data()), reinterpret_cast<uint8_t*>(pic.data()), pic.size());
|
||||||
return avatarHash;
|
return avatarHash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -812,7 +812,7 @@ bool Profile::isEncrypted(QString name)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
saveFile.read((char*)data, TOX_PASS_ENCRYPTION_EXTRA_LENGTH);
|
saveFile.read(reinterpret_cast<char*>(data), TOX_PASS_ENCRYPTION_EXTRA_LENGTH);
|
||||||
saveFile.close();
|
saveFile.close();
|
||||||
|
|
||||||
return tox_is_data_encrypted(data);
|
return tox_is_data_encrypted(data);
|
||||||
|
|
|
@ -68,7 +68,7 @@ bool Platform::setAutorun(bool on)
|
||||||
|
|
||||||
if (on) {
|
if (on) {
|
||||||
tstring path = currentCommandLine();
|
tstring path = currentCommandLine();
|
||||||
result = RegSetValueEx(key, keyName.c_str(), 0, REG_SZ, (PBYTE)path.c_str(),
|
result = RegSetValueEx(key, keyName.c_str(), 0, REG_SZ, const_cast<PBYTE>(reinterpret_cast<const unsigned char*>(path.c_str())),
|
||||||
path.length() * sizeof(TCHAR))
|
path.length() * sizeof(TCHAR))
|
||||||
== ERROR_SUCCESS;
|
== ERROR_SUCCESS;
|
||||||
} else
|
} else
|
||||||
|
@ -93,7 +93,7 @@ bool Platform::getAutorun()
|
||||||
DWORD type = REG_SZ;
|
DWORD type = REG_SZ;
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
if (RegQueryValueEx(key, keyName.c_str(), 0, &type, (PBYTE)path, &length) == ERROR_SUCCESS
|
if (RegQueryValueEx(key, keyName.c_str(), 0, &type, const_cast<PBYTE>(reinterpret_cast<const unsigned char*>(path)), &length) == ERROR_SUCCESS
|
||||||
&& type == REG_SZ)
|
&& type == REG_SZ)
|
||||||
result = true;
|
result = true;
|
||||||
|
|
||||||
|
|
|
@ -63,7 +63,7 @@ QVector<VideoMode> avfoundation::getDeviceModes(QString devName)
|
||||||
for (AVCaptureDeviceFormat* format in [device formats]) {
|
for (AVCaptureDeviceFormat* format in [device formats]) {
|
||||||
CMFormatDescriptionRef formatDescription;
|
CMFormatDescriptionRef formatDescription;
|
||||||
CMVideoDimensions dimensions;
|
CMVideoDimensions dimensions;
|
||||||
formatDescription = (CMFormatDescriptionRef)[format performSelector:@selector(formatDescription)];
|
formatDescription = static_cast<CMFormatDescriptionRef>([format performSelector:@selector(formatDescription)]);
|
||||||
dimensions = CMVideoFormatDescriptionGetDimensions(formatDescription);
|
dimensions = CMVideoFormatDescriptionGetDimensions(formatDescription);
|
||||||
|
|
||||||
for (AVFrameRateRange* range in format.videoSupportedFrameRateRanges) {
|
for (AVFrameRateRange* range in format.videoSupportedFrameRateRanges) {
|
||||||
|
|
|
@ -56,12 +56,12 @@ QVector<QPair<QString, QString>> DirectShow::getDeviceList()
|
||||||
|
|
||||||
ICreateDevEnum* devenum = nullptr;
|
ICreateDevEnum* devenum = nullptr;
|
||||||
if (CoCreateInstance(CLSID_SystemDeviceEnum, nullptr, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum,
|
if (CoCreateInstance(CLSID_SystemDeviceEnum, nullptr, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum,
|
||||||
(void**)&devenum)
|
reinterpret_cast<void**>(&devenum))
|
||||||
!= S_OK)
|
!= S_OK)
|
||||||
return devices;
|
return devices;
|
||||||
|
|
||||||
IEnumMoniker* classenum = nullptr;
|
IEnumMoniker* classenum = nullptr;
|
||||||
if (devenum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, (IEnumMoniker**)&classenum, 0)
|
if (devenum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, reinterpret_cast<IEnumMoniker**>(&classenum), 0)
|
||||||
!= S_OK)
|
!= S_OK)
|
||||||
return devices;
|
return devices;
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ QVector<QPair<QString, QString>> DirectShow::getDeviceList()
|
||||||
devIdString[i] = '_';
|
devIdString[i] = '_';
|
||||||
|
|
||||||
// Get a human friendly name/description
|
// Get a human friendly name/description
|
||||||
if (m->BindToStorage(nullptr, nullptr, IID_IPropertyBag, (void**)&bag) != S_OK)
|
if (m->BindToStorage(nullptr, nullptr, IID_IPropertyBag, reinterpret_cast<void**>(&bag)) != S_OK)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
var.vt = VT_BSTR;
|
var.vt = VT_BSTR;
|
||||||
|
@ -125,12 +125,12 @@ static IBaseFilter* getDevFilter(QString devName)
|
||||||
|
|
||||||
ICreateDevEnum* devenum = nullptr;
|
ICreateDevEnum* devenum = nullptr;
|
||||||
if (CoCreateInstance(CLSID_SystemDeviceEnum, nullptr, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum,
|
if (CoCreateInstance(CLSID_SystemDeviceEnum, nullptr, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum,
|
||||||
(void**)&devenum)
|
reinterpret_cast<void**>(&devenum))
|
||||||
!= S_OK)
|
!= S_OK)
|
||||||
return devFilter;
|
return devFilter;
|
||||||
|
|
||||||
IEnumMoniker* classenum = nullptr;
|
IEnumMoniker* classenum = nullptr;
|
||||||
if (devenum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, (IEnumMoniker**)&classenum, 0)
|
if (devenum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, reinterpret_cast<IEnumMoniker**>(&classenum), 0)
|
||||||
!= S_OK)
|
!= S_OK)
|
||||||
return devFilter;
|
return devFilter;
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ static IBaseFilter* getDevFilter(QString devName)
|
||||||
if (devName != devIdString)
|
if (devName != devIdString)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if (m->BindToObject(0, 0, IID_IBaseFilter, (void**)&devFilter) != S_OK)
|
if (m->BindToObject(0, 0, IID_IBaseFilter, reinterpret_cast<void**>(&devFilter)) != S_OK)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
|
@ -200,7 +200,7 @@ QVector<VideoMode> DirectShow::getDeviceModes(QString devName)
|
||||||
info.pFilter->Release();
|
info.pFilter->Release();
|
||||||
if (info.dir != PINDIR_OUTPUT)
|
if (info.dir != PINDIR_OUTPUT)
|
||||||
goto next;
|
goto next;
|
||||||
if (pin->QueryInterface(IID_IKsPropertySet, (void**)&p) != S_OK)
|
if (pin->QueryInterface(IID_IKsPropertySet, reinterpret_cast<void**>(&p)) != S_OK)
|
||||||
goto next;
|
goto next;
|
||||||
if (p->Get(AMPROPSETID_Pin, AMPROPERTY_PIN_CATEGORY, nullptr, 0, &category, sizeof(GUID), &r2)
|
if (p->Get(AMPROPSETID_Pin, AMPROPERTY_PIN_CATEGORY, nullptr, 0, &category, sizeof(GUID), &r2)
|
||||||
!= S_OK)
|
!= S_OK)
|
||||||
|
@ -214,7 +214,7 @@ QVector<VideoMode> DirectShow::getDeviceModes(QString devName)
|
||||||
IAMStreamConfig* config = nullptr;
|
IAMStreamConfig* config = nullptr;
|
||||||
VIDEO_STREAM_CONFIG_CAPS* vcaps = nullptr;
|
VIDEO_STREAM_CONFIG_CAPS* vcaps = nullptr;
|
||||||
int size, n;
|
int size, n;
|
||||||
if (pin->QueryInterface(IID_IAMStreamConfig, (void**)&config) != S_OK)
|
if (pin->QueryInterface(IID_IAMStreamConfig, reinterpret_cast<void**>(&config)) != S_OK)
|
||||||
goto next;
|
goto next;
|
||||||
if (config->GetNumberOfCapabilities(&n, &size) != S_OK)
|
if (config->GetNumberOfCapabilities(&n, &size) != S_OK)
|
||||||
goto pinend;
|
goto pinend;
|
||||||
|
@ -225,7 +225,7 @@ QVector<VideoMode> DirectShow::getDeviceModes(QString devName)
|
||||||
for (int i = 0; i < n; ++i) {
|
for (int i = 0; i < n; ++i) {
|
||||||
AM_MEDIA_TYPE* type = nullptr;
|
AM_MEDIA_TYPE* type = nullptr;
|
||||||
VideoMode mode;
|
VideoMode mode;
|
||||||
if (config->GetStreamCaps(i, &type, (BYTE*)vcaps) != S_OK)
|
if (config->GetStreamCaps(i, &type, reinterpret_cast<BYTE*>(vcaps)) != S_OK)
|
||||||
goto nextformat;
|
goto nextformat;
|
||||||
|
|
||||||
if (!IsEqualGUID(type->formattype, FORMAT_VideoInfo)
|
if (!IsEqualGUID(type->formattype, FORMAT_VideoInfo)
|
||||||
|
|
|
@ -206,7 +206,7 @@ QVector<QPair<QString, QString>> v4l2::getDeviceList()
|
||||||
ioctl(fd, VIDIOC_QUERYCAP, &caps);
|
ioctl(fd, VIDIOC_QUERYCAP, &caps);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
||||||
devices += {file, (const char*)caps.card};
|
devices += {file, reinterpret_cast<const char*>(caps.card)};
|
||||||
}
|
}
|
||||||
return devices;
|
return devices;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ uint32_t Platform::getIdleTime()
|
||||||
}
|
}
|
||||||
|
|
||||||
property = IORegistryEntryCreateCFProperty(service, CFSTR("HIDIdleTime"), kCFAllocatorDefault, 0);
|
property = IORegistryEntryCreateCFProperty(service, CFSTR("HIDIdleTime"), kCFAllocatorDefault, 0);
|
||||||
CFNumberGetValue((CFNumberRef)property, kCFNumberSInt64Type, &idleTime_ns);
|
CFNumberGetValue(static_cast<CFNumberRef>(property), kCFNumberSInt64Type, &idleTime_ns);
|
||||||
CFRelease(property);
|
CFRelease(property);
|
||||||
|
|
||||||
return idleTime_ns / 1000000;
|
return idleTime_ns / 1000000;
|
||||||
|
|
|
@ -39,7 +39,10 @@ uint32_t Platform::getIdleTime()
|
||||||
if (hasExtension) {
|
if (hasExtension) {
|
||||||
XScreenSaverInfo* info = XScreenSaverAllocInfo();
|
XScreenSaverInfo* info = XScreenSaverAllocInfo();
|
||||||
if (info) {
|
if (info) {
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||||
XScreenSaverQueryInfo(display, DefaultRootWindow(display), info);
|
XScreenSaverQueryInfo(display, DefaultRootWindow(display), info);
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
idleTime = info->idle;
|
idleTime = info->idle;
|
||||||
XFree(info);
|
XFree(info);
|
||||||
} else
|
} else
|
||||||
|
|
|
@ -22,8 +22,11 @@
|
||||||
#include <QDesktopWidget>
|
#include <QDesktopWidget>
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||||
#include <libavdevice/avdevice.h>
|
#include <libavdevice/avdevice.h>
|
||||||
#include <libavformat/avformat.h>
|
#include <libavformat/avformat.h>
|
||||||
|
#pragma GCC disagnostic pop
|
||||||
}
|
}
|
||||||
#include "cameradevice.h"
|
#include "cameradevice.h"
|
||||||
#include "src/persistence/settings.h"
|
#include "src/persistence/settings.h"
|
||||||
|
@ -294,7 +297,7 @@ QVector<QPair<QString, QString>> CameraDevice::getRawDeviceListGeneric()
|
||||||
return devices;
|
return devices;
|
||||||
}
|
}
|
||||||
if (s->iformat->priv_class) {
|
if (s->iformat->priv_class) {
|
||||||
*(const AVClass**)s->priv_data = s->iformat->priv_class;
|
*static_cast<const AVClass**>(s->priv_data) = s->iformat->priv_class;
|
||||||
av_opt_set_defaults(s->priv_data);
|
av_opt_set_defaults(s->priv_data);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -18,10 +18,13 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||||
#include <libavcodec/avcodec.h>
|
#include <libavcodec/avcodec.h>
|
||||||
#include <libavdevice/avdevice.h>
|
#include <libavdevice/avdevice.h>
|
||||||
#include <libavformat/avformat.h>
|
#include <libavformat/avformat.h>
|
||||||
#include <libswscale/swscale.h>
|
#include <libswscale/swscale.h>
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
}
|
}
|
||||||
#include "cameradevice.h"
|
#include "cameradevice.h"
|
||||||
#include "camerasource.h"
|
#include "camerasource.h"
|
||||||
|
|
|
@ -18,8 +18,11 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||||
#include <libavcodec/avcodec.h>
|
#include <libavcodec/avcodec.h>
|
||||||
#include <libavutil/imgutils.h>
|
#include <libavutil/imgutils.h>
|
||||||
|
#pragma GCC disagnostic pop
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "corevideosource.h"
|
#include "corevideosource.h"
|
||||||
|
|
|
@ -27,7 +27,10 @@
|
||||||
#include <QSize>
|
#include <QSize>
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wold-style-cast"
|
||||||
#include <libavcodec/avcodec.h>
|
#include <libavcodec/avcodec.h>
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
|
|
@ -728,7 +728,7 @@ bool GenericChatForm::loadHistoryFrom(const QDateTime &time)
|
||||||
|
|
||||||
void GenericChatForm::removeFirstsMessages(const int num)
|
void GenericChatForm::removeFirstsMessages(const int num)
|
||||||
{
|
{
|
||||||
if (messages.size() > num) {
|
if (static_cast<int>(messages.size()) > num) {
|
||||||
messages.erase(messages.begin(), std::next(messages.begin(), num));
|
messages.erase(messages.begin(), std::next(messages.begin(), num));
|
||||||
} else {
|
} else {
|
||||||
messages.clear();
|
messages.clear();
|
||||||
|
@ -737,7 +737,7 @@ void GenericChatForm::removeFirstsMessages(const int num)
|
||||||
|
|
||||||
void GenericChatForm::removeLastsMessages(const int num)
|
void GenericChatForm::removeLastsMessages(const int num)
|
||||||
{
|
{
|
||||||
if (messages.size() > num) {
|
if (static_cast<int>(messages.size()) > num) {
|
||||||
messages.erase(std::next(messages.end(), -num), messages.end());
|
messages.erase(std::next(messages.end(), -num), messages.end());
|
||||||
} else {
|
} else {
|
||||||
messages.clear();
|
messages.clear();
|
||||||
|
|
|
@ -102,9 +102,9 @@ void PrivacyForm::on_randomNosapamButton_clicked()
|
||||||
{
|
{
|
||||||
QTime time = QTime::currentTime();
|
QTime time = QTime::currentTime();
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
|
#if (QT_VERSION >= QT_VERSION_CHECK(5, 15, 0))
|
||||||
QRandomGenerator((uint)time.msec());
|
QRandomGenerator(static_cast<uint>(time.msec()));
|
||||||
#else
|
#else
|
||||||
qsrand((uint)time.msec());
|
qsrand(static_cast<uint>(time.msec()));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint32_t newNospam{0};
|
uint32_t newNospam{0};
|
||||||
|
|
|
@ -41,13 +41,13 @@ private:
|
||||||
static const QString testStr;
|
static const QString testStr;
|
||||||
static const QByteArray testByte;
|
static const QByteArray testByte;
|
||||||
static const uint8_t* testUINT8;
|
static const uint8_t* testUINT8;
|
||||||
static const size_t lengthUINT8;
|
static const int lengthUINT8;
|
||||||
|
|
||||||
//"" - empty test text
|
//"" - empty test text
|
||||||
static const QString emptyStr;
|
static const QString emptyStr;
|
||||||
static const QByteArray emptyByte;
|
static const QByteArray emptyByte;
|
||||||
static const uint8_t* emptyUINT8;
|
static const uint8_t* emptyUINT8;
|
||||||
static const size_t emptyLength;
|
static const int emptyLength;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -56,13 +56,13 @@ private:
|
||||||
const QString TestToxString::testStr = QStringLiteral("My Test String");
|
const QString TestToxString::testStr = QStringLiteral("My Test String");
|
||||||
const QByteArray TestToxString::testByte = QByteArrayLiteral("My Test String");
|
const QByteArray TestToxString::testByte = QByteArrayLiteral("My Test String");
|
||||||
const uint8_t* TestToxString::testUINT8 = reinterpret_cast<const uint8_t*>("My Test String");
|
const uint8_t* TestToxString::testUINT8 = reinterpret_cast<const uint8_t*>("My Test String");
|
||||||
const size_t TestToxString::lengthUINT8 = 14;
|
const int TestToxString::lengthUINT8 = 14;
|
||||||
|
|
||||||
//"" - empty test text
|
//"" - empty test text
|
||||||
const QString TestToxString::emptyStr = QStringLiteral("");
|
const QString TestToxString::emptyStr = QStringLiteral("");
|
||||||
const QByteArray TestToxString::emptyByte = QByteArrayLiteral("");
|
const QByteArray TestToxString::emptyByte = QByteArrayLiteral("");
|
||||||
const uint8_t* TestToxString::emptyUINT8 = reinterpret_cast<const uint8_t*>("");
|
const uint8_t* TestToxString::emptyUINT8 = reinterpret_cast<const uint8_t*>("");
|
||||||
const size_t TestToxString::emptyLength = 0;
|
const int TestToxString::emptyLength = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Use QString as input data, check output: QString, QByteArray, size_t and uint8_t
|
* @brief Use QString as input data, check output: QString, QByteArray, size_t and uint8_t
|
||||||
|
|
Loading…
Reference in New Issue
Block a user