From efac089c76b2880a1e5ebbf5e70946bc5aac6d80 Mon Sep 17 00:00:00 2001 From: Sebastian Messmer Date: Sat, 8 Jun 2019 13:06:17 -0700 Subject: [PATCH] - Add Clang 8 and GCC 9 to CI - Switch clang-tidy to Clang 9 - Fix compiler and clang-tidy warnings produced by the previous points --- .circleci/config.yml | 104 ++++++++++++++---- .clang-tidy | 5 + .../datatreestore/impl/LeafTraverser.cpp | 2 +- .../implementations/caching/cache/QueueMap.h | 8 +- src/cpp-utils/crypto/RandomPadding.cpp | 2 +- src/cpp-utils/crypto/symmetric/CFB_Cipher.h | 2 +- src/cpp-utils/crypto/symmetric/GCM_Cipher.h | 2 +- .../testutils/FakeAuthenticatedCipher.h | 4 +- src/cpp-utils/data/FixedSizeData.h | 18 +-- src/cpp-utils/io/IOStreamConsole.cpp | 2 +- src/cpp-utils/process/subprocess.cpp | 7 +- src/cpp-utils/system/filetime_nonwindows.cpp | 5 +- src/cpp-utils/thread/debugging_nonwindows.cpp | 8 +- src/cryfs-cli/Cli.cpp | 2 +- src/cryfs-cli/Cli.h | 2 +- src/cryfs-cli/program_options/Parser.cpp | 4 +- src/cryfs-cli/program_options/Parser.h | 4 +- src/cryfs-unmount/Cli.cpp | 2 +- src/cryfs-unmount/Cli.h | 2 +- src/cryfs-unmount/program_options/Parser.cpp | 4 +- src/cryfs-unmount/program_options/Parser.h | 4 +- src/cryfs/config/CryConfigConsole.cpp | 4 +- src/cryfs/config/CryConfigFile.cpp | 2 +- .../filesystem/fsblobstore/SymlinkBlob.cpp | 1 + .../fsblobstore/utils/DirEntryList.cpp | 2 +- src/fspp/fstest/FsppOpenFileTest_Timestamps.h | 8 +- src/fspp/fuse/Fuse.cpp | 6 +- src/fspp/fuse/Fuse.h | 2 +- src/parallelaccessstore/ParallelAccessStore.h | 4 +- .../DataTreeTest_ResizeByTraversing.cpp | 2 +- .../testutils/TwoLevelDataFixture.h | 2 +- .../caching/cache/CacheTest_PushAndPop.cpp | 40 +++---- test/cpp-utils/assert/exit_signal.cpp | 4 +- test/cpp-utils/process/exit_status.cpp | 2 +- .../testutils/ProgramOptionsTestBase.h | 2 +- test/cryfs-cli/testutils/CliTest.h | 2 +- .../fuse/read/FuseReadFileDescriptorTest.cpp | 4 +- test/fspp/fuse/read/FuseReadOverflowTest.cpp | 8 +- .../readDir/testutils/FuseReadDirTest.cpp | 2 +- .../utimens/FuseUtimensTimeParameterTest.cpp | 22 ++-- .../write/FuseWriteFileDescriptorTest.cpp | 4 +- 41 files changed, 191 insertions(+), 125 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index b9e70445..a06f7149 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -45,6 +45,8 @@ references: deb-src http://apt.llvm.org/trusty/ llvm-toolchain-trusty-6.0 main deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-7 main deb-src http://apt.llvm.org/trusty/ llvm-toolchain-trusty-7 main + deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-8 main + deb-src http://apt.llvm.org/trusty/ llvm-toolchain-trusty-8 main EOF sudo chmod o-w /etc/apt/sources.list.d/clang.list @@ -57,8 +59,8 @@ references: # They aren't set automatically unfortunately sudo ln -s /usr/bin/$CC /usr/bin/clang sudo ln -s /usr/bin/$CXX /usr/bin/clang++ - sudo ln -s /usr/bin/clang-tidy-7 /usr/bin/clang-tidy - sudo ln -s /usr/bin/run-clang-tidy-7.py /usr/bin/run-clang-tidy.py + sudo ln -s /usr/bin/clang-tidy-8 /usr/bin/clang-tidy + sudo ln -s /usr/bin/run-clang-tidy-8.py /usr/bin/run-clang-tidy.py # Need a c++14 compliant STL for clang sudo apt-get install -y g++-5 @@ -299,6 +301,30 @@ jobs: GTEST_ARGS: "" CMAKE_FLAGS: "" RUN_TESTS: true + gcc_9_debug: + <<: *job_definition + environment: + CC: gcc-9 + CXX: g++-9 + BUILD_TOOLSET: gcc + APT_COMPILER_PACKAGE: "g++-9" + CXXFLAGS: "" + BUILD_TYPE: "Debug" + GTEST_ARGS: "" + CMAKE_FLAGS: "" + RUN_TESTS: true + gcc_9_release: + <<: *job_definition + environment: + CC: gcc-9 + CXX: g++-9 + BUILD_TOOLSET: gcc + APT_COMPILER_PACKAGE: "g++-9" + CXXFLAGS: "" + BUILD_TYPE: "Release" + GTEST_ARGS: "" + CMAKE_FLAGS: "" + RUN_TESTS: true clang_4_debug: <<: *job_definition environment: @@ -395,13 +421,37 @@ jobs: GTEST_ARGS: "" CMAKE_FLAGS: "" RUN_TESTS: true + clang_8_debug: + <<: *job_definition + environment: + CC: clang-8 + CXX: clang++-8 + BUILD_TOOLSET: clang + APT_COMPILER_PACKAGE: clang-8 + CXXFLAGS: "" + BUILD_TYPE: "Debug" + GTEST_ARGS: "" + CMAKE_FLAGS: "" + RUN_TESTS: true + clang_8_release: + <<: *job_definition + environment: + CC: clang-8 + CXX: clang++-8 + BUILD_TOOLSET: clang + APT_COMPILER_PACKAGE: clang-8 + CXXFLAGS: "" + BUILD_TYPE: "Release" + GTEST_ARGS: "" + CMAKE_FLAGS: "" + RUN_TESTS: true clang_werror: <<: *job_definition environment: - CC: clang-7 - CXX: clang++-7 + CC: clang-8 + CXX: clang++-8 BUILD_TOOLSET: clang - APT_COMPILER_PACKAGE: clang-7 + APT_COMPILER_PACKAGE: clang-8 CXXFLAGS: "" BUILD_TYPE: "Release" GTEST_ARGS: "" @@ -410,10 +460,10 @@ jobs: gcc_werror: <<: *job_definition environment: - CC: gcc-8 - CXX: g++-8 + CC: gcc-9 + CXX: g++-9 BUILD_TOOLSET: gcc - APT_COMPILER_PACKAGE: "g++-8" + APT_COMPILER_PACKAGE: "g++-9" CXXFLAGS: "" BUILD_TYPE: "Release" GTEST_ARGS: "" @@ -422,10 +472,10 @@ jobs: no_compatibility: <<: *job_definition environment: - CC: clang-7 - CXX: clang++-7 + CC: clang-8 + CXX: clang++-8 BUILD_TOOLSET: clang - APT_COMPILER_PACKAGE: clang-7 + APT_COMPILER_PACKAGE: clang-8 CXXFLAGS: "-DCRYFS_NO_COMPATIBILITY" BUILD_TYPE: "Debug" GTEST_ARGS: "" @@ -434,10 +484,10 @@ jobs: address_sanitizer: <<: *job_definition environment: - CC: clang-7 - CXX: clang++-7 + CC: clang-8 + CXX: clang++-8 BUILD_TOOLSET: clang - APT_COMPILER_PACKAGE: clang-7 + APT_COMPILER_PACKAGE: clang-8 CXXFLAGS: "-O2 -fsanitize=address -fno-omit-frame-pointer -fno-common -fsanitize-address-use-after-scope" BUILD_TYPE: "Debug" ASAN_OPTIONS: "detect_leaks=1 check_initialization_order=1 detect_stack_use_after_return=1 detect_invalid_pointer_pairs=1 atexit=1" @@ -448,10 +498,10 @@ jobs: ub_sanitizer: <<: *job_definition environment: - CC: clang-7 - CXX: clang++-7 + CC: clang-8 + CXX: clang++-8 BUILD_TOOLSET: clang - APT_COMPILER_PACKAGE: clang-7 + APT_COMPILER_PACKAGE: clang-8 CXXFLAGS: "-O2 -fno-sanitize-recover=undefined,nullability,implicit-conversion,unsigned-integer-overflow -fno-omit-frame-pointer -fno-common" BUILD_TYPE: "Debug" GTEST_ARGS: "" @@ -460,10 +510,10 @@ jobs: thread_sanitizer: <<: *job_definition environment: - CC: clang-7 - CXX: clang++-7 + CC: clang-8 + CXX: clang++-8 BUILD_TOOLSET: clang - APT_COMPILER_PACKAGE: clang-7 + APT_COMPILER_PACKAGE: clang-8 OMP_NUM_THREADS: "1" CXXFLAGS: "-O2 -fsanitize=thread -fno-omit-frame-pointer" BUILD_TYPE: "Debug" @@ -496,10 +546,10 @@ jobs: - store_artifacts: path: /tmp/clang-tidy-fixes environment: - CC: clang-7 - CXX: clang++-7 + CC: clang-8 + CXX: clang++-8 BUILD_TOOLSET: clang - APT_COMPILER_PACKAGE: "clang-7 clang-tidy-7" + APT_COMPILER_PACKAGE: "clang-8 clang-tidy-8" workflows: version: 2 @@ -522,6 +572,10 @@ workflows: <<: *enable_for_tags - gcc_8_release: <<: *enable_for_tags + - gcc_9_debug: + <<: *enable_for_tags + - gcc_9_release: + <<: *enable_for_tags - clang_4_debug: <<: *enable_for_tags - clang_4_release: @@ -538,6 +592,10 @@ workflows: <<: *enable_for_tags - clang_7_release: <<: *enable_for_tags + - clang_8_debug: + <<: *enable_for_tags + - clang_8_release: + <<: *enable_for_tags - clang_werror: <<: *enable_for_tags - gcc_werror: diff --git a/.clang-tidy b/.clang-tidy index 6ce5b1c8..b9569c1d 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -25,8 +25,13 @@ Checks: | -cppcoreguidelines-pro-bounds-array-to-pointer-decay, -cppcoreguidelines-pro-type-vararg, -cppcoreguidelines-avoid-goto, + -cppcoreguidelines-avoid-magic-numbers, + -cppcoreguidelines-macro-usage, + -cppcoreguidelines-non-private-member-variables-in-classes, -clang-analyzer-optin.cplusplus.VirtualCall, + -clang-analyzer-cplusplus.NewDeleteLeaks, -misc-macro-parentheses, + -misc-non-private-member-variables-in-classes, -misc-unused-raii WarningsAsErrors: '*' HeaderFilterRegex: '/src/|/test/' diff --git a/src/blobstore/implementations/onblocks/datatreestore/impl/LeafTraverser.cpp b/src/blobstore/implementations/onblocks/datatreestore/impl/LeafTraverser.cpp index 12d0b499..1a17e297 100644 --- a/src/blobstore/implementations/onblocks/datatreestore/impl/LeafTraverser.cpp +++ b/src/blobstore/implementations/onblocks/datatreestore/impl/LeafTraverser.cpp @@ -215,7 +215,7 @@ namespace blobstore { if (endIndex > beginIndex) { onBacktrackFromSubtree(newNode.get()); } - return std::move(newNode); + return newNode; } uint32_t LeafTraverser::_maxLeavesForTreeDepth(uint8_t depth) const { diff --git a/src/blockstore/implementations/caching/cache/QueueMap.h b/src/blockstore/implementations/caching/cache/QueueMap.h index 8db9d646..851b3265 100644 --- a/src/blockstore/implementations/caching/cache/QueueMap.h +++ b/src/blockstore/implementations/caching/cache/QueueMap.h @@ -48,7 +48,7 @@ public: _removeFromQueue(found->second); auto value = found->second.release(); _entries.erase(found); - return std::move(value); + return value; } boost::optional pop() { @@ -83,7 +83,7 @@ private: } void init(const Key *key_, Value value_) { key = key_; - new(__value) Value(std::move(value_)); + new(__value.data()) Value(std::move(value_)); } Value release() { Value value = std::move(*_value()); @@ -98,9 +98,9 @@ private: const Key *key; private: Value *_value() { - return reinterpret_cast(__value); + return reinterpret_cast(__value.data()); } - alignas(Value) char __value[sizeof(Value)]; + alignas(Value) std::array __value; DISALLOW_COPY_AND_ASSIGN(Entry); }; diff --git a/src/cpp-utils/crypto/RandomPadding.cpp b/src/cpp-utils/crypto/RandomPadding.cpp index 041fa7dc..8d9b2229 100644 --- a/src/cpp-utils/crypto/RandomPadding.cpp +++ b/src/cpp-utils/crypto/RandomPadding.cpp @@ -29,6 +29,6 @@ namespace cpputils { }; Data result(size); std::memcpy(result.data(), data.dataOffset(sizeof(size)), size); - return std::move(result); + return result; } } diff --git a/src/cpp-utils/crypto/symmetric/CFB_Cipher.h b/src/cpp-utils/crypto/symmetric/CFB_Cipher.h index 4f91b893..217111d9 100644 --- a/src/cpp-utils/crypto/symmetric/CFB_Cipher.h +++ b/src/cpp-utils/crypto/symmetric/CFB_Cipher.h @@ -71,7 +71,7 @@ boost::optional CFB_Cipher::decrypt(const CryptoPP:: // TODO Shouldn't we pass in ciphertextSize instead of plaintext.size() here as last argument (and also in the if above)? decryption.ProcessData(static_cast(plaintext.data()), ciphertextData, plaintext.size()); } - return std::move(plaintext); + return plaintext; } } diff --git a/src/cpp-utils/crypto/symmetric/GCM_Cipher.h b/src/cpp-utils/crypto/symmetric/GCM_Cipher.h index 21d55fb6..87404c8f 100644 --- a/src/cpp-utils/crypto/symmetric/GCM_Cipher.h +++ b/src/cpp-utils/crypto/symmetric/GCM_Cipher.h @@ -81,7 +81,7 @@ boost::optional GCM_Cipher::decrypt(const CryptoPP:: CryptoPP::AuthenticatedDecryptionFilter::DEFAULT_FLAGS, TAG_SIZE ) ); - return std::move(plaintext); + return plaintext; } catch (const CryptoPP::HashVerificationFilter::HashVerificationFailed &e) { return boost::none; } diff --git a/src/cpp-utils/crypto/symmetric/testutils/FakeAuthenticatedCipher.h b/src/cpp-utils/crypto/symmetric/testutils/FakeAuthenticatedCipher.h index 4305ef02..4c0a248f 100644 --- a/src/cpp-utils/crypto/symmetric/testutils/FakeAuthenticatedCipher.h +++ b/src/cpp-utils/crypto/symmetric/testutils/FakeAuthenticatedCipher.h @@ -92,7 +92,7 @@ namespace cpputils { Data result(plaintextSize(ciphertextSize)); _xor(static_cast(result.data()), ciphertext + sizeof(uint64_t), plaintextSize(ciphertextSize), encKey.value ^ iv); - return std::move(result); + return result; } static constexpr const char *NAME = "FakeAuthenticatedCipher"; @@ -101,7 +101,7 @@ namespace cpputils { static uint64_t _checksum(const CryptoPP::byte *data, FakeKey encKey, std::size_t size) { uint64_t checksum = 34343435 * encKey.value; // some init value - for (unsigned int i = 0; i < size; ++i) { + for (size_t i = 0; i < size; ++i) { checksum ^= (static_cast(data[i]) << (56 - 8 * (i%8))); } diff --git a/src/cpp-utils/data/FixedSizeData.h b/src/cpp-utils/data/FixedSizeData.h index c4a88d73..832a96ee 100644 --- a/src/cpp-utils/data/FixedSizeData.h +++ b/src/cpp-utils/data/FixedSizeData.h @@ -37,7 +37,7 @@ private: FixedSizeData(): _data() {} template friend class FixedSizeData; - unsigned char _data[BINARY_LENGTH]; + std::array _data; }; template bool operator==(const FixedSizeData &lhs, const FixedSizeData &rhs); @@ -51,7 +51,7 @@ template constexpr size_t FixedSizeData::STRING_LENGTH; template FixedSizeData FixedSizeData::Null() { FixedSizeData result; - std::memset(result._data, 0, BINARY_LENGTH); + std::memset(result._data.data(), 0, BINARY_LENGTH); return result; } @@ -62,7 +62,7 @@ FixedSizeData FixedSizeData::FromString(const std::string &data) { { CryptoPP::StringSource _1(data, true, new CryptoPP::HexDecoder( - new CryptoPP::ArraySink(result._data, BINARY_LENGTH) + new CryptoPP::ArraySink(result._data.data(), BINARY_LENGTH) ) ); } @@ -72,7 +72,7 @@ FixedSizeData FixedSizeData::FromString(const std::string &data) { template std::string FixedSizeData::ToString() const { std::string result; - CryptoPP::ArraySource(_data, BINARY_LENGTH, true, + CryptoPP::ArraySource(_data.data(), BINARY_LENGTH, true, new CryptoPP::HexEncoder( new CryptoPP::StringSink(result) ) @@ -83,7 +83,7 @@ std::string FixedSizeData::ToString() const { template const unsigned char *FixedSizeData::data() const { - return _data; + return _data.data(); } template @@ -93,13 +93,13 @@ unsigned char *FixedSizeData::data() { template void FixedSizeData::ToBinary(void *target) const { - std::memcpy(target, _data, BINARY_LENGTH); + std::memcpy(target, _data.data(), BINARY_LENGTH); } template FixedSizeData FixedSizeData::FromBinary(const void *source) { FixedSizeData result; - std::memcpy(result._data, source, BINARY_LENGTH); + std::memcpy(result._data.data(), source, BINARY_LENGTH); return result; } @@ -107,7 +107,7 @@ template template FixedSizeData FixedSizeData::take() const { static_assert(size <= SIZE, "Out of bounds"); FixedSizeData result; - std::memcpy(result._data, _data, size); + std::memcpy(result._data.data(), _data.data(), size); return result; } @@ -115,7 +115,7 @@ template template FixedSizeData FixedSizeData::drop() const { static_assert(size <= SIZE, "Out of bounds"); FixedSizeData result; - std::memcpy(result._data, _data+size, SIZE-size); + std::memcpy(result._data.data(), _data.data()+size, SIZE-size); return result; } diff --git a/src/cpp-utils/io/IOStreamConsole.cpp b/src/cpp-utils/io/IOStreamConsole.cpp index 1c6213bb..48cdd7fa 100644 --- a/src/cpp-utils/io/IOStreamConsole.cpp +++ b/src/cpp-utils/io/IOStreamConsole.cpp @@ -67,7 +67,7 @@ unsigned int IOStreamConsole::ask(const string &question, const vector & throw std::invalid_argument("options should have at least one entry"); } _output << question << "\n"; - for (unsigned int i = 0; i < options.size(); ++i) { + for (size_t i = 0; i < options.size(); ++i) { _output << " [" << (i+1) << "] " << options[i] << "\n"; } int choice = _askForChoice("Your choice [1-" + std::to_string(options.size()) + "]: ", _parseUIntWithMinMax(1, options.size())); diff --git a/src/cpp-utils/process/subprocess.cpp b/src/cpp-utils/process/subprocess.cpp index c1eb1a9e..b044901a 100644 --- a/src/cpp-utils/process/subprocess.cpp +++ b/src/cpp-utils/process/subprocess.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #if defined(__APPLE__) @@ -44,9 +45,9 @@ namespace cpputils { string getOutput() { string output; - char buffer[1024]; - while (fgets(buffer, sizeof(buffer), _subprocess) != nullptr) { - output += buffer; + std::array buffer{}; + while (fgets(buffer.data(), buffer.size(), _subprocess) != nullptr) { + output += buffer.data(); } return output; } diff --git a/src/cpp-utils/system/filetime_nonwindows.cpp b/src/cpp-utils/system/filetime_nonwindows.cpp index 344f0c0e..6dccba6a 100644 --- a/src/cpp-utils/system/filetime_nonwindows.cpp +++ b/src/cpp-utils/system/filetime_nonwindows.cpp @@ -5,15 +5,16 @@ #include #include #include +#include #include namespace cpputils { int set_filetime(const char *filepath, timespec lastAccessTime, timespec lastModificationTime) { - struct timeval casted_times[2]; + std::array casted_times{}; TIMESPEC_TO_TIMEVAL(&casted_times[0], &lastAccessTime); TIMESPEC_TO_TIMEVAL(&casted_times[1], &lastModificationTime); - int retval = ::utimes(filepath, casted_times); + int retval = ::utimes(filepath, casted_times.data()); if (0 == retval) { return 0; } else { diff --git a/src/cpp-utils/thread/debugging_nonwindows.cpp b/src/cpp-utils/thread/debugging_nonwindows.cpp index 4afb4045..32bba95b 100644 --- a/src/cpp-utils/thread/debugging_nonwindows.cpp +++ b/src/cpp-utils/thread/debugging_nonwindows.cpp @@ -71,11 +71,11 @@ int pthread_getname_np_gcompat(pthread_t thread, char *name, size_t len) { #endif std::string get_thread_name(pthread_t thread) { - char name[MAX_NAME_LEN]; + std::array name{}; #if defined(__GLIBC__) || defined(__APPLE__) - int result = pthread_getname_np(thread, name, MAX_NAME_LEN); + int result = pthread_getname_np(thread, name.data(), MAX_NAME_LEN); #else - int result = pthread_getname_np_gcompat(thread, name, MAX_NAME_LEN); + int result = pthread_getname_np_gcompat(thread, name.data(), MAX_NAME_LEN); #endif if (0 != result) { throw std::runtime_error("Error getting thread name with pthread_getname_np. Code: " + std::to_string(result)); @@ -83,7 +83,7 @@ std::string get_thread_name(pthread_t thread) { // pthread_getname_np returns a null terminated string with maximum 16 bytes. // but just to be safe against a buggy implementation, let's set the last byte to zero. name[MAX_NAME_LEN - 1] = '\0'; - return name; + return name.data(); } } diff --git a/src/cryfs-cli/Cli.cpp b/src/cryfs-cli/Cli.cpp index 261459f9..45e34a9e 100644 --- a/src/cryfs-cli/Cli.cpp +++ b/src/cryfs-cli/Cli.cpp @@ -399,7 +399,7 @@ namespace cryfs_cli { return false; } - int Cli::main(int argc, const char *argv[], unique_ref httpClient, std::function onMounted) { + int Cli::main(int argc, const char **argv, unique_ref httpClient, std::function onMounted) { cpputils::showBacktraceOnCrash(); cpputils::set_thread_name("cryfs"); diff --git a/src/cryfs-cli/Cli.h b/src/cryfs-cli/Cli.h index bdffaa54..8228f6e5 100644 --- a/src/cryfs-cli/Cli.h +++ b/src/cryfs-cli/Cli.h @@ -18,7 +18,7 @@ namespace cryfs_cli { class Cli final { public: Cli(cpputils::RandomGenerator &keyGenerator, const cpputils::SCryptSettings& scryptSettings, std::shared_ptr console); - int main(int argc, const char *argv[], cpputils::unique_ref httpClient, std::function onMounted); + int main(int argc, const char **argv, cpputils::unique_ref httpClient, std::function onMounted); private: void _checkForUpdates(cpputils::unique_ref httpClient); diff --git a/src/cryfs-cli/program_options/Parser.cpp b/src/cryfs-cli/program_options/Parser.cpp index 5310e364..6fe0da3d 100644 --- a/src/cryfs-cli/program_options/Parser.cpp +++ b/src/cryfs-cli/program_options/Parser.cpp @@ -20,11 +20,11 @@ using boost::optional; using boost::none; using namespace cpputils::logging; -Parser::Parser(int argc, const char *argv[]) +Parser::Parser(int argc, const char **argv) :_options(_argsToVector(argc, argv)) { } -vector Parser::_argsToVector(int argc, const char *argv[]) { +vector Parser::_argsToVector(int argc, const char **argv) { vector result; for(int i = 0; i < argc; ++i) { result.push_back(argv[i]); diff --git a/src/cryfs-cli/program_options/Parser.h b/src/cryfs-cli/program_options/Parser.h index 735c2b8d..359cf910 100644 --- a/src/cryfs-cli/program_options/Parser.h +++ b/src/cryfs-cli/program_options/Parser.h @@ -10,12 +10,12 @@ namespace cryfs_cli { namespace program_options { class Parser final { public: - Parser(int argc, const char *argv[]); + Parser(int argc, const char **argv); ProgramOptions parse(const std::vector &supportedCiphers) const; private: - static std::vector _argsToVector(int argc, const char *argv[]); + static std::vector _argsToVector(int argc, const char **argv); static std::vector _to_const_char_vector(const std::vector &options); static void _addAllowedOptions(boost::program_options::options_description *desc); static void _addPositionalOptionForBaseDir(boost::program_options::options_description *desc, diff --git a/src/cryfs-unmount/Cli.cpp b/src/cryfs-unmount/Cli.cpp index aa5c06f2..9cfe30d7 100644 --- a/src/cryfs-unmount/Cli.cpp +++ b/src/cryfs-unmount/Cli.cpp @@ -18,7 +18,7 @@ void _showVersion() { } } -void Cli::main(int argc, const char* argv[]) { +void Cli::main(int argc, const char **argv) { _showVersion(); ProgramOptions options = Parser(argc, argv).parse(); diff --git a/src/cryfs-unmount/Cli.h b/src/cryfs-unmount/Cli.h index d69b6f3e..498e6b74 100644 --- a/src/cryfs-unmount/Cli.h +++ b/src/cryfs-unmount/Cli.h @@ -6,7 +6,7 @@ namespace cryfs_unmount { class Cli final { public: - void main(int argc, const char* argv[]); + void main(int argc, const char **argv); }; } diff --git a/src/cryfs-unmount/program_options/Parser.cpp b/src/cryfs-unmount/program_options/Parser.cpp index 25e27951..b11e331e 100644 --- a/src/cryfs-unmount/program_options/Parser.cpp +++ b/src/cryfs-unmount/program_options/Parser.cpp @@ -17,11 +17,11 @@ using std::endl; using std::string; using namespace cpputils::logging; -Parser::Parser(int argc, const char *argv[]) +Parser::Parser(int argc, const char **argv) :_options(_argsToVector(argc, argv)) { } -vector Parser::_argsToVector(int argc, const char *argv[]) { +vector Parser::_argsToVector(int argc, const char **argv) { vector result; for (int i = 0; i < argc; ++i) { result.push_back(argv[i]); diff --git a/src/cryfs-unmount/program_options/Parser.h b/src/cryfs-unmount/program_options/Parser.h index 6f98eb1f..5d1a1e40 100644 --- a/src/cryfs-unmount/program_options/Parser.h +++ b/src/cryfs-unmount/program_options/Parser.h @@ -10,12 +10,12 @@ namespace cryfs_unmount { namespace program_options { class Parser final { public: - Parser(int argc, const char *argv[]); + Parser(int argc, const char **argv); ProgramOptions parse() const; private: - static std::vector _argsToVector(int argc, const char *argv[]); + static std::vector _argsToVector(int argc, const char **argv); static std::vector _to_const_char_vector(const std::vector &options); static void _addAllowedOptions(boost::program_options::options_description *desc); static void _addPositionalOptionForBaseDir(boost::program_options::options_description *desc, diff --git a/src/cryfs/config/CryConfigConsole.cpp b/src/cryfs/config/CryConfigConsole.cpp index da7ebb54..6b0d36fd 100644 --- a/src/cryfs/config/CryConfigConsole.cpp +++ b/src/cryfs/config/CryConfigConsole.cpp @@ -29,7 +29,7 @@ namespace cryfs { bool askAgain = true; while(askAgain) { _console->print("\n"); - int cipherIndex = _console->ask("Which block cipher do you want to use?", ciphers); + unsigned int cipherIndex = _console->ask("Which block cipher do you want to use?", ciphers); cipherName = ciphers[cipherIndex]; askAgain = !_showWarningForCipherAndReturnIfOk(cipherName); }; @@ -54,7 +54,7 @@ namespace cryfs { uint32_t CryConfigConsole::_askBlocksizeBytes() const { vector sizes = {"4KB", "8KB", "16KB", "32KB", "64KB", "512KB", "1MB", "4MB"}; - int index = _console->ask("Which block size do you want to use?", sizes); + unsigned int index = _console->ask("Which block size do you want to use?", sizes); switch(index) { case 0: return 4*1024; case 1: return 8*1024; diff --git a/src/cryfs/config/CryConfigFile.cpp b/src/cryfs/config/CryConfigFile.cpp index 8e683f87..277d0dc5 100644 --- a/src/cryfs/config/CryConfigFile.cpp +++ b/src/cryfs/config/CryConfigFile.cpp @@ -49,7 +49,7 @@ optional CryConfigFile::load(bf::path path, CryKeyProvider* keyPr configFile.save(); } //TODO For newer compilers, this works without std::move - return std::move(configFile); + return configFile; } CryConfigFile CryConfigFile::create(bf::path path, CryConfig config, CryKeyProvider* keyProvider) { diff --git a/src/cryfs/filesystem/fsblobstore/SymlinkBlob.cpp b/src/cryfs/filesystem/fsblobstore/SymlinkBlob.cpp index dc1b9f2d..67f14af2 100644 --- a/src/cryfs/filesystem/fsblobstore/SymlinkBlob.cpp +++ b/src/cryfs/filesystem/fsblobstore/SymlinkBlob.cpp @@ -28,6 +28,7 @@ unique_ref SymlinkBlob::InitializeSymlink(unique_ref blob, co } bf::path SymlinkBlob::_readTargetFromBlob(const FsBlobView &blob) { + // NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays) auto targetStr = std::make_unique(blob.size() + 1); // +1 because of the nullbyte blob.read(targetStr.get(), 0, blob.size()); targetStr[blob.size()] = '\0'; diff --git a/src/cryfs/filesystem/fsblobstore/utils/DirEntryList.cpp b/src/cryfs/filesystem/fsblobstore/utils/DirEntryList.cpp index f27c5783..21768605 100644 --- a/src/cryfs/filesystem/fsblobstore/utils/DirEntryList.cpp +++ b/src/cryfs/filesystem/fsblobstore/utils/DirEntryList.cpp @@ -175,7 +175,7 @@ vector::iterator DirEntryList::_findFirst(const BlockId &hint, std::fu return _entries.end(); } double startpos_percent = static_cast(*static_cast(hint.data().data())) / std::numeric_limits::max(); - auto iter = _entries.begin() + static_cast(startpos_percent * (_entries.size()-1)); + auto iter = _entries.begin() + static_cast(startpos_percent * static_cast(_entries.size()-1)); ASSERT(iter >= _entries.begin() && iter < _entries.end(), "Startpos out of range"); while(iter != _entries.begin() && pred(*iter)) { --iter; diff --git a/src/fspp/fstest/FsppOpenFileTest_Timestamps.h b/src/fspp/fstest/FsppOpenFileTest_Timestamps.h index e9b7d42f..dd4f2d5f 100644 --- a/src/fspp/fstest/FsppOpenFileTest_Timestamps.h +++ b/src/fspp/fstest/FsppOpenFileTest_Timestamps.h @@ -72,8 +72,8 @@ TYPED_TEST_P(FsppOpenFileTest_Timestamps, truncate_nonempty_to_nonempty_grow) { TYPED_TEST_P(FsppOpenFileTest_Timestamps, read_inbounds) { auto openFile = this->CreateAndOpenFileWithSize("/myfile", fspp::num_bytes_t(10)); auto operation = [&openFile] () { - char buffer[5]; - openFile->read(buffer, fspp::num_bytes_t(5), fspp::num_bytes_t(0)); + std::array buffer{}; + openFile->read(buffer.data(), fspp::num_bytes_t(5), fspp::num_bytes_t(0)); }; this->EXPECT_OPERATION_UPDATES_TIMESTAMPS_AS(*openFile, operation, {this->ExpectUpdatesAccessTimestamp, this->ExpectDoesntUpdateModificationTimestamp, this->ExpectDoesntUpdateMetadataTimestamp}); } @@ -81,8 +81,8 @@ TYPED_TEST_P(FsppOpenFileTest_Timestamps, read_inbounds) { TYPED_TEST_P(FsppOpenFileTest_Timestamps, read_outofbounds) { auto openFile = this->CreateAndOpenFileWithSize("/myfile", fspp::num_bytes_t(0)); auto operation = [&openFile] () { - char buffer[5]; - openFile->read(buffer, fspp::num_bytes_t(5), fspp::num_bytes_t(2)); + std::array buffer{}; + openFile->read(buffer.data(), fspp::num_bytes_t(5), fspp::num_bytes_t(2)); }; this->EXPECT_OPERATION_UPDATES_TIMESTAMPS_AS(*openFile, operation, {this->ExpectUpdatesAccessTimestamp, this->ExpectDoesntUpdateModificationTimestamp, this->ExpectDoesntUpdateMetadataTimestamp}); } diff --git a/src/fspp/fuse/Fuse.cpp b/src/fspp/fuse/Fuse.cpp index 3a5131c6..52cd5644 100644 --- a/src/fspp/fuse/Fuse.cpp +++ b/src/fspp/fuse/Fuse.cpp @@ -113,8 +113,8 @@ int fusepp_ftruncate(const char *path, int64_t size, fuse_file_info *fileinfo) { return FUSE_OBJ->ftruncate(bf::path(path), size, fileinfo); } -int fusepp_utimens(const char *path, const timespec times[2]) { - return FUSE_OBJ->utimens(bf::path(path), times); +int fusepp_utimens(const char *path, const timespec times[2]) { // NOLINT(cppcoreguidelines-avoid-c-arrays) + return FUSE_OBJ->utimens(bf::path(path), {times[0], times[1]}); } int fusepp_open(const char *path, fuse_file_info *fileinfo) { @@ -751,7 +751,7 @@ int Fuse::ftruncate(const bf::path &path, int64_t size, fuse_file_info *fileinfo } } -int Fuse::utimens(const bf::path &path, const timespec times[2]) { +int Fuse::utimens(const bf::path &path, const std::array times) { ThreadNameForDebugging _threadName("utimens"); #ifdef FSPP_LOG LOG(DEBUG, "utimens({}, _)", path); diff --git a/src/fspp/fuse/Fuse.h b/src/fspp/fuse/Fuse.h index 2da56c44..0b384d81 100644 --- a/src/fspp/fuse/Fuse.h +++ b/src/fspp/fuse/Fuse.h @@ -44,7 +44,7 @@ public: int chown(const boost::filesystem::path &path, ::uid_t uid, ::gid_t gid); int truncate(const boost::filesystem::path &path, int64_t size); int ftruncate(const boost::filesystem::path &path, int64_t size, fuse_file_info *fileinfo); - int utimens(const boost::filesystem::path &path, const timespec times[2]); + int utimens(const boost::filesystem::path &path, const std::array times); int open(const boost::filesystem::path &path, fuse_file_info *fileinfo); int release(const boost::filesystem::path &path, fuse_file_info *fileinfo); int read(const boost::filesystem::path &path, char *buf, size_t size, int64_t offset, fuse_file_info *fileinfo); diff --git a/src/parallelaccessstore/ParallelAccessStore.h b/src/parallelaccessstore/ParallelAccessStore.h index 6b2c36d3..296e643c 100644 --- a/src/parallelaccessstore/ParallelAccessStore.h +++ b/src/parallelaccessstore/ParallelAccessStore.h @@ -165,7 +165,7 @@ cpputils::unique_ref ParallelAccessStoresecond.getReference()); resourceRef->init(this, key); onExists(resourceRef.get()); - return std::move(resourceRef); + return resourceRef; } }; @@ -190,7 +190,7 @@ boost::optional> ParallelAccessStoresecond.getReference()); resourceRef->init(this, key); - return std::move(resourceRef); + return resourceRef; } } diff --git a/test/blobstore/implementations/onblocks/datatreestore/DataTreeTest_ResizeByTraversing.cpp b/test/blobstore/implementations/onblocks/datatreestore/DataTreeTest_ResizeByTraversing.cpp index b113fdb8..6503e814 100644 --- a/test/blobstore/implementations/onblocks/datatreestore/DataTreeTest_ResizeByTraversing.cpp +++ b/test/blobstore/implementations/onblocks/datatreestore/DataTreeTest_ResizeByTraversing.cpp @@ -222,7 +222,7 @@ TEST_P(DataTreeTest_ResizeByTraversing_P, DataStaysIntact) { if (traversalBeginIndex < oldNumberOfLeaves) { // Traversal wrote over part of the pre-existing data, we can only check the data before it. if (traversalBeginIndex != 0) { - data.EXPECT_DATA_CORRECT(nodeStore->load(blockId).get().get(), traversalBeginIndex - 1); + data.EXPECT_DATA_CORRECT(nodeStore->load(blockId).get().get(), static_cast(traversalBeginIndex - 1)); } } else { // Here, traversal was entirely outside the preexisting data, we can check all preexisting data. diff --git a/test/blobstore/implementations/onblocks/datatreestore/testutils/TwoLevelDataFixture.h b/test/blobstore/implementations/onblocks/datatreestore/testutils/TwoLevelDataFixture.h index b5cbbd53..fd59a231 100644 --- a/test/blobstore/implementations/onblocks/datatreestore/testutils/TwoLevelDataFixture.h +++ b/test/blobstore/implementations/onblocks/datatreestore/testutils/TwoLevelDataFixture.h @@ -67,7 +67,7 @@ private: case SizePolicy::Full: return _dataNodeStore->layout().maxBytesPerLeaf(); case SizePolicy::Random: - return mod(_dataNodeStore->layout().maxBytesPerLeaf() - childIndex, _dataNodeStore->layout().maxBytesPerLeaf()); + return mod(static_cast(_dataNodeStore->layout().maxBytesPerLeaf() - childIndex), static_cast(_dataNodeStore->layout().maxBytesPerLeaf())); case SizePolicy::Unchanged: return leaf->numBytes(); default: diff --git a/test/blockstore/implementations/caching/cache/CacheTest_PushAndPop.cpp b/test/blockstore/implementations/caching/cache/CacheTest_PushAndPop.cpp index 86c48796..d4ff8c8a 100644 --- a/test/blockstore/implementations/caching/cache/CacheTest_PushAndPop.cpp +++ b/test/blockstore/implementations/caching/cache/CacheTest_PushAndPop.cpp @@ -21,7 +21,7 @@ TEST_F(CacheTest_PushAndPop, PopNonExistingEntry_NonEmptyCache) { TEST_F(CacheTest_PushAndPop, PopNonExistingEntry_FullCache) { //Add a lot of even numbered keys - for (unsigned int i = 0; i < MAX_ENTRIES; ++i) { + for (int i = 0; i < static_cast(MAX_ENTRIES); ++i) { push(2*i, 2*i); } //Request an odd numbered key @@ -43,35 +43,35 @@ TEST_F(CacheTest_PushAndPop, MultipleEntries) { } TEST_F(CacheTest_PushAndPop, FullCache) { - for(unsigned int i = 0; i < MAX_ENTRIES; ++i) { + for(int i = 0; i < static_cast(MAX_ENTRIES); ++i) { push(i, 2*i); } - for(unsigned int i = 0; i < MAX_ENTRIES; ++i) { - EXPECT_EQ(static_cast(2*i), pop(i).value()); + for(int i = 0; i < static_cast(MAX_ENTRIES); ++i) { + EXPECT_EQ(2*i, pop(i).value()); } } TEST_F(CacheTest_PushAndPop, FullCache_PushNonOrdered_PopOrdered) { - for(unsigned int i = 1; i < MAX_ENTRIES; i += 2) { + for(int i = 1; i < static_cast(MAX_ENTRIES); i += 2) { push(i, 2*i); } - for(unsigned int i = 0; i < MAX_ENTRIES; i += 2) { + for(int i = 0; i < static_cast(MAX_ENTRIES); i += 2) { push(i, 2*i); } - for(unsigned int i = 0; i < MAX_ENTRIES; ++i) { - EXPECT_EQ(static_cast(2*i), pop(i).value()); + for(int i = 0; i < static_cast(MAX_ENTRIES); ++i) { + EXPECT_EQ(2*i, pop(i).value()); } } TEST_F(CacheTest_PushAndPop, FullCache_PushOrdered_PopNonOrdered) { - for(unsigned int i = 0; i < MAX_ENTRIES; ++i) { + for(int i = 0; i < static_cast(MAX_ENTRIES); ++i) { push(i, 2*i); } - for(unsigned int i = 1; i < MAX_ENTRIES; i += 2) { - EXPECT_EQ(static_cast(2*i), pop(i).value()); + for(int i = 1; i < static_cast(MAX_ENTRIES); i += 2) { + EXPECT_EQ(2*i, pop(i).value()); } - for(unsigned int i = 0; i < MAX_ENTRIES; i += 2) { - EXPECT_EQ(static_cast(2*i), pop(i).value()); + for(int i = 0; i < static_cast(MAX_ENTRIES); i += 2) { + EXPECT_EQ(2*i, pop(i).value()); } } @@ -95,27 +95,27 @@ TEST_F(CacheTest_PushAndPop, FullCache_PushNonOrdered_PopNonOrdered) { for(int i = roundDownToEven(MAX_ENTRIES - 1); i >= 0; i -= 2) { push(i, 2*i); } - for(unsigned int i = 1; i < MAX_ENTRIES; i += 2) { + for(int i = 1; i < static_cast(MAX_ENTRIES); i += 2) { push(i, 2*i); } for(int i = roundDownToOdd(MAX_ENTRIES-1); i >= 0; i -= 2) { - EXPECT_EQ(static_cast(2*i), pop(i).value()); + EXPECT_EQ(2*i, pop(i).value()); } - for(unsigned int i = 0; i < MAX_ENTRIES; i += 2) { - EXPECT_EQ(static_cast(2*i), pop(i).value()); + for(int i = 0; i < static_cast(MAX_ENTRIES); i += 2) { + EXPECT_EQ(2*i, pop(i).value()); } } TEST_F(CacheTest_PushAndPop, MoreThanFullCache) { - for(unsigned int i = 0; i < MAX_ENTRIES + 2; ++i) { + for(int i = 0; i < static_cast(MAX_ENTRIES + 2); ++i) { push(i, 2*i); } //Check that the oldest two elements got deleted automatically EXPECT_EQ(boost::none, pop(0)); EXPECT_EQ(boost::none, pop(1)); //Check the other elements are still there - for(unsigned int i = 2; i < MAX_ENTRIES + 2; ++i) { - EXPECT_EQ(static_cast(2*i), pop(i).value()); + for(int i = 2; i < static_cast(MAX_ENTRIES + 2); ++i) { + EXPECT_EQ(2*i, pop(i).value()); } } diff --git a/test/cpp-utils/assert/exit_signal.cpp b/test/cpp-utils/assert/exit_signal.cpp index f0abb696..cedc9a8d 100644 --- a/test/cpp-utils/assert/exit_signal.cpp +++ b/test/cpp-utils/assert/exit_signal.cpp @@ -6,7 +6,7 @@ #include #endif -void handle_exit_signal(char* argv[]) { +void handle_exit_signal(char **argv) { const std::string kind = argv[1]; if (kind == "exception") { throw std::logic_error(argv[2]); @@ -18,7 +18,7 @@ void handle_exit_signal(char* argv[]) { DWORD code = std::atoll(argv[2]); ::RaiseException(code, EXCEPTION_NONCONTINUABLE, 0, NULL); #else - int code = std::strtol(argv[2], nullptr, 10); + int code = static_cast(std::strtol(argv[2], nullptr, 10)); ::raise(code); #endif } diff --git a/test/cpp-utils/process/exit_status.cpp b/test/cpp-utils/process/exit_status.cpp index 3d72f6b1..d61db0e6 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::strtol(argv[2], nullptr, 10); + int exit_status = static_cast(std::strtol(argv[2], nullptr, 10)); return exit_status; } diff --git a/test/cryfs-cli/program_options/testutils/ProgramOptionsTestBase.h b/test/cryfs-cli/program_options/testutils/ProgramOptionsTestBase.h index 163915e8..9526a76d 100644 --- a/test/cryfs-cli/program_options/testutils/ProgramOptionsTestBase.h +++ b/test/cryfs-cli/program_options/testutils/ProgramOptionsTestBase.h @@ -10,7 +10,7 @@ public: void EXPECT_VECTOR_EQ(std::initializer_list expected, const std::vector &actual) { std::vector expectedVec(expected); ASSERT_EQ(expectedVec.size(), actual.size()); - for(unsigned int i = 0; i < expectedVec.size(); ++i) { + for(size_t i = 0; i < expectedVec.size(); ++i) { EXPECT_EQ(expectedVec[i], actual[i]); } } diff --git a/test/cryfs-cli/testutils/CliTest.h b/test/cryfs-cli/testutils/CliTest.h index 872953a8..6c1f2a54 100644 --- a/test/cryfs-cli/testutils/CliTest.h +++ b/test/cryfs-cli/testutils/CliTest.h @@ -40,7 +40,7 @@ public: cpputils::unique_ref _httpClient() { cpputils::unique_ref httpClient = cpputils::make_unique_ref(); httpClient->addWebsite("https://www.cryfs.org/version_info.json", "{\"version_info\":{\"current\":\"0.8.5\"}}"); - return std::move(httpClient); + return httpClient; } int run(const std::vector& args, std::function onMounted) { diff --git a/test/fspp/fuse/read/FuseReadFileDescriptorTest.cpp b/test/fspp/fuse/read/FuseReadFileDescriptorTest.cpp index 9470b1ab..03809775 100644 --- a/test/fspp/fuse/read/FuseReadFileDescriptorTest.cpp +++ b/test/fspp/fuse/read/FuseReadFileDescriptorTest.cpp @@ -20,6 +20,6 @@ TEST_P(FuseReadFileDescriptorTest, FileDescriptorIsCorrect) { EXPECT_CALL(*fsimpl, read(Eq(GetParam()), _, _, _)) .Times(1).WillOnce(ReturnSuccessfulRead); - char buf[1]; - ReadFile(FILENAME, buf, fspp::num_bytes_t(1), fspp::num_bytes_t(0)); + std::array buf{}; + ReadFile(FILENAME, buf.data(), fspp::num_bytes_t(1), fspp::num_bytes_t(0)); } diff --git a/test/fspp/fuse/read/FuseReadOverflowTest.cpp b/test/fspp/fuse/read/FuseReadOverflowTest.cpp index 43c9dc44..54f33f64 100644 --- a/test/fspp/fuse/read/FuseReadOverflowTest.cpp +++ b/test/fspp/fuse/read/FuseReadOverflowTest.cpp @@ -26,13 +26,13 @@ constexpr fspp::num_bytes_t FuseReadOverflowTest::OFFSET; TEST_F(FuseReadOverflowTest, ReadMoreThanFileSizeFromBeginning) { - char buf[READSIZE.value()]; - auto retval = ReadFileReturnError(FILENAME, buf, READSIZE, fspp::num_bytes_t(0)); + std::array buf{}; + auto retval = ReadFileReturnError(FILENAME, buf.data(), READSIZE, fspp::num_bytes_t(0)); EXPECT_EQ(FILESIZE, retval.read_bytes); } TEST_F(FuseReadOverflowTest, ReadMoreThanFileSizeFromMiddle) { - char buf[READSIZE.value()]; - auto retval = ReadFileReturnError(FILENAME, buf, READSIZE, OFFSET); + std::array buf{}; + auto retval = ReadFileReturnError(FILENAME, buf.data(), READSIZE, OFFSET); EXPECT_EQ(FILESIZE-OFFSET, retval.read_bytes); } diff --git a/test/fspp/fuse/readDir/testutils/FuseReadDirTest.cpp b/test/fspp/fuse/readDir/testutils/FuseReadDirTest.cpp index 25a49fde..036c5b17 100644 --- a/test/fspp/fuse/readDir/testutils/FuseReadDirTest.cpp +++ b/test/fspp/fuse/readDir/testutils/FuseReadDirTest.cpp @@ -80,7 +80,7 @@ void FuseReadDirTest::closeDir(DIR *dir) { Action*(const char*)> FuseReadDirTest::ReturnDirEntries(vector entries) { vector *direntries = new vector(entries.size(), fspp::Dir::Entry(fspp::Dir::EntryType::FILE, "")); - for(unsigned int i = 0; i < entries.size(); ++i) { + for(size_t i = 0; i < entries.size(); ++i) { (*direntries)[i].name = entries[i]; } return Return(direntries); diff --git a/test/fspp/fuse/utimens/FuseUtimensTimeParameterTest.cpp b/test/fspp/fuse/utimens/FuseUtimensTimeParameterTest.cpp index 631a7249..f8a60728 100644 --- a/test/fspp/fuse/utimens/FuseUtimensTimeParameterTest.cpp +++ b/test/fspp/fuse/utimens/FuseUtimensTimeParameterTest.cpp @@ -5,18 +5,18 @@ using ::testing::Return; using ::testing::WithParamInterface; using ::testing::Values; -class FuseUtimensTimeParameterTest: public FuseUtimensTest, public WithParamInterface { +class FuseUtimensTimeParameterTest: public FuseUtimensTest, public WithParamInterface> { }; -const timespec TIMEVAL1[2] = {FuseUtimensTest::makeTimespec(0,0), FuseUtimensTest::makeTimespec(0,0)}; -const timespec TIMEVAL2[2] = {FuseUtimensTest::makeTimespec(1000,0), FuseUtimensTest::makeTimespec(0,0)}; -const timespec TIMEVAL3[2] = {FuseUtimensTest::makeTimespec(0,1000), FuseUtimensTest::makeTimespec(0,0)}; -const timespec TIMEVAL4[2] = {FuseUtimensTest::makeTimespec(1000,1000), FuseUtimensTest::makeTimespec(0,0)}; -const timespec TIMEVAL5[2] = {FuseUtimensTest::makeTimespec(0,0), FuseUtimensTest::makeTimespec(0,0)}; -const timespec TIMEVAL6[2] = {FuseUtimensTest::makeTimespec(0,0), FuseUtimensTest::makeTimespec(1000,0)}; -const timespec TIMEVAL7[2] = {FuseUtimensTest::makeTimespec(0,0), FuseUtimensTest::makeTimespec(0,1000)}; -const timespec TIMEVAL8[2] = {FuseUtimensTest::makeTimespec(0,0), FuseUtimensTest::makeTimespec(1000,1000)}; -const timespec TIMEVAL9[2] = {FuseUtimensTest::makeTimespec(1417196126,123000), FuseUtimensTest::makeTimespec(1417109713,321000)}; // current timestamp and the day before as of writing this test case -const timespec TIMEVAL10[2] = {FuseUtimensTest::makeTimespec(UINT64_C(1024)*1024*1024*1024,999000), FuseUtimensTest::makeTimespec(UINT64_C(2*1024)*1024*1024*1024,321000)}; // needs 64bit for timestamp representation +const std::array TIMEVAL1 = {FuseUtimensTest::makeTimespec(0,0), FuseUtimensTest::makeTimespec(0,0)}; +const std::array TIMEVAL2 = {FuseUtimensTest::makeTimespec(1000,0), FuseUtimensTest::makeTimespec(0,0)}; +const std::array TIMEVAL3 = {FuseUtimensTest::makeTimespec(0,1000), FuseUtimensTest::makeTimespec(0,0)}; +const std::array TIMEVAL4 = {FuseUtimensTest::makeTimespec(1000,1000), FuseUtimensTest::makeTimespec(0,0)}; +const std::array TIMEVAL5 = {FuseUtimensTest::makeTimespec(0,0), FuseUtimensTest::makeTimespec(0,0)}; +const std::array TIMEVAL6 = {FuseUtimensTest::makeTimespec(0,0), FuseUtimensTest::makeTimespec(1000,0)}; +const std::array TIMEVAL7 = {FuseUtimensTest::makeTimespec(0,0), FuseUtimensTest::makeTimespec(0,1000)}; +const std::array TIMEVAL8 = {FuseUtimensTest::makeTimespec(0,0), FuseUtimensTest::makeTimespec(1000,1000)}; +const std::array TIMEVAL9 = {FuseUtimensTest::makeTimespec(1417196126,123000), FuseUtimensTest::makeTimespec(1417109713,321000)}; // current timestamp and the day before as of writing this test case +const std::array TIMEVAL10 = {FuseUtimensTest::makeTimespec(UINT64_C(1024)*1024*1024*1024,999000), FuseUtimensTest::makeTimespec(UINT64_C(2*1024)*1024*1024*1024,321000)}; // needs 64bit for timestamp representation INSTANTIATE_TEST_CASE_P(FuseUtimensTimeParameterTest, FuseUtimensTimeParameterTest, Values(TIMEVAL1, TIMEVAL2, TIMEVAL3, TIMEVAL4, TIMEVAL5, TIMEVAL6, TIMEVAL7, TIMEVAL8, TIMEVAL9, TIMEVAL10)); diff --git a/test/fspp/fuse/write/FuseWriteFileDescriptorTest.cpp b/test/fspp/fuse/write/FuseWriteFileDescriptorTest.cpp index e586eafd..50158d44 100644 --- a/test/fspp/fuse/write/FuseWriteFileDescriptorTest.cpp +++ b/test/fspp/fuse/write/FuseWriteFileDescriptorTest.cpp @@ -21,6 +21,6 @@ TEST_P(FuseWriteFileDescriptorTest, FileDescriptorIsCorrect) { EXPECT_CALL(*fsimpl, write(Eq(GetParam()), _, _, _)) .Times(1).WillOnce(Return()); - char buf[1]; - WriteFile(FILENAME, buf, fspp::num_bytes_t(1), fspp::num_bytes_t(0)); + std::array buf{}; + WriteFile(FILENAME, buf.data(), fspp::num_bytes_t(1), fspp::num_bytes_t(0)); }