fixup: new coverity warnings (#3864)

* fixup: memcmp length argument regression

* perf: fix big parameter passed by value

* chore: silence unchecked curl_easy_setopt return value warning
This commit is contained in:
Charles Kerr 2022-10-02 19:45:38 -05:00 committed by GitHub
parent 3bb8f3c03f
commit fed6d180fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 8 deletions

View File

@ -581,10 +581,9 @@ void BlocklistFile::assertValidRules(std::vector<AddressRange> const& ranges)
for (size_t i = 1; i < std::size(ranges_ipv6); ++i)
{
auto last_end_address = ranges_ipv6[i - 1].end6_.s6_addr;
auto start_address = ranges_ipv6[i].begin6_.s6_addr;
TR_ASSERT(memcmp(last_end_address, start_address, sizeof(&start_address)) > 0);
auto const& last_end_address = ranges_ipv6[i - 1].end6_;
auto const& start_address = ranges_ipv6[i].begin6_;
TR_ASSERT(memcmp(&last_end_address, &start_address, sizeof(start_address)) > 0);
}
}
#endif

View File

@ -11,6 +11,7 @@
#include <cstddef> // for size_t
#include <cstdint>
#include <cstring>
#include <memory>
#include <string>
#include <string_view>

View File

@ -32,7 +32,7 @@ public:
[[nodiscard]] virtual tr_sha1_digest_t finish() = 0;
template<typename... T>
[[nodiscard]] static tr_sha1_digest_t digest(T... args)
[[nodiscard]] static tr_sha1_digest_t digest(T const&... args)
{
auto context = tr_sha1::create();
(context->add(std::data(args), std::size(args)), ...);
@ -51,7 +51,7 @@ public:
[[nodiscard]] virtual tr_sha256_digest_t finish() = 0;
template<typename... T>
[[nodiscard]] static tr_sha256_digest_t digest(T... args)
[[nodiscard]] static tr_sha256_digest_t digest(T const&... args)
{
auto context = tr_sha256::create();
(context->add(std::data(args), std::size(args)), ...);

View File

@ -345,8 +345,8 @@ void doScrape(tr_torrent_metainfo const& metainfo)
fflush(stdout);
// execute the http scrape
curl_easy_setopt(curl, CURLOPT_URL, scrape_url.c_str());
curl_easy_setopt(curl, CURLOPT_TIMEOUT, TimeoutSecs);
(void)curl_easy_setopt(curl, CURLOPT_URL, scrape_url.c_str());
(void)curl_easy_setopt(curl, CURLOPT_TIMEOUT, TimeoutSecs);
if (auto const res = curl_easy_perform(curl); res != CURLE_OK)
{
fmt::print("error: {:s}\n", curl_easy_strerror(res));