diff --git a/src/cpp-utils/crypto/symmetric/testutils/FakeAuthenticatedCipher.h b/src/cpp-utils/crypto/symmetric/testutils/FakeAuthenticatedCipher.h index 79c59f46..9f5215f6 100644 --- a/src/cpp-utils/crypto/symmetric/testutils/FakeAuthenticatedCipher.h +++ b/src/cpp-utils/crypto/symmetric/testutils/FakeAuthenticatedCipher.h @@ -14,7 +14,7 @@ namespace cpputils { struct FakeKey { static FakeKey FromString(const std::string& keyData) { - return FakeKey{static_cast(std::atoi(keyData.c_str()))}; + return FakeKey{static_cast(std::strtol(keyData.c_str(), nullptr, 10))}; } static constexpr unsigned int BINARY_LENGTH = sizeof(uint64_t); diff --git a/src/cpp-utils/data/Data.cpp b/src/cpp-utils/data/Data.cpp index 9b749121..c8a3a25b 100644 --- a/src/cpp-utils/data/Data.cpp +++ b/src/cpp-utils/data/Data.cpp @@ -47,21 +47,25 @@ Data Data::LoadFromStream(istream &stream, size_t size) { Data Data::FromString(const std::string &data, unique_ref allocator) { ASSERT(data.size() % 2 == 0, "hex encoded data cannot have odd number of characters"); Data result(data.size() / 2, std::move(allocator)); - CryptoPP::StringSource(data, true, - new CryptoPP::HexDecoder( - new CryptoPP::ArraySink(static_cast(result._data), result.size()) - ) - ); + { + CryptoPP::StringSource _1(data, true, + new CryptoPP::HexDecoder( + new CryptoPP::ArraySink(static_cast(result._data), result.size()) + ) + ); + } return result; } std::string Data::ToString() const { std::string result; - CryptoPP::ArraySource(static_cast(_data), _size, true, - new CryptoPP::HexEncoder( - new CryptoPP::StringSink(result) - ) - ); + { + CryptoPP::ArraySource _1(static_cast(_data), _size, true, + new CryptoPP::HexEncoder( + new CryptoPP::StringSink(result) + ) + ); + } ASSERT(result.size() == 2 * _size, "Created wrongly sized string"); return result; } diff --git a/src/cpp-utils/data/FixedSizeData.h b/src/cpp-utils/data/FixedSizeData.h index 5c8c1a69..c4a88d73 100644 --- a/src/cpp-utils/data/FixedSizeData.h +++ b/src/cpp-utils/data/FixedSizeData.h @@ -59,11 +59,13 @@ template FixedSizeData FixedSizeData::FromString(const std::string &data) { ASSERT(data.size() == STRING_LENGTH, "Wrong string size for parsing FixedSizeData"); FixedSizeData result; - CryptoPP::StringSource(data, true, - new CryptoPP::HexDecoder( - new CryptoPP::ArraySink(result._data, BINARY_LENGTH) - ) - ); + { + CryptoPP::StringSource _1(data, true, + new CryptoPP::HexDecoder( + new CryptoPP::ArraySink(result._data, BINARY_LENGTH) + ) + ); + } return result; } diff --git a/src/cpp-utils/pointer/cast.h b/src/cpp-utils/pointer/cast.h index be45ab87..f7483ec2 100644 --- a/src/cpp-utils/pointer/cast.h +++ b/src/cpp-utils/pointer/cast.h @@ -15,7 +15,7 @@ inline std::unique_ptr dynamic_pointer_move(std::unique_ptr &source) { //TODO Deleter DST *casted = dynamic_cast(source.get()); if (casted != nullptr) { - source.release(); + std::ignore = source.release(); } return std::unique_ptr(casted); } diff --git a/src/cpp-utils/pointer/unique_ref.h b/src/cpp-utils/pointer/unique_ref.h index a21e9f1f..89e0d238 100644 --- a/src/cpp-utils/pointer/unique_ref.h +++ b/src/cpp-utils/pointer/unique_ref.h @@ -108,7 +108,7 @@ private: explicit unique_ref(std::unique_ptr target) noexcept : _target(std::move(target)) {} - void _invariant() const { + void _invariant() const noexcept { // TODO Test performance impact of this ASSERT(_target.get() != nullptr, "Member was moved out to another unique_ref. This instance is invalid."); } diff --git a/src/cpp-utils/system/filetime_nonwindows.cpp b/src/cpp-utils/system/filetime_nonwindows.cpp index 063fbd88..344f0c0e 100644 --- a/src/cpp-utils/system/filetime_nonwindows.cpp +++ b/src/cpp-utils/system/filetime_nonwindows.cpp @@ -22,7 +22,7 @@ int set_filetime(const char *filepath, timespec lastAccessTime, timespec lastMod } int get_filetime(const char *filepath, timespec* lastAccessTime, timespec* lastModificationTime) { - struct ::stat attrib; + struct ::stat attrib{}; int retval = ::stat(filepath, &attrib); if (retval != 0) { return errno; diff --git a/src/cpp-utils/system/time.cpp b/src/cpp-utils/system/time.cpp index a599faa4..cb292c33 100644 --- a/src/cpp-utils/system/time.cpp +++ b/src/cpp-utils/system/time.cpp @@ -11,7 +11,7 @@ namespace time { struct timespec now() { auto now = system_clock::now().time_since_epoch(); - struct timespec spec; + struct timespec spec{}; spec.tv_sec = duration_cast(now).count(); spec.tv_nsec = duration_cast(now).count() % 1000000000; return spec; diff --git a/src/cpp-utils/value_type/ValueType.h b/src/cpp-utils/value_type/ValueType.h index 86b604f8..031cc00a 100644 --- a/src/cpp-utils/value_type/ValueType.h +++ b/src/cpp-utils/value_type/ValueType.h @@ -139,7 +139,7 @@ public: return *static_cast(this); } - constexpr ConcreteType operator++(int) noexcept(noexcept(++std::declval())) { + constexpr const ConcreteType operator++(int) noexcept(noexcept(++std::declval())) { ConcreteType tmp = *static_cast(this); ++(*this); return tmp; @@ -150,7 +150,7 @@ public: return *static_cast(this); } - constexpr ConcreteType operator--(int) noexcept(noexcept(--std::declval())) { + constexpr const ConcreteType operator--(int) noexcept(noexcept(--std::declval())) { ConcreteType tmp = *static_cast(this); --(*this); return tmp; diff --git a/src/cryfs-cli/Cli.cpp b/src/cryfs-cli/Cli.cpp index 93e2aa3b..366ac035 100644 --- a/src/cryfs-cli/Cli.cpp +++ b/src/cryfs-cli/Cli.cpp @@ -44,8 +44,6 @@ using cpputils::unique_ref; using cpputils::SCryptSettings; using cpputils::Console; using cpputils::HttpClient; -using cpputils::DontEchoStdinToStdoutRAII; -using std::cin; using std::cout; using std::string; using std::endl; @@ -272,7 +270,7 @@ namespace cryfs { if (minutes == none) { return none; } - uint64_t millis = std::round(60000 * (*minutes)); + uint64_t millis = std::llround(60000 * (*minutes)); return make_unique_ref(milliseconds(millis), callback); } diff --git a/src/cryfs-cli/program_options/Parser.cpp b/src/cryfs-cli/program_options/Parser.cpp index db3c73ef..89a6042f 100644 --- a/src/cryfs-cli/program_options/Parser.cpp +++ b/src/cryfs-cli/program_options/Parser.cpp @@ -12,10 +12,8 @@ using namespace cryfs::program_options; using cryfs::CryConfigConsole; using cryfs::CryfsException; using cryfs::ErrorCode; -using std::pair; using std::vector; using std::cerr; -using std::cout; using std::endl; using std::string; using boost::optional; diff --git a/src/cryfs/config/CryCipher.cpp b/src/cryfs/config/CryCipher.cpp index bff577ff..bb1f414d 100644 --- a/src/cryfs/config/CryCipher.cpp +++ b/src/cryfs/config/CryCipher.cpp @@ -8,7 +8,6 @@ using std::vector; using std::string; using cpputils::unique_ref; using cpputils::make_unique_ref; -using cpputils::FixedSizeData; using blockstore::BlockStore2; using std::shared_ptr; using std::make_shared; diff --git a/src/cryfs/config/crypto/CryConfigEncryptor.cpp b/src/cryfs/config/crypto/CryConfigEncryptor.cpp index 59a2833b..487ba816 100644 --- a/src/cryfs/config/crypto/CryConfigEncryptor.cpp +++ b/src/cryfs/config/crypto/CryConfigEncryptor.cpp @@ -5,7 +5,6 @@ using std::string; using cpputils::unique_ref; using cpputils::make_unique_ref; using cpputils::Data; -using cpputils::FixedSizeData; using boost::optional; using boost::none; using namespace cpputils::logging; diff --git a/src/fspp/fs_interface/Types.h b/src/fspp/fs_interface/Types.h index 0aee64b9..ae2e72ff 100644 --- a/src/fspp/fs_interface/Types.h +++ b/src/fspp/fs_interface/Types.h @@ -157,15 +157,15 @@ struct num_bytes_t final : cpputils::value_type::QuantityValueTypecreateNewInnerNode(1, {leaf->blockId()}); auto block = blockStore->load(node->blockId()).value(); EXPECT_EQ(BLOCKSIZE_BYTES, block->size()); -} \ No newline at end of file +} diff --git a/test/blockstore/implementations/encrypted/EncryptedBlockStoreTest_Generic.cpp b/test/blockstore/implementations/encrypted/EncryptedBlockStoreTest_Generic.cpp index 613202ad..61171e32 100644 --- a/test/blockstore/implementations/encrypted/EncryptedBlockStoreTest_Generic.cpp +++ b/test/blockstore/implementations/encrypted/EncryptedBlockStoreTest_Generic.cpp @@ -20,7 +20,6 @@ using cpputils::AES256_GCM; using cpputils::AES256_CFB; using cpputils::FakeAuthenticatedCipher; -using cpputils::Data; using cpputils::DataFixture; using cpputils::make_unique_ref; using cpputils::unique_ref; diff --git a/test/blockstore/implementations/integrity/KnownBlockVersionsTest.cpp b/test/blockstore/implementations/integrity/KnownBlockVersionsTest.cpp index fd693cbb..772fb65d 100644 --- a/test/blockstore/implementations/integrity/KnownBlockVersionsTest.cpp +++ b/test/blockstore/implementations/integrity/KnownBlockVersionsTest.cpp @@ -231,7 +231,9 @@ TEST_F(KnownBlockVersionsTest, checkAndUpdate_doesntAllowRollbackToOldClientWith TEST_F(KnownBlockVersionsTest, saveAndLoad_empty) { TempFile stateFile(false); - KnownBlockVersions(stateFile.path(), myClientId); + { + KnownBlockVersions _1(stateFile.path(), myClientId); + } EXPECT_TRUE(KnownBlockVersions(stateFile.path(), myClientId).checkAndUpdateVersion(clientId, blockId, 1)); } diff --git a/test/cpp-utils/assert/assert_release_test.cpp b/test/cpp-utils/assert/assert_release_test.cpp index aa76a6be..3b814e68 100644 --- a/test/cpp-utils/assert/assert_release_test.cpp +++ b/test/cpp-utils/assert/assert_release_test.cpp @@ -8,7 +8,6 @@ #endif #include "cpp-utils/assert/assert.h" -using testing::MatchesRegex; using testing::HasSubstr; TEST(AssertTest_ReleaseBuild, DoesntThrowIfTrue) { @@ -32,7 +31,7 @@ TEST(AssertTest_ReleaseBuild, AssertMessage) { /*EXPECT_THAT(e.what(), MatchesRegex( R"(Assertion \[2==5\] failed in .*assert_release_test.cpp:27: my message)" ));*/ - EXPECT_TRUE(std::regex_search(e.what(), std::regex(R"(Assertion \[2==5\] failed in .*assert_release_test.cpp:27: my message)"))); + EXPECT_TRUE(std::regex_search(e.what(), std::regex(R"(Assertion \[2==5\] failed in .*assert_release_test.cpp:26: my message)"))); } } diff --git a/test/cpp-utils/assert/exit_signal.cpp b/test/cpp-utils/assert/exit_signal.cpp index 4673703a..f0abb696 100644 --- a/test/cpp-utils/assert/exit_signal.cpp +++ b/test/cpp-utils/assert/exit_signal.cpp @@ -12,20 +12,20 @@ void handle_exit_signal(char* argv[]) { throw std::logic_error(argv[2]); } else if (kind == "nullptr") { int* ptr = nullptr; - *ptr = 5; + *ptr = 5; // NOLINT } else if (kind == "signal") { #if defined(_MSC_VER) DWORD code = std::atoll(argv[2]); ::RaiseException(code, EXCEPTION_NONCONTINUABLE, 0, NULL); #else - int code = std::atoi(argv[2]); + int code = std::strtol(argv[2], nullptr, 10); ::raise(code); #endif } } -int main(int argc, char* argv[]) { +int main(int /*argc*/, char* argv[]) { cpputils::showBacktraceOnCrash(); #if defined(_MSC_VER) // don't show windows error box diff --git a/test/cpp-utils/data/DataTest.cpp b/test/cpp-utils/data/DataTest.cpp index a382f37f..7875e2ac 100644 --- a/test/cpp-utils/data/DataTest.cpp +++ b/test/cpp-utils/data/DataTest.cpp @@ -197,7 +197,7 @@ TEST_F(DataTest, Inequality_DifferentLastByte) { #ifdef __x86_64__ TEST_F(DataTest, LargesizeSize) { //Needs 64bit for representation. This value isn't in the size param list, because the list is also used for read/write checks. - uint64_t size = 4.5L*1024*1024*1024; + uint64_t size = static_cast(4.5L*1024*1024*1024); Data data(size); EXPECT_EQ(size, data.size()); } @@ -235,7 +235,7 @@ struct MockAllocator final : public Allocator { class DataTestWithMockAllocator: public DataTest { public: - char ptr_target; + char ptr_target{}; unique_ref allocator = make_unique_ref(); MockAllocator* allocator_ptr = allocator.get(); diff --git a/test/cpp-utils/logging/LoggingLevelTest.cpp b/test/cpp-utils/logging/LoggingLevelTest.cpp index 9dcccb27..624608f4 100644 --- a/test/cpp-utils/logging/LoggingLevelTest.cpp +++ b/test/cpp-utils/logging/LoggingLevelTest.cpp @@ -3,7 +3,6 @@ using namespace cpputils::logging; using std::string; -using testing::MatchesRegex; class LoggingLevelTest: public LoggingTest { public: diff --git a/test/cpp-utils/logging/LoggingTest.cpp b/test/cpp-utils/logging/LoggingTest.cpp index e5b81696..2cfd6f61 100644 --- a/test/cpp-utils/logging/LoggingTest.cpp +++ b/test/cpp-utils/logging/LoggingTest.cpp @@ -8,7 +8,6 @@ using namespace cpputils::logging; using std::string; -using testing::MatchesRegex; TEST_F(LoggingTest, DefaultLoggerIsStderr) { string output = captureStderr([]{ diff --git a/test/cpp-utils/process/exit_status.cpp b/test/cpp-utils/process/exit_status.cpp index b4d7e73d..3d72f6b1 100644 --- a/test/cpp-utils/process/exit_status.cpp +++ b/test/cpp-utils/process/exit_status.cpp @@ -11,6 +11,6 @@ int main(int argc, char* argv[]) { std::cout << argv[1]; - int exit_status = std::atoi(argv[2]); + int exit_status = std::strtol(argv[2], nullptr, 10); return exit_status; } diff --git a/test/cpp-utils/system/FiletimeTest.cpp b/test/cpp-utils/system/FiletimeTest.cpp index 29d0d843..09c1b9a7 100644 --- a/test/cpp-utils/system/FiletimeTest.cpp +++ b/test/cpp-utils/system/FiletimeTest.cpp @@ -13,8 +13,8 @@ TEST(FiletimeTest, SetAndGetTime_ReturnsCorrectTime) { int retval = set_filetime(file.path().string().c_str(), accessTime, modificationTime); EXPECT_EQ(0, retval); - struct timespec readAccessTime; - struct timespec readModificationTime; + struct timespec readAccessTime{}; + struct timespec readModificationTime{}; retval = get_filetime(file.path().string().c_str(), &readAccessTime, &readModificationTime); EXPECT_EQ(0, retval); diff --git a/test/cryfs/config/CompatibilityTest.cpp b/test/cryfs/config/CompatibilityTest.cpp index 5c8575bb..6a8db504 100644 --- a/test/cryfs/config/CompatibilityTest.cpp +++ b/test/cryfs/config/CompatibilityTest.cpp @@ -35,11 +35,13 @@ private: Data hexToBinary(const string &hex) { ASSERT(hex.size()%2 == 0, "Hex codes need to have two characters per byte"); Data result(hex.size()/2); - CryptoPP::StringSource(hex, true, - new CryptoPP::HexDecoder( - new CryptoPP::ArraySink(static_cast(result.data()), result.size()) - ) - ); + { + CryptoPP::StringSource _1(hex, true, + new CryptoPP::HexDecoder( + new CryptoPP::ArraySink(static_cast(result.data()), result.size()) + ) + ); + } return result; } diff --git a/test/cryfs/config/crypto/CryConfigEncryptorTest.cpp b/test/cryfs/config/crypto/CryConfigEncryptorTest.cpp index 26961339..66f3e705 100644 --- a/test/cryfs/config/crypto/CryConfigEncryptorTest.cpp +++ b/test/cryfs/config/crypto/CryConfigEncryptorTest.cpp @@ -9,7 +9,6 @@ using cpputils::make_unique_ref; using cpputils::DataFixture; using cpputils::Data; using cpputils::EncryptionKey; -using cpputils::FixedSizeData; using cpputils::AES128_CFB; using cpputils::AES256_GCM; using cpputils::Twofish256_GCM; diff --git a/test/fspp/fuse/read/testutils/FuseReadTest.h b/test/fspp/fuse/read/testutils/FuseReadTest.h index 30bbbe88..7827d521 100644 --- a/test/fspp/fuse/read/testutils/FuseReadTest.h +++ b/test/fspp/fuse/read/testutils/FuseReadTest.h @@ -10,7 +10,7 @@ public: const char *FILENAME = "/myfile"; struct ReadError { - int error; + int error{}; fspp::num_bytes_t read_bytes; }; diff --git a/test/fspp/fuse/statfs/FuseStatfsErrorTest.cpp b/test/fspp/fuse/statfs/FuseStatfsErrorTest.cpp index e37687c3..21cd9004 100644 --- a/test/fspp/fuse/statfs/FuseStatfsErrorTest.cpp +++ b/test/fspp/fuse/statfs/FuseStatfsErrorTest.cpp @@ -2,7 +2,6 @@ #include "fspp/fs_interface/FuseErrnoException.h" -using ::testing::StrEq; using ::testing::_; using ::testing::Throw; using ::testing::Return; diff --git a/test/fspp/fuse/statfs/testutils/FuseStatfsTest.cpp b/test/fspp/fuse/statfs/testutils/FuseStatfsTest.cpp index a6986b66..18e548a8 100644 --- a/test/fspp/fuse/statfs/testutils/FuseStatfsTest.cpp +++ b/test/fspp/fuse/statfs/testutils/FuseStatfsTest.cpp @@ -1,7 +1,6 @@ #include "FuseStatfsTest.h" using std::function; -using ::testing::StrEq; using ::testing::_; using ::testing::Invoke; diff --git a/test/fspp/fuse/write/testutils/FuseWriteTest.h b/test/fspp/fuse/write/testutils/FuseWriteTest.h index 6c22eeff..97e0d990 100644 --- a/test/fspp/fuse/write/testutils/FuseWriteTest.h +++ b/test/fspp/fuse/write/testutils/FuseWriteTest.h @@ -10,7 +10,7 @@ public: const char *FILENAME = "/myfile"; struct WriteError { - int error; + int error{}; fspp::num_bytes_t written_bytes; };