From: Joel Rosdahl Date: Thu, 19 Aug 2021 17:57:13 +0000 (+0200) Subject: chore: Fix Cppcheck warnings X-Git-Tag: v4.4~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1603069851a3f1c1d77588f56a71caad0ba09cfe;p=thirdparty%2Fccache.git chore: Fix Cppcheck warnings --- diff --git a/src/ResultRetriever.hpp b/src/ResultRetriever.hpp index a2ab43941..4794afdef 100644 --- a/src/ResultRetriever.hpp +++ b/src/ResultRetriever.hpp @@ -39,7 +39,7 @@ public: private: Context& m_ctx; - Result::FileType m_dest_file_type; + Result::FileType m_dest_file_type{}; Fd m_dest_fd; std::string m_dest_path; diff --git a/src/argprocessing.cpp b/src/argprocessing.cpp index e5b6f9cea..c77dd1125 100644 --- a/src/argprocessing.cpp +++ b/src/argprocessing.cpp @@ -341,7 +341,7 @@ process_arg(Context& ctx, // Some arguments that clang passes directly to cc1 (related to precompiled // headers) need the usual ccache handling. In those cases, the -Xclang // prefix is skipped and the cc1 argument is handled instead. - if (args[i] == "-Xclang" && i < args.size() - 1 + if (args[i] == "-Xclang" && i + 1 < args.size() && (args[i + 1] == "-emit-pch" || args[i + 1] == "-emit-pth" || args[i + 1] == "-include-pch" || args[i + 1] == "-include-pth" || args[i + 1] == "-fno-pch-timestamp")) { @@ -741,7 +741,7 @@ process_arg(Context& ctx, // In the "-Xclang -fcolor-diagnostics" form, -Xclang is skipped and the // -fcolor-diagnostics argument which is passed to cc1 is handled below. - if (args[i] == "-Xclang" && i < args.size() - 1 + if (args[i] == "-Xclang" && i + 1 < args.size() && args[i + 1] == "-fcolor-diagnostics") { state.compiler_only_args_no_hash.push_back(args[i]); ++i; diff --git a/src/storage/secondary/RedisStorage.cpp b/src/storage/secondary/RedisStorage.cpp index 8c12083cb..c08fc06e0 100644 --- a/src/storage/secondary/RedisStorage.cpp +++ b/src/storage/secondary/RedisStorage.cpp @@ -280,16 +280,14 @@ RedisStorageBackend::authenticate(const Url& url) const auto password_username_pair = split_user_info(url.user_info()); const auto& password = password_username_pair.first; if (password) { - decltype(redis_command("")) reply = nonstd::make_unexpected(Failure::error); const auto& username = password_username_pair.second; if (username) { LOG("Redis AUTH {} {}", *username, k_redacted_password); - reply = util::value_or_throw( + util::value_or_throw( redis_command("AUTH %s %s", username->c_str(), password->c_str())); } else { LOG("Redis AUTH {}", k_redacted_password); - reply = util::value_or_throw( - redis_command("AUTH %s", password->c_str())); + util::value_or_throw(redis_command("AUTH %s", password->c_str())); } } }