Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJanek Bevendorff <janek@jbev.net>2018-01-06 19:06:51 +0300
committerJonathan White <support@dmapps.us>2018-01-13 22:24:57 +0300
commitccfd7a065c821b3075144f497ddff6b4c80598f1 (patch)
treeb5afccecd7d4aacd6f5c4decb581d64de63c6dd4 /src/streams
parent54fb0d9bd331d6f5567360e772a4e1b44587a75b (diff)
Fix coding style and GUI test
Diffstat (limited to 'src/streams')
-rw-r--r--src/streams/HmacBlockStream.cpp34
-rw-r--r--src/streams/SymmetricCipherStream.cpp3
2 files changed, 15 insertions, 22 deletions
diff --git a/src/streams/HmacBlockStream.cpp b/src/streams/HmacBlockStream.cpp
index 677921a60..780db98c1 100644
--- a/src/streams/HmacBlockStream.cpp
+++ b/src/streams/HmacBlockStream.cpp
@@ -57,10 +57,8 @@ bool HmacBlockStream::reset()
// Write final block(s) only if device is writable and we haven't
// already written a final block.
if (isWritable() && (!m_buffer.isEmpty() || m_blockIndex != 0)) {
- if (!m_buffer.isEmpty()) {
- if (!writeHashedBlock()) {
- return false;
- }
+ if (!m_buffer.isEmpty() && !writeHashedBlock()) {
+ return false;
}
// write empty final block
@@ -106,15 +104,14 @@ qint64 HmacBlockStream::readData(char* data, qint64 maxSize)
if (!readHashedBlock()) {
if (m_error) {
return -1;
- } else {
- return maxSize - bytesRemaining;
}
+ return maxSize - bytesRemaining;
}
}
- int bytesToCopy = qMin(bytesRemaining, static_cast<qint64>(m_buffer.size() - m_bufferPos));
+ qint64 bytesToCopy = qMin(bytesRemaining, static_cast<qint64>(m_buffer.size() - m_bufferPos));
- memcpy(data + offset, m_buffer.constData() + m_bufferPos, bytesToCopy);
+ memcpy(data + offset, m_buffer.constData() + m_bufferPos, static_cast<size_t>(bytesToCopy));
offset += bytesToCopy;
m_bufferPos += bytesToCopy;
@@ -142,7 +139,7 @@ bool HmacBlockStream::readHashedBlock()
setErrorString("Invalid block size size.");
return false;
}
- qint32 blockSize = Endian::bytesToSizedInt<qint32>(blockSizeBytes, ByteOrder);
+ auto blockSize = Endian::bytesToSizedInt<qint32>(blockSizeBytes, ByteOrder);
if (blockSize < 0) {
m_error = true;
setErrorString("Invalid block size.");
@@ -169,7 +166,7 @@ bool HmacBlockStream::readHashedBlock()
}
m_bufferPos = 0;
- m_blockIndex++;
+ ++m_blockIndex;
if (blockSize == 0) {
m_eof = true;
@@ -191,21 +188,18 @@ qint64 HmacBlockStream::writeData(const char* data, qint64 maxSize)
qint64 offset = 0;
while (bytesRemaining > 0) {
- int bytesToCopy = qMin(bytesRemaining, static_cast<qint64>(m_blockSize - m_buffer.size()));
+ qint64 bytesToCopy = qMin(bytesRemaining, static_cast<qint64>(m_blockSize - m_buffer.size()));
- m_buffer.append(data + offset, bytesToCopy);
+ m_buffer.append(data + offset, static_cast<int>(bytesToCopy));
offset += bytesToCopy;
bytesRemaining -= bytesToCopy;
- if (m_buffer.size() == m_blockSize) {
- if (!writeHashedBlock()) {
- if (m_error) {
- return -1;
- } else {
- return maxSize - bytesRemaining;
- }
+ if (m_buffer.size() == m_blockSize && !writeHashedBlock()) {
+ if (m_error) {
+ return -1;
}
+ return maxSize - bytesRemaining;
}
}
@@ -242,7 +236,7 @@ bool HmacBlockStream::writeHashedBlock()
m_buffer.clear();
}
- m_blockIndex++;
+ ++m_blockIndex;
return true;
}
diff --git a/src/streams/SymmetricCipherStream.cpp b/src/streams/SymmetricCipherStream.cpp
index ece2642b5..78476c618 100644
--- a/src/streams/SymmetricCipherStream.cpp
+++ b/src/streams/SymmetricCipherStream.cpp
@@ -252,7 +252,6 @@ bool SymmetricCipherStream::writeBlock(bool lastBlock)
int SymmetricCipherStream::blockSize() const {
if (m_streamCipher) {
return 1024;
- } else {
- return m_cipher->blockSize();
}
+ return m_cipher->blockSize();
}