Fix some compiler warnings.

Implements parts of
https://gitorious.org/keepassx/keepassx/merge_requests/18
This commit is contained in:
Felix Geyer 2012-07-08 10:56:56 +02:00
parent 98df309d28
commit 4b6cae0fcd
2 changed files with 8 additions and 5 deletions

View File

@ -694,7 +694,7 @@ bool KeePass1Reader::parseGroupTreeState(const QByteArray& data)
quint32 num = Endian::bytesToUInt32(data.mid(pos, 4), KeePass1::BYTEORDER);
pos += 4;
if ((data.size() - 4) != (num * 5)) {
if (static_cast<quint32>(data.size() - 4) != (num * 5)) {
return false;
}
@ -739,7 +739,7 @@ bool KeePass1Reader::parseCustomIcons4(const QByteArray& data)
quint32 iconSize = Endian::bytesToUInt32(data.mid(pos, 4), KeePass1::BYTEORDER);
pos += 4;
if (data.size() < (pos + iconSize)) {
if (static_cast<quint32>(data.size()) < (pos + iconSize)) {
return false;
}
QImage icon = QImage::fromData(data.mid(pos, iconSize));
@ -754,7 +754,7 @@ bool KeePass1Reader::parseCustomIcons4(const QByteArray& data)
m_db->metadata()->addCustomIcon(uuid, icon);
}
if (data.size() < (pos + numEntries * 20)) {
if (static_cast<quint32>(data.size()) < (pos + numEntries * 20)) {
return false;
}
@ -770,7 +770,7 @@ bool KeePass1Reader::parseCustomIcons4(const QByteArray& data)
}
}
if (data.size() < (pos + numGroups * 8)) {
if (static_cast<quint32>(data.size()) < (pos + numGroups * 8)) {
return false;
}

View File

@ -121,10 +121,13 @@ bool KeePass2Writer::writeData(const QByteArray& data)
bool KeePass2Writer::writeHeaderField(KeePass2::HeaderFieldID fieldId, const QByteArray& data)
{
Q_ASSERT(data.size() <= 65535);
QByteArray fieldIdArr;
fieldIdArr[0] = fieldId;
CHECK_RETURN_FALSE(writeData(fieldIdArr));
CHECK_RETURN_FALSE(writeData(Endian::int16ToBytes(data.size(), KeePass2::BYTEORDER)));
CHECK_RETURN_FALSE(writeData(Endian::int16ToBytes(static_cast<quint16>(data.size()),
KeePass2::BYTEORDER)));
CHECK_RETURN_FALSE(writeData(data));
return true;