Fix warnings

This commit is contained in:
Martchus 2021-03-20 21:55:40 +01:00
parent f7c6db0132
commit 5935ea0691
5 changed files with 11 additions and 11 deletions

View File

@ -10,7 +10,7 @@ set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}")
set(META_APP_DESCRIPTION "C++ library to read/write passwords from/to encrypted files") set(META_APP_DESCRIPTION "C++ library to read/write passwords from/to encrypted files")
set(META_VERSION_MAJOR 5) set(META_VERSION_MAJOR 5)
set(META_VERSION_MINOR 0) set(META_VERSION_MINOR 0)
set(META_VERSION_PATCH 4) set(META_VERSION_PATCH 5)
set(META_ADD_DEFAULT_CPP_UNIT_TEST_APPLICATION ON) set(META_ADD_DEFAULT_CPP_UNIT_TEST_APPLICATION ON)
# add project files # add project files

View File

@ -114,7 +114,7 @@ void Entry::setParent(NodeEntry *parent, int index)
// attach the new parent // attach the new parent
if (parent) { if (parent) {
if (index < 0 || static_cast<size_t>(index) >= parent->m_children.size()) { if (index < 0 || static_cast<size_t>(index) >= parent->m_children.size()) {
m_index = parent->m_children.size(); m_index = static_cast<int>(parent->m_children.size());
parent->m_children.push_back(this); parent->m_children.push_back(this);
} else { } else {
for (auto i = parent->m_children.insert(parent->m_children.begin() + index, this) + 1; i != parent->m_children.end(); ++i) { for (auto i = parent->m_children.insert(parent->m_children.begin() + index, this) + 1; i != parent->m_children.end(); ++i) {
@ -265,7 +265,7 @@ NodeEntry::NodeEntry(const NodeEntry &other)
for (Entry *const otherChild : other.m_children) { for (Entry *const otherChild : other.m_children) {
Entry *clonedChild = otherChild->clone(); Entry *clonedChild = otherChild->clone();
clonedChild->m_parent = this; clonedChild->m_parent = this;
clonedChild->m_index = m_children.size(); clonedChild->m_index = static_cast<int>(m_children.size());
m_children.push_back(clonedChild); m_children.push_back(clonedChild);
} }
} }
@ -334,7 +334,7 @@ void NodeEntry::replaceChild(size_t at, Entry *newChild)
// do the actual assignment // do the actual assignment
newChild->m_parent = this; newChild->m_parent = this;
newChild->m_index = at; newChild->m_index = static_cast<int>(at);
m_children[at] = newChild; m_children[at] = newChild;
} }
@ -398,7 +398,7 @@ void NodeEntry::make(ostream &stream) const
writer.writeByte(isExpandedByDefault() && m_extendedData.empty() ? 0x0 : 0x1); // version writer.writeByte(isExpandedByDefault() && m_extendedData.empty() ? 0x0 : 0x1); // version
writer.writeLengthPrefixedString(label()); writer.writeLengthPrefixedString(label());
if (!isExpandedByDefault() || !m_extendedData.empty()) { if (!isExpandedByDefault() || !m_extendedData.empty()) {
writer.writeUInt16BE(1 + m_extendedData.size()); // extended header is 1 byte long writer.writeUInt16BE(static_cast<std::uint16_t>(1 + m_extendedData.size())); // extended header is 1 byte long
std::uint8_t flags = 0x00; std::uint8_t flags = 0x00;
if (isExpandedByDefault()) { if (isExpandedByDefault()) {
flags |= 0x80; flags |= 0x80;
@ -406,7 +406,7 @@ void NodeEntry::make(ostream &stream) const
writer.writeByte(flags); writer.writeByte(flags);
writer.writeString(m_extendedData); writer.writeString(m_extendedData);
} }
writer.writeUInt32BE(m_children.size()); writer.writeUInt32BE(static_cast<std::uint32_t>(m_children.size()));
for (const Entry *const child : m_children) { for (const Entry *const child : m_children) {
child->make(stream); child->make(stream);
} }
@ -496,10 +496,10 @@ void AccountEntry::make(ostream &stream) const
writer.writeByte(0x80 | (m_extendedData.empty() ? 0x0 : 0x1)); // version writer.writeByte(0x80 | (m_extendedData.empty() ? 0x0 : 0x1)); // version
writer.writeLengthPrefixedString(label()); writer.writeLengthPrefixedString(label());
if (!m_extendedData.empty()) { if (!m_extendedData.empty()) {
writer.writeUInt16BE(m_extendedData.size()); writer.writeUInt16BE(static_cast<std::uint16_t>(m_extendedData.size()));
writer.writeString(m_extendedData); writer.writeString(m_extendedData);
} }
writer.writeUInt32BE(m_fields.size()); writer.writeUInt32BE(static_cast<std::uint32_t>(m_fields.size()));
for (const Field &field : m_fields) { for (const Field &field : m_fields) {
field.make(stream); field.make(stream);
} }

View File

@ -66,7 +66,7 @@ void Field::make(ostream &stream) const
writer.writeLengthPrefixedString(m_value); writer.writeLengthPrefixedString(m_value);
writer.writeByte(static_cast<std::uint8_t>(m_type)); writer.writeByte(static_cast<std::uint8_t>(m_type));
if (!m_extendedData.empty()) { if (!m_extendedData.empty()) {
writer.writeUInt16BE(m_extendedData.size()); writer.writeUInt16BE(static_cast<std::uint16_t>(m_extendedData.size()));
writer.writeString(m_extendedData); writer.writeString(m_extendedData);
} }
} }

View File

@ -398,7 +398,7 @@ void PasswordFile::save(PasswordFileSaveFlags options)
} }
// use already opened and writable file; otherwise re-open the file // use already opened and writable file; otherwise re-open the file
if (m_file.good() && m_file.is_open() && (m_file.flags() & ios_base::out)) { if (m_file.good() && m_file.is_open() && !(m_openOptions & PasswordFileOpenFlags::ReadOnly)) {
m_file.seekp(0); m_file.seekp(0);
} else { } else {
m_file.clear(); m_file.clear();

View File

@ -49,7 +49,7 @@ void OpenSslUtilsTests::testComputeSha256Sum()
string sumAsHex; string sumAsHex;
sumAsHex.reserve(64); sumAsHex.reserve(64);
for (unsigned char hashNumber : sum.data) { for (unsigned char hashNumber : sum.data) {
const string digits = numberToString(hashNumber, 16); const string digits = numberToString(hashNumber, static_cast<unsigned char>(16));
sumAsHex.push_back(digits.size() < 2 ? '0' : digits.front()); sumAsHex.push_back(digits.size() < 2 ? '0' : digits.front());
sumAsHex.push_back(digits.back()); sumAsHex.push_back(digits.back());
} }