Fix inaccuracies pointed out by PVS-Studio

This commit is contained in:
RipleyTom 2023-03-21 21:06:18 +01:00 committed by Megamouse
parent ad3e740c09
commit 0f45a8c180
3 changed files with 5 additions and 16 deletions

View File

@ -2351,10 +2351,9 @@ void thread_ctrl::wait_for(u64 usec, [[maybe_unused]] bool alert /* true */)
{
struct itimerspec timeout;
u64 missed;
u64 nsec = usec * 1000ull;
timeout.it_value.tv_nsec = (nsec % 1000000000ull);
timeout.it_value.tv_sec = nsec / 1000000000ull;
timeout.it_value.tv_nsec = usec * 1'000ull;
timeout.it_value.tv_sec = 0;
timeout.it_interval.tv_sec = 0;
timeout.it_interval.tv_nsec = 0;
timerfd_settime(fd_timer, 0, &timeout, NULL);

View File

@ -382,7 +382,7 @@ bool lv2_socket_p2ps::handle_listening(p2ps_encapsulated_tcp* tcp_header, [[mayb
}
// Only valid packet
if (tcp_header->flags == p2ps_tcp_flags::SYN && backlog.size() < max_backlog)
if (tcp_header->flags == p2ps_tcp_flags::SYN)
{
if (backlog.size() >= max_backlog)
{
@ -394,6 +394,7 @@ bool lv2_socket_p2ps::handle_listening(p2ps_encapsulated_tcp* tcp_header, [[mayb
send_hdr.flags = p2ps_tcp_flags::RST;
auto packet = generate_u2s_packet(send_hdr, nullptr, 0);
send_u2s_packet(std::move(packet), reinterpret_cast<::sockaddr_in*>(op_addr), 0, false);
return true;
}
// Yes, new connection and a backlog is available, create a new lv2_socket for it and send SYN|ACK
@ -450,17 +451,6 @@ bool lv2_socket_p2ps::handle_listening(p2ps_encapsulated_tcp* tcp_header, [[mayb
}
}
}
else if (tcp_header->flags == p2ps_tcp_flags::SYN)
{
// Send a RST packet on backlog full
sys_net.trace("[P2PS] Backlog was full, sent a RST packet");
p2ps_encapsulated_tcp send_hdr;
send_hdr.src_port = tcp_header->dst_port;
send_hdr.dst_port = tcp_header->src_port;
send_hdr.flags = p2ps_tcp_flags::RST;
auto packet = generate_u2s_packet(send_hdr, nullptr, 0);
send_u2s_packet(std::move(packet), reinterpret_cast<::sockaddr_in*>(op_addr), 0, false);
}
// Ignore other packets?

View File

@ -131,7 +131,7 @@ class evdev_joystick_handler final : public PadHandlerBase
{ 0x11d , "0x11d" },
{ 0x11e , "0x11e" },
{ 0x11f , "0x11f" },
{ BTN_JOYSTICK , "Joystick" },
//{ BTN_JOYSTICK , "Joystick" }, same as BTN_TRIGGER
{ BTN_TRIGGER , "Trigger" },
{ BTN_THUMB , "Thumb" },
{ BTN_THUMB2 , "Thumb 2" },