mirror of
https://github.com/transmission/transmission
synced 2025-01-03 13:35:36 +00:00
fix: sonarcloud warnings (#4023)
This commit is contained in:
parent
088e146cee
commit
798e873b87
11 changed files with 17 additions and 19 deletions
|
@ -13,7 +13,7 @@
|
||||||
class PathButton::Impl
|
class PathButton::Impl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Impl(PathButton& widget);
|
explicit Impl(PathButton& widget);
|
||||||
|
|
||||||
TR_DISABLE_COPY_MOVE(Impl)
|
TR_DISABLE_COPY_MOVE(Impl)
|
||||||
|
|
||||||
|
|
|
@ -286,9 +286,9 @@ bool on_tree_view_button_pressed(
|
||||||
if (context_menu_requested)
|
if (context_menu_requested)
|
||||||
{
|
{
|
||||||
Gtk::TreeModel::Path path;
|
Gtk::TreeModel::Path path;
|
||||||
auto const selection = view.get_selection();
|
|
||||||
|
|
||||||
if (view.get_path_at_pos((int)view_x, (int)view_y, path) && !selection->is_selected(path))
|
if (auto const selection = view.get_selection();
|
||||||
|
view.get_path_at_pos((int)view_x, (int)view_y, path) && !selection->is_selected(path))
|
||||||
{
|
{
|
||||||
selection->unselect_all();
|
selection->unselect_all();
|
||||||
selection->select(path);
|
selection->select(path);
|
||||||
|
@ -707,8 +707,8 @@ void gtr_paste_clipboard_url_into_entry(Gtk::Entry& entry)
|
||||||
{
|
{
|
||||||
auto const process = [&entry](Glib::ustring const& text)
|
auto const process = [&entry](Glib::ustring const& text)
|
||||||
{
|
{
|
||||||
auto const sv = tr_strvStrip(text.raw());
|
if (auto const sv = tr_strvStrip(text.raw());
|
||||||
if (!sv.empty() && (tr_urlIsValid(sv) || tr_magnet_metainfo{}.parseMagnet(sv)))
|
!sv.empty() && (tr_urlIsValid(sv) || tr_magnet_metainfo{}.parseMagnet(sv)))
|
||||||
{
|
{
|
||||||
entry.set_text(text);
|
entry.set_text(text);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -22,8 +22,6 @@
|
||||||
#include "dns.h"
|
#include "dns.h"
|
||||||
#include "utils.h" // for tr_strlower()
|
#include "utils.h" // for tr_strlower()
|
||||||
|
|
||||||
using namespace std::literals;
|
|
||||||
|
|
||||||
namespace libtransmission
|
namespace libtransmission
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -107,7 +105,8 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
auto& request = requests_[key];
|
auto& request = requests_[key];
|
||||||
auto const tag = next_tag_++;
|
auto const tag = next_tag_;
|
||||||
|
++next_tag_;
|
||||||
request.callbacks.emplace_back(tag, std::move(callback));
|
request.callbacks.emplace_back(tag, std::move(callback));
|
||||||
if (request.request == nullptr)
|
if (request.request == nullptr)
|
||||||
{
|
{
|
||||||
|
|
|
@ -321,7 +321,7 @@ struct tr_peer_socket tr_netOpenPeerSocket(tr_session* session, tr_address const
|
||||||
auto const [source_addr, is_default_addr] = session->publicAddress(addr->type);
|
auto const [source_addr, is_default_addr] = session->publicAddress(addr->type);
|
||||||
auto const [source_sock, sourcelen] = source_addr.toSockaddr({});
|
auto const [source_sock, sourcelen] = source_addr.toSockaddr({});
|
||||||
|
|
||||||
if (bind(s, (struct sockaddr*)&source_sock, sourcelen) == -1)
|
if (bind(s, reinterpret_cast<sockaddr const*>(&source_sock), sourcelen) == -1)
|
||||||
{
|
{
|
||||||
tr_logAddWarn(fmt::format(
|
tr_logAddWarn(fmt::format(
|
||||||
_("Couldn't set source address {address} on {socket}: {error} ({error_code})"),
|
_("Couldn't set source address {address} on {socket}: {error} ({error_code})"),
|
||||||
|
@ -334,7 +334,7 @@ struct tr_peer_socket tr_netOpenPeerSocket(tr_session* session, tr_address const
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ret = tr_peer_socket{};
|
auto ret = tr_peer_socket{};
|
||||||
if (connect(s, (struct sockaddr*)&sock, addrlen) == -1 &&
|
if (connect(s, reinterpret_cast<sockaddr const*>(&sock), addrlen) == -1 &&
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
sockerrno != WSAEWOULDBLOCK &&
|
sockerrno != WSAEWOULDBLOCK &&
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -142,7 +142,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
constexpr tr_port(uint16_t hport) noexcept
|
explicit constexpr tr_port(uint16_t hport) noexcept
|
||||||
: hport_{ hport }
|
: hport_{ hport }
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -205,8 +205,7 @@ static void event_read_cb(evutil_socket_t fd, short /*event*/, void* vio)
|
||||||
}
|
}
|
||||||
|
|
||||||
tr_error* error = nullptr;
|
tr_error* error = nullptr;
|
||||||
auto const res = io->inbuf.addSocket(fd, howmuch, &error);
|
if (auto const res = io->inbuf.addSocket(fd, howmuch, &error); res > 0)
|
||||||
if (res > 0)
|
|
||||||
{
|
{
|
||||||
io->setEnabled(dir, true);
|
io->setEnabled(dir, true);
|
||||||
|
|
||||||
|
|
|
@ -290,7 +290,7 @@ static void acceptIncomingPeer(evutil_socket_t fd, short /*what*/, void* vsessio
|
||||||
|
|
||||||
if (auto const incoming_info = tr_netAccept(session, fd); incoming_info)
|
if (auto const incoming_info = tr_netAccept(session, fd); incoming_info)
|
||||||
{
|
{
|
||||||
auto const [addr, port, sock] = *incoming_info;
|
auto const& [addr, port, sock] = *incoming_info;
|
||||||
tr_logAddTrace(fmt::format("new incoming connection {} ({})", sock, addr.readable(port)));
|
tr_logAddTrace(fmt::format("new incoming connection {} ({})", sock, addr.readable(port)));
|
||||||
session->addIncoming(addr, port, tr_peer_socket_tcp_create(sock));
|
session->addIncoming(addr, port, tr_peer_socket_tcp_create(sock));
|
||||||
}
|
}
|
||||||
|
|
|
@ -143,7 +143,7 @@ private:
|
||||||
class AnnouncerUdpMediator final : public tr_announcer_udp::Mediator
|
class AnnouncerUdpMediator final : public tr_announcer_udp::Mediator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AnnouncerUdpMediator(tr_session& session)
|
explicit AnnouncerUdpMediator(tr_session& session)
|
||||||
: session_{ session }
|
: session_{ session }
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace libtransmission
|
||||||
class EvTimerMaker final : public TimerMaker
|
class EvTimerMaker final : public TimerMaker
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
EvTimerMaker(event_base* base)
|
explicit EvTimerMaker(event_base* base)
|
||||||
: event_base_{ base }
|
: event_base_{ base }
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,7 +125,7 @@ public:
|
||||||
Buffer& operator=(Buffer&&) = default;
|
Buffer& operator=(Buffer&&) = default;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
Buffer(T const& data)
|
explicit Buffer(T const& data)
|
||||||
{
|
{
|
||||||
add(std::data(data), std::size(data));
|
add(std::data(data), std::size(data));
|
||||||
}
|
}
|
||||||
|
@ -137,7 +137,7 @@ public:
|
||||||
|
|
||||||
[[nodiscard]] auto empty() const noexcept
|
[[nodiscard]] auto empty() const noexcept
|
||||||
{
|
{
|
||||||
return size() == 0U;
|
return evbuffer_get_length(buf_.get()) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] auto vecs(size_t n_bytes) const
|
[[nodiscard]] auto vecs(size_t n_bytes) const
|
||||||
|
|
|
@ -92,7 +92,7 @@ static void utp_on_accept(tr_session* const session, UTPSocket* const utp_sock)
|
||||||
|
|
||||||
if (auto addrport = tr_address::fromSockaddr(reinterpret_cast<struct sockaddr*>(&from_storage)); addrport)
|
if (auto addrport = tr_address::fromSockaddr(reinterpret_cast<struct sockaddr*>(&from_storage)); addrport)
|
||||||
{
|
{
|
||||||
auto const [addr, port] = *addrport;
|
auto const& [addr, port] = *addrport;
|
||||||
session->addIncoming(addr, port, tr_peer_socket_utp_create(utp_sock));
|
session->addIncoming(addr, port, tr_peer_socket_utp_create(utp_sock));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue