fix: clang-15 warnings (#3257)

This commit is contained in:
Charles Kerr 2022-06-11 14:35:08 -05:00 committed by GitHub
parent 61c1a0f1e8
commit cd592d0091
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 22 deletions

View File

@ -121,38 +121,38 @@ int readOrWriteBytes(
***/
auto fd = session->openFiles().get(tor->uniqueId, file_index, do_write);
if (!fd) // it's not cached, so open/create it now
auto filename = tr_pathbuf{};
if (!fd && !getFilename(filename, tor, file_index, io_mode))
{
auto filename = tr_pathbuf{};
if (!getFilename(filename, tor, file_index, io_mode))
{
return ENOENT;
}
return ENOENT;
}
if (!fd) // not in the cache, so open or create it now
{
// open (and maybe create) the file
auto const prealloc = (!do_write || !tor->fileIsWanted(file_index)) ? TR_PREALLOCATE_NONE :
tor->session->preallocationMode;
fd = session->openFiles().get(tor->uniqueId, file_index, do_write, filename, prealloc, file_size);
if (!fd)
{
int const err = errno;
tr_logAddErrorTor(
tor,
fmt::format(
_("Couldn't get '{path}': {error} ({error_code})"),
fmt::arg("path", filename),
fmt::arg("error", tr_strerror(err)),
fmt::arg("error_code", err)));
return err;
}
if (do_write)
if (fd && do_write)
{
// make a note that we just created a file
tr_statsFileCreated(tor->session);
}
}
if (!fd) // couldn't create/open it either
{
int const err = errno;
tr_logAddErrorTor(
tor,
fmt::format(
_("Couldn't get '{path}': {error} ({error_code})"),
fmt::arg("path", filename),
fmt::arg("error", tr_strerror(err)),
fmt::arg("error_code", err)));
return err;
}
switch (io_mode)
{
case IoMode::Read:

View File

@ -196,7 +196,7 @@ void tr_magnet_metainfo::addWebseed(std::string_view webseed)
return;
}
urls.emplace_back(std::string{ webseed });
urls.emplace_back(webseed);
}
bool tr_magnet_metainfo::parseMagnet(std::string_view magnet_link, tr_error** error)

View File

@ -259,7 +259,7 @@ public:
{
TR_ASSERT(!contains(address));
handshakes_.emplace_back(std::make_pair(address, handshake));
handshakes_.emplace_back(address, handshake);
}
[[nodiscard]] bool contains(tr_address const& address) const noexcept