fixing sign-conversion warnings, part 23, final (#1763)
fixing sign-conversion warnings, part 23, final
This commit is contained in:
parent
de9d777c9c
commit
3764ee62cb
1
Jamfile
1
Jamfile
|
@ -244,7 +244,6 @@ rule warnings ( properties * )
|
|||
|
||||
# enable these warnings again, once the other ones are dealt with
|
||||
result += <cflags>-Wno-weak-vtables ;
|
||||
result += <cflags>-Wno-sign-conversion ;
|
||||
}
|
||||
|
||||
if <toolset>gcc in $(properties)
|
||||
|
|
|
@ -81,14 +81,14 @@ namespace libtorrent
|
|||
int size() const
|
||||
{ return m_size; }
|
||||
|
||||
int capacity() const
|
||||
std::uint32_t capacity() const
|
||||
{ return m_capacity; }
|
||||
|
||||
packet* at(index_type idx) const;
|
||||
|
||||
packet_ptr remove(index_type idx);
|
||||
|
||||
void reserve(int size);
|
||||
void reserve(std::uint32_t size);
|
||||
|
||||
index_type cursor() const { return m_first; }
|
||||
|
||||
|
@ -100,7 +100,7 @@ namespace libtorrent
|
|||
|
||||
private:
|
||||
aux::unique_ptr<packet_ptr[], index_type> m_storage;
|
||||
int m_capacity = 0;
|
||||
std::uint32_t m_capacity = 0;
|
||||
|
||||
// this is the total number of elements that are occupied
|
||||
// in the array
|
||||
|
|
|
@ -42,6 +42,8 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
#include "libtorrent/assert.hpp"
|
||||
#include "libtorrent/debug.hpp" // for single_threaded
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
namespace libtorrent
|
||||
{
|
||||
// internal: some MTU and protocol header sizes constants
|
||||
|
@ -146,7 +148,7 @@ namespace libtorrent
|
|||
void decay()
|
||||
{
|
||||
if (m_storage.empty()) return;
|
||||
m_storage.erase(m_storage.end()-1);
|
||||
m_storage.erase(m_storage.end() - 1);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -30,8 +30,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
*/
|
||||
|
||||
#include <cstdlib> // free and calloc
|
||||
#include <new> // for bad_alloc
|
||||
#include "libtorrent/packet_buffer.hpp"
|
||||
#include "libtorrent/assert.hpp"
|
||||
#include "libtorrent/invariant_check.hpp"
|
||||
|
@ -45,7 +43,7 @@ namespace libtorrent {
|
|||
void packet_buffer::check_invariant() const
|
||||
{
|
||||
int count = 0;
|
||||
for (int i = 0; i < m_capacity; ++i)
|
||||
for (index_type i = 0; i < m_capacity; ++i)
|
||||
{
|
||||
count += m_storage[i] ? 1 : 0;
|
||||
}
|
||||
|
@ -70,7 +68,7 @@ namespace libtorrent {
|
|||
// Index comes before m_first. If we have room, we can simply
|
||||
// adjust m_first backward.
|
||||
|
||||
int free_space = 0;
|
||||
std::uint32_t free_space = 0;
|
||||
|
||||
for (index_type i = (m_first - 1) & (m_capacity - 1);
|
||||
i != (m_first & (m_capacity - 1)); i = (i - 1) & (m_capacity - 1))
|
||||
|
@ -80,7 +78,7 @@ namespace libtorrent {
|
|||
++free_space;
|
||||
}
|
||||
|
||||
if (((m_first - idx) & 0xffff) > std::uint32_t(free_space))
|
||||
if (((m_first - idx) & 0xffff) > free_space)
|
||||
reserve(((m_first - idx) & 0xffff) + m_capacity - free_space);
|
||||
|
||||
m_first = idx;
|
||||
|
@ -133,11 +131,11 @@ namespace libtorrent {
|
|||
return m_storage[idx & mask].get();
|
||||
}
|
||||
|
||||
void packet_buffer::reserve(int size)
|
||||
void packet_buffer::reserve(std::uint32_t size)
|
||||
{
|
||||
INVARIANT_CHECK;
|
||||
TORRENT_ASSERT_VAL(size <= 0xffff, size);
|
||||
int new_size = m_capacity == 0 ? 16 : m_capacity;
|
||||
std::uint32_t new_size = m_capacity == 0 ? 16 : m_capacity;
|
||||
|
||||
while (new_size < size)
|
||||
new_size <<= 1;
|
||||
|
@ -174,7 +172,7 @@ namespace libtorrent {
|
|||
if (idx == m_first && m_size != 0)
|
||||
{
|
||||
++m_first;
|
||||
for (int i = 0; i < m_capacity; ++i, ++m_first)
|
||||
for (index_type i = 0; i < m_capacity; ++i, ++m_first)
|
||||
if (m_storage[m_first & mask]) break;
|
||||
m_first &= 0xffff;
|
||||
}
|
||||
|
@ -182,7 +180,7 @@ namespace libtorrent {
|
|||
if (((idx + 1) & 0xffff) == m_last && m_size != 0)
|
||||
{
|
||||
--m_last;
|
||||
for (int i = 0; i < m_capacity; ++i, --m_last)
|
||||
for (index_type i = 0; i < m_capacity; ++i, --m_last)
|
||||
if (m_storage[m_last & mask]) break;
|
||||
++m_last;
|
||||
m_last &= 0xffff;
|
||||
|
|
|
@ -1910,8 +1910,8 @@ bool utp_socket_impl::send_pkt(int const flags)
|
|||
}
|
||||
|
||||
h->timestamp_difference_microseconds = m_reply_micro;
|
||||
h->wnd_size = std::max(m_in_buf_size - m_buffered_incoming_bytes
|
||||
- m_receive_buffer_size, std::int32_t(0));
|
||||
h->wnd_size = aux::numeric_cast<std::uint32_t>(std::max(m_in_buf_size - m_buffered_incoming_bytes
|
||||
- m_receive_buffer_size, 0));
|
||||
h->ack_nr = m_ack_nr;
|
||||
|
||||
// if this is a FIN packet, override the type
|
||||
|
@ -2638,9 +2638,9 @@ bool utp_socket_impl::incoming_packet(span<std::uint8_t const> buf
|
|||
std::uint32_t timestamp = std::uint32_t(total_microseconds(
|
||||
receive_time.time_since_epoch()) & 0xffffffff);
|
||||
m_reply_micro = timestamp - ph->timestamp_microseconds;
|
||||
std::uint32_t prev_base = m_their_delay_hist.initialized() ? m_their_delay_hist.base() : 0;
|
||||
std::uint32_t const prev_base = m_their_delay_hist.initialized() ? m_their_delay_hist.base() : 0;
|
||||
their_delay = m_their_delay_hist.add_sample(m_reply_micro, step);
|
||||
int base_change = m_their_delay_hist.base() - prev_base;
|
||||
int const base_change = int(m_their_delay_hist.base() - prev_base);
|
||||
UTP_LOGV("%8p: their_delay::add_sample:%u prev_base:%u new_base:%u\n"
|
||||
, static_cast<void*>(this), m_reply_micro, prev_base, m_their_delay_hist.base());
|
||||
|
||||
|
@ -2840,7 +2840,7 @@ bool utp_socket_impl::incoming_packet(span<std::uint8_t const> buf
|
|||
return true;
|
||||
}
|
||||
std::uint8_t const next_extension = *ptr++;
|
||||
int len = *ptr++;
|
||||
int const len = *ptr++;
|
||||
if (len < 0)
|
||||
{
|
||||
UTP_LOGV("%8p: invalid extension length:%d packet:%d\n"
|
||||
|
@ -3042,11 +3042,11 @@ bool utp_socket_impl::incoming_packet(span<std::uint8_t const> buf
|
|||
// sure to clamp it as a sanity check
|
||||
if (delay > min_rtt) delay = min_rtt;
|
||||
|
||||
do_ledbat(acked_bytes, delay, prev_bytes_in_flight);
|
||||
m_send_delay = delay;
|
||||
do_ledbat(acked_bytes, int(delay), prev_bytes_in_flight);
|
||||
m_send_delay = std::int32_t(delay);
|
||||
}
|
||||
|
||||
m_recv_delay = std::min(their_delay, min_rtt);
|
||||
m_recv_delay = std::int32_t(std::min(their_delay, min_rtt));
|
||||
|
||||
consume_incoming_data(ph, ptr, payload_size, receive_time);
|
||||
|
||||
|
@ -3624,11 +3624,11 @@ void utp_socket_impl::check_receive_buffers() const
|
|||
#if TORRENT_USE_INVARIANT_CHECKS
|
||||
void utp_socket_impl::check_invariant() const
|
||||
{
|
||||
for (int i = m_outbuf.cursor();
|
||||
i != int((m_outbuf.cursor() + m_outbuf.span()) & ACK_MASK);
|
||||
for (packet_buffer::index_type i = m_outbuf.cursor();
|
||||
i != ((m_outbuf.cursor() + m_outbuf.span()) & ACK_MASK);
|
||||
i = (i + 1) & ACK_MASK)
|
||||
{
|
||||
packet* p = m_outbuf.at(aux::numeric_cast<packet_buffer::index_type>(i));
|
||||
packet* p = m_outbuf.at(i);
|
||||
if (!p) continue;
|
||||
if (m_mtu_seq == i && m_mtu_seq != 0)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue