From 5935ea0691243611e482142e4ddbd0f5960981a2 Mon Sep 17 00:00:00 2001 From: Martchus Date: Sat, 20 Mar 2021 21:55:40 +0100 Subject: [PATCH] Fix warnings --- CMakeLists.txt | 2 +- io/entry.cpp | 14 +++++++------- io/field.cpp | 2 +- io/passwordfile.cpp | 2 +- tests/opensslutils.cpp | 2 +- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9eb5906..c9f93ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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_VERSION_MAJOR 5) set(META_VERSION_MINOR 0) -set(META_VERSION_PATCH 4) +set(META_VERSION_PATCH 5) set(META_ADD_DEFAULT_CPP_UNIT_TEST_APPLICATION ON) # add project files diff --git a/io/entry.cpp b/io/entry.cpp index efc7bb6..d89c4f7 100644 --- a/io/entry.cpp +++ b/io/entry.cpp @@ -114,7 +114,7 @@ void Entry::setParent(NodeEntry *parent, int index) // attach the new parent if (parent) { if (index < 0 || static_cast(index) >= parent->m_children.size()) { - m_index = parent->m_children.size(); + m_index = static_cast(parent->m_children.size()); parent->m_children.push_back(this); } else { 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) { Entry *clonedChild = otherChild->clone(); clonedChild->m_parent = this; - clonedChild->m_index = m_children.size(); + clonedChild->m_index = static_cast(m_children.size()); m_children.push_back(clonedChild); } } @@ -334,7 +334,7 @@ void NodeEntry::replaceChild(size_t at, Entry *newChild) // do the actual assignment newChild->m_parent = this; - newChild->m_index = at; + newChild->m_index = static_cast(at); m_children[at] = newChild; } @@ -398,7 +398,7 @@ void NodeEntry::make(ostream &stream) const writer.writeByte(isExpandedByDefault() && m_extendedData.empty() ? 0x0 : 0x1); // version writer.writeLengthPrefixedString(label()); if (!isExpandedByDefault() || !m_extendedData.empty()) { - writer.writeUInt16BE(1 + m_extendedData.size()); // extended header is 1 byte long + writer.writeUInt16BE(static_cast(1 + m_extendedData.size())); // extended header is 1 byte long std::uint8_t flags = 0x00; if (isExpandedByDefault()) { flags |= 0x80; @@ -406,7 +406,7 @@ void NodeEntry::make(ostream &stream) const writer.writeByte(flags); writer.writeString(m_extendedData); } - writer.writeUInt32BE(m_children.size()); + writer.writeUInt32BE(static_cast(m_children.size())); for (const Entry *const child : m_children) { child->make(stream); } @@ -496,10 +496,10 @@ void AccountEntry::make(ostream &stream) const writer.writeByte(0x80 | (m_extendedData.empty() ? 0x0 : 0x1)); // version writer.writeLengthPrefixedString(label()); if (!m_extendedData.empty()) { - writer.writeUInt16BE(m_extendedData.size()); + writer.writeUInt16BE(static_cast(m_extendedData.size())); writer.writeString(m_extendedData); } - writer.writeUInt32BE(m_fields.size()); + writer.writeUInt32BE(static_cast(m_fields.size())); for (const Field &field : m_fields) { field.make(stream); } diff --git a/io/field.cpp b/io/field.cpp index 95944db..301ee91 100644 --- a/io/field.cpp +++ b/io/field.cpp @@ -66,7 +66,7 @@ void Field::make(ostream &stream) const writer.writeLengthPrefixedString(m_value); writer.writeByte(static_cast(m_type)); if (!m_extendedData.empty()) { - writer.writeUInt16BE(m_extendedData.size()); + writer.writeUInt16BE(static_cast(m_extendedData.size())); writer.writeString(m_extendedData); } } diff --git a/io/passwordfile.cpp b/io/passwordfile.cpp index 4ebe481..4db0759 100644 --- a/io/passwordfile.cpp +++ b/io/passwordfile.cpp @@ -398,7 +398,7 @@ void PasswordFile::save(PasswordFileSaveFlags options) } // 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); } else { m_file.clear(); diff --git a/tests/opensslutils.cpp b/tests/opensslutils.cpp index a5cc880..da1468d 100644 --- a/tests/opensslutils.cpp +++ b/tests/opensslutils.cpp @@ -49,7 +49,7 @@ void OpenSslUtilsTests::testComputeSha256Sum() string sumAsHex; sumAsHex.reserve(64); for (unsigned char hashNumber : sum.data) { - const string digits = numberToString(hashNumber, 16); + const string digits = numberToString(hashNumber, static_cast(16)); sumAsHex.push_back(digits.size() < 2 ? '0' : digits.front()); sumAsHex.push_back(digits.back()); }