fixed some shadow warnings

This commit is contained in:
Arvid Norberg 2010-03-06 07:16:39 +00:00
parent b835b03ae8
commit e3a9578e2d
12 changed files with 111 additions and 111 deletions

View File

@ -388,9 +388,9 @@ namespace libtorrent
struct TORRENT_EXPORT peer_ban_alert: peer_alert struct TORRENT_EXPORT peer_ban_alert: peer_alert
{ {
peer_ban_alert(torrent_handle h, tcp::endpoint const& ip peer_ban_alert(torrent_handle h, tcp::endpoint const& ep
, peer_id const& pid) , peer_id const& peer_id)
: peer_alert(h, ip, pid) : peer_alert(h, ep, peer_id)
{} {}
TORRENT_DEFINE_ALERT(peer_ban_alert); TORRENT_DEFINE_ALERT(peer_ban_alert);
@ -400,9 +400,9 @@ namespace libtorrent
struct TORRENT_EXPORT peer_unsnubbed_alert: peer_alert struct TORRENT_EXPORT peer_unsnubbed_alert: peer_alert
{ {
peer_unsnubbed_alert(torrent_handle h, tcp::endpoint const& ip peer_unsnubbed_alert(torrent_handle h, tcp::endpoint const& ep
, peer_id const& pid) , peer_id const& peer_id)
: peer_alert(h, ip, pid) : peer_alert(h, ep, peer_id)
{} {}
TORRENT_DEFINE_ALERT(peer_unsnubbed_alert); TORRENT_DEFINE_ALERT(peer_unsnubbed_alert);
@ -412,9 +412,9 @@ namespace libtorrent
struct TORRENT_EXPORT peer_snubbed_alert: peer_alert struct TORRENT_EXPORT peer_snubbed_alert: peer_alert
{ {
peer_snubbed_alert(torrent_handle h, tcp::endpoint const& ip peer_snubbed_alert(torrent_handle h, tcp::endpoint const& ep
, peer_id const& pid) , peer_id const& peer_id)
: peer_alert(h, ip, pid) : peer_alert(h, ep, peer_id)
{} {}
TORRENT_DEFINE_ALERT(peer_snubbed_alert); TORRENT_DEFINE_ALERT(peer_snubbed_alert);
@ -424,9 +424,9 @@ namespace libtorrent
struct TORRENT_EXPORT peer_error_alert: peer_alert struct TORRENT_EXPORT peer_error_alert: peer_alert
{ {
peer_error_alert(torrent_handle const& h, tcp::endpoint const& ip peer_error_alert(torrent_handle const& h, tcp::endpoint const& ep
, peer_id const& pid, error_code const& e) , peer_id const& peer_id, error_code const& e)
: peer_alert(h, ip, pid) : peer_alert(h, ep, peer_id)
, error(e) , error(e)
{ {
#ifndef TORRENT_NO_DEPRECATE #ifndef TORRENT_NO_DEPRECATE
@ -451,9 +451,9 @@ namespace libtorrent
struct TORRENT_EXPORT peer_connect_alert: peer_alert struct TORRENT_EXPORT peer_connect_alert: peer_alert
{ {
peer_connect_alert(torrent_handle h, tcp::endpoint const& ip peer_connect_alert(torrent_handle h, tcp::endpoint const& ep
, peer_id const& pid) , peer_id const& peer_id)
: peer_alert(h, ip, pid) : peer_alert(h, ep, peer_id)
{} {}
TORRENT_DEFINE_ALERT(peer_connect_alert); TORRENT_DEFINE_ALERT(peer_connect_alert);
@ -465,9 +465,9 @@ namespace libtorrent
struct TORRENT_EXPORT peer_disconnected_alert: peer_alert struct TORRENT_EXPORT peer_disconnected_alert: peer_alert
{ {
peer_disconnected_alert(torrent_handle const& h, tcp::endpoint const& ip peer_disconnected_alert(torrent_handle const& h, tcp::endpoint const& ep
, peer_id const& pid, error_code const& e) , peer_id const& peer_id, error_code const& e)
: peer_alert(h, ip, pid) : peer_alert(h, ep, peer_id)
, error(e) , error(e)
{ {
#ifndef TORRENT_NO_DEPRECATE #ifndef TORRENT_NO_DEPRECATE
@ -490,9 +490,9 @@ namespace libtorrent
struct TORRENT_EXPORT invalid_request_alert: peer_alert struct TORRENT_EXPORT invalid_request_alert: peer_alert
{ {
invalid_request_alert(torrent_handle const& h, tcp::endpoint const& ip invalid_request_alert(torrent_handle const& h, tcp::endpoint const& ep
, peer_id const& pid, peer_request const& r) , peer_id const& peer_id, peer_request const& r)
: peer_alert(h, ip, pid) : peer_alert(h, ep, peer_id)
, request(r) , request(r)
{} {}
@ -536,9 +536,9 @@ namespace libtorrent
struct TORRENT_EXPORT request_dropped_alert: peer_alert struct TORRENT_EXPORT request_dropped_alert: peer_alert
{ {
request_dropped_alert(const torrent_handle& h, tcp::endpoint const& ip request_dropped_alert(const torrent_handle& h, tcp::endpoint const& ep
, peer_id const& pid, int block_num, int piece_num) , peer_id const& peer_id, int block_num, int piece_num)
: peer_alert(h, ip, pid) : peer_alert(h, ep, peer_id)
, block_index(block_num) , block_index(block_num)
, piece_index(piece_num) , piece_index(piece_num)
{ TORRENT_ASSERT(block_index >= 0 && piece_index >= 0);} { TORRENT_ASSERT(block_index >= 0 && piece_index >= 0);}
@ -555,9 +555,9 @@ namespace libtorrent
struct TORRENT_EXPORT block_timeout_alert: peer_alert struct TORRENT_EXPORT block_timeout_alert: peer_alert
{ {
block_timeout_alert(const torrent_handle& h, tcp::endpoint const& ip block_timeout_alert(const torrent_handle& h, tcp::endpoint const& ep
, peer_id const& pid, int block_num, int piece_num) , peer_id const& peer_id, int block_num, int piece_num)
: peer_alert(h, ip, pid) : peer_alert(h, ep, peer_id)
, block_index(block_num) , block_index(block_num)
, piece_index(piece_num) , piece_index(piece_num)
{ TORRENT_ASSERT(block_index >= 0 && piece_index >= 0);} { TORRENT_ASSERT(block_index >= 0 && piece_index >= 0);}
@ -574,9 +574,9 @@ namespace libtorrent
struct TORRENT_EXPORT block_finished_alert: peer_alert struct TORRENT_EXPORT block_finished_alert: peer_alert
{ {
block_finished_alert(const torrent_handle& h, tcp::endpoint const& ip block_finished_alert(const torrent_handle& h, tcp::endpoint const& ep
, peer_id const& pid, int block_num, int piece_num) , peer_id const& peer_id, int block_num, int piece_num)
: peer_alert(h, ip, pid) : peer_alert(h, ep, peer_id)
, block_index(block_num) , block_index(block_num)
, piece_index(piece_num) , piece_index(piece_num)
{ TORRENT_ASSERT(block_index >= 0 && piece_index >= 0);} { TORRENT_ASSERT(block_index >= 0 && piece_index >= 0);}
@ -592,9 +592,9 @@ namespace libtorrent
struct TORRENT_EXPORT block_downloading_alert: peer_alert struct TORRENT_EXPORT block_downloading_alert: peer_alert
{ {
block_downloading_alert(const torrent_handle& h, tcp::endpoint const& ip block_downloading_alert(const torrent_handle& h, tcp::endpoint const& ep
, peer_id const& pid, char const* speedmsg, int block_num, int piece_num) , peer_id const& peer_id, char const* speedmsg, int block_num, int piece_num)
: peer_alert(h, ip, pid) : peer_alert(h, ep, peer_id)
, peer_speedmsg(speedmsg) , peer_speedmsg(speedmsg)
, block_index(block_num) , block_index(block_num)
, piece_index(piece_num) , piece_index(piece_num)
@ -612,9 +612,9 @@ namespace libtorrent
struct TORRENT_EXPORT unwanted_block_alert: peer_alert struct TORRENT_EXPORT unwanted_block_alert: peer_alert
{ {
unwanted_block_alert(const torrent_handle& h, tcp::endpoint const& ip unwanted_block_alert(const torrent_handle& h, tcp::endpoint const& ep
, peer_id const& pid, int block_num, int piece_num) , peer_id const& peer_id, int block_num, int piece_num)
: peer_alert(h, ip, pid) : peer_alert(h, ep, peer_id)
, block_index(block_num) , block_index(block_num)
, piece_index(piece_num) , piece_index(piece_num)
{ TORRENT_ASSERT(block_index >= 0 && piece_index >= 0);} { TORRENT_ASSERT(block_index >= 0 && piece_index >= 0);}

View File

@ -46,22 +46,22 @@ namespace libtorrent
{ resize(bits); } { resize(bits); }
bitfield(int bits, bool val): m_bytes(0), m_size(0) bitfield(int bits, bool val): m_bytes(0), m_size(0)
{ resize(bits, val); } { resize(bits, val); }
bitfield(char const* bytes, int bits): m_bytes(0), m_size(0) bitfield(char const* b, int bits): m_bytes(0), m_size(0)
{ assign(bytes, bits); } { assign(b, bits); }
bitfield(bitfield const& rhs): m_bytes(0), m_size(0), m_own(false) bitfield(bitfield const& rhs): m_bytes(0), m_size(0), m_own(false)
{ assign(rhs.bytes(), rhs.size()); } { assign(rhs.bytes(), rhs.size()); }
void borrow_bytes(char* bytes, int bits) void borrow_bytes(char* b, int bits)
{ {
dealloc(); dealloc();
m_bytes = (unsigned char*)bytes; m_bytes = (unsigned char*)b;
m_size = bits; m_size = bits;
m_own = false; m_own = false;
} }
~bitfield() { dealloc(); } ~bitfield() { dealloc(); }
void assign(char const* bytes, int bits) void assign(char const* b, int bits)
{ resize(bits); std::memcpy(m_bytes, bytes, (bits + 7) / 8); clear_trailing_bits(); } { resize(bits); std::memcpy(m_bytes, b, (bits + 7) / 8); clear_trailing_bits(); }
bool operator[](int index) const bool operator[](int index) const
{ return get_bit(index); } { return get_bit(index); }
@ -221,25 +221,25 @@ namespace libtorrent
void resize(int bits) void resize(int bits)
{ {
const int bytes = (bits + 7) / 8; const int b = (bits + 7) / 8;
if (m_bytes) if (m_bytes)
{ {
if (m_own) if (m_own)
{ {
m_bytes = (unsigned char*)std::realloc(m_bytes, bytes); m_bytes = (unsigned char*)std::realloc(m_bytes, b);
m_own = true; m_own = true;
} }
else if (bits > m_size) else if (bits > m_size)
{ {
unsigned char* tmp = (unsigned char*)std::malloc(bytes); unsigned char* tmp = (unsigned char*)std::malloc(b);
std::memcpy(tmp, m_bytes, (std::min)(int(m_size + 7)/ 8, bytes)); std::memcpy(tmp, m_bytes, (std::min)(int(m_size + 7)/ 8, b));
m_bytes = tmp; m_bytes = tmp;
m_own = true; m_own = true;
} }
} }
else else
{ {
m_bytes = (unsigned char*)std::malloc(bytes); m_bytes = (unsigned char*)std::malloc(b);
m_own = true; m_own = true;
} }
m_size = bits; m_size = bits;

View File

@ -49,9 +49,9 @@ public:
, end(0) , end(0)
{} {}
interval(char* begin, char* end) interval(char* b, char* e)
: begin(begin) : begin(b)
, end(end) , end(e)
{} {}
char operator[](int index) const char operator[](int index) const
@ -73,9 +73,9 @@ public:
, end(i.end) , end(i.end)
{} {}
const_interval(char const* begin, char const* end) const_interval(char const* b, char const* e)
: begin(begin) : begin(b)
, end(end) , end(e)
{} {}
char operator[](int index) const char operator[](int index) const
@ -151,18 +151,18 @@ public:
std::memcpy(m_begin + p, first, last - first); std::memcpy(m_begin + p, first, last - first);
} }
void erase(char* begin, char* end) void erase(char* b, char* e)
{ {
TORRENT_ASSERT(end <= m_end); TORRENT_ASSERT(e <= m_end);
TORRENT_ASSERT(begin >= m_begin); TORRENT_ASSERT(b >= m_begin);
TORRENT_ASSERT(begin <= end); TORRENT_ASSERT(b <= e);
if (end == m_end) if (e == m_end)
{ {
resize(begin - m_begin); resize(b - m_begin);
return; return;
} }
std::memmove(begin, end, m_end - end); std::memmove(b, e, m_end - e);
m_end = begin + (m_end - end); m_end = b + (m_end - e);
} }
void clear() { m_end = m_begin; } void clear() { m_end = m_begin; }

View File

@ -95,19 +95,19 @@ namespace libtorrent
} }
template <class D> template <class D>
void append_buffer(char* buffer, int size, int used_size, D const& destructor) void append_buffer(char* buffer, int s, int used_size, D const& destructor)
{ {
TORRENT_ASSERT(size >= used_size); TORRENT_ASSERT(s >= used_size);
buffer_t b; buffer_t b;
b.buf = buffer; b.buf = buffer;
b.size = size; b.size = s;
b.start = buffer; b.start = buffer;
b.used_size = used_size; b.used_size = used_size;
b.free = destructor; b.free = destructor;
m_vec.push_back(b); m_vec.push_back(b);
m_bytes += used_size; m_bytes += used_size;
m_capacity += size; m_capacity += s;
TORRENT_ASSERT(m_bytes <= m_capacity); TORRENT_ASSERT(m_bytes <= m_capacity);
} }
@ -123,25 +123,25 @@ namespace libtorrent
// tries to copy the given buffer to the end of the // tries to copy the given buffer to the end of the
// last chained buffer. If there's not enough room // last chained buffer. If there's not enough room
// it returns false // it returns false
bool append(char const* buf, int size) bool append(char const* buf, int s)
{ {
char* insert = allocate_appendix(size); char* insert = allocate_appendix(s);
if (insert == 0) return false; if (insert == 0) return false;
std::memcpy(insert, buf, size); std::memcpy(insert, buf, s);
return true; return true;
} }
// tries to allocate memory from the end // tries to allocate memory from the end
// of the last buffer. If there isn't // of the last buffer. If there isn't
// enough room, returns 0 // enough room, returns 0
char* allocate_appendix(int size) char* allocate_appendix(int s)
{ {
if (m_vec.empty()) return 0; if (m_vec.empty()) return 0;
buffer_t& b = m_vec.back(); buffer_t& b = m_vec.back();
char* insert = b.start + b.used_size; char* insert = b.start + b.used_size;
if (insert + size > b.buf + b.size) return 0; if (insert + s > b.buf + b.size) return 0;
b.used_size += size; b.used_size += s;
m_bytes += size; m_bytes += s;
TORRENT_ASSERT(m_bytes <= m_capacity); TORRENT_ASSERT(m_bytes <= m_capacity);
return insert; return insert;
} }

View File

@ -241,7 +241,7 @@ namespace detail
struct range struct range
{ {
range(Addr addr, int access = 0): start(addr), access(access) {} range(Addr addr, int a = 0): start(addr), access(a) {}
bool operator<(range const& r) const bool operator<(range const& r) const
{ return start < r.start; } { return start < r.start; }
bool operator<(Addr const& a) const bool operator<(Addr const& a) const

View File

@ -279,7 +279,7 @@ namespace libtorrent
void keep_alive(); void keep_alive();
peer_id const& pid() const { return m_peer_id; } peer_id const& pid() const { return m_peer_id; }
void set_pid(const peer_id& pid) { m_peer_id = pid; } void set_pid(const peer_id& peer_id) { m_peer_id = peer_id; }
bool has_piece(int i) const; bool has_piece(int i) const;
std::vector<pending_block> const& download_queue() const; std::vector<pending_block> const& download_queue() const;
@ -1063,10 +1063,10 @@ namespace libtorrent
struct allocating_handler struct allocating_handler
{ {
allocating_handler( allocating_handler(
Handler const& handler, handler_storage<Size>& storage Handler const& h, handler_storage<Size>& s
) )
: handler(handler) : handler(h)
, storage(storage) , storage(s)
{} {}
template <class A0> template <class A0>

View File

@ -425,15 +425,15 @@ namespace libtorrent
// prio 4,5,6 halves the availability of a piece // prio 4,5,6 halves the availability of a piece
int availability = peer_count; int availability = peer_count;
int priority = piece_priority; int p = piece_priority;
if (piece_priority >= priority_levels / 2) if (piece_priority >= priority_levels / 2)
{ {
availability /= 2; availability /= 2;
priority -= (priority_levels - 2) / 2; p -= (priority_levels - 2) / 2;
} }
if (downloading) return availability * prio_factor; if (downloading) return availability * prio_factor;
return availability * prio_factor + (priority_levels / 2) - priority; return availability * prio_factor + (priority_levels / 2) - p;
} }
bool operator!=(piece_pos p) const bool operator!=(piece_pos p) const

View File

@ -464,10 +464,10 @@ namespace libtorrent
}; };
inline policy::ipv4_peer::ipv4_peer( inline policy::ipv4_peer::ipv4_peer(
tcp::endpoint const& ip, bool connectable, int src tcp::endpoint const& ep, bool c, int src
) )
: peer(ip.port(), connectable, src) : peer(ep.port(), c, src)
, addr(ip.address().to_v4()) , addr(ep.address().to_v4())
{ {
#if TORRENT_USE_IPV6 #if TORRENT_USE_IPV6
is_v6_addr = false; is_v6_addr = false;
@ -512,10 +512,10 @@ namespace libtorrent
#if TORRENT_USE_IPV6 #if TORRENT_USE_IPV6
inline policy::ipv6_peer::ipv6_peer( inline policy::ipv6_peer::ipv6_peer(
tcp::endpoint const& ip, bool connectable, int src tcp::endpoint const& ep, bool c, int src
) )
: peer(ip.port(), connectable, src) : peer(ep.port(), c, src)
, addr(ip.address().to_v6().to_bytes()) , addr(ep.address().to_v6().to_bytes())
{ {
is_v6_addr = true; is_v6_addr = true;
#if TORRENT_USE_I2P #if TORRENT_USE_I2P

View File

@ -112,11 +112,11 @@ namespace libtorrent
size_type rate_sum() const { return m_rate_sum; } size_type rate_sum() const { return m_rate_sum; }
size_type total() const { return m_total_counter; } size_type total() const { return m_total_counter; }
void offset(size_type counter) void offset(size_type c)
{ {
TORRENT_ASSERT(counter >= 0); TORRENT_ASSERT(c >= 0);
TORRENT_ASSERT(m_total_counter >= 0); TORRENT_ASSERT(m_total_counter >= 0);
m_total_counter += counter; m_total_counter += c;
TORRENT_ASSERT(m_total_counter >= 0); TORRENT_ASSERT(m_total_counter >= 0);
} }

View File

@ -275,8 +275,8 @@ namespace libtorrent
std::string save_path() const; std::string save_path() const;
bool verify_resume_data(lazy_entry const& rd, error_code& error) bool verify_resume_data(lazy_entry const& rd, error_code& e)
{ return m_storage->verify_resume_data(rd, error); } { return m_storage->verify_resume_data(rd, e); }
bool is_allocating() const bool is_allocating() const
{ return m_state == state_expand_pieces; } { return m_state == state_expand_pieces; }

View File

@ -307,8 +307,8 @@ namespace libtorrent
void connect_to_url_seed(std::list<web_seed_entry>::iterator url); void connect_to_url_seed(std::list<web_seed_entry>::iterator url);
bool connect_to_peer(policy::peer* peerinfo); bool connect_to_peer(policy::peer* peerinfo);
void set_ratio(float ratio) void set_ratio(float r)
{ TORRENT_ASSERT(ratio >= 0.0f); m_ratio = ratio; } { TORRENT_ASSERT(r >= 0.0f); m_ratio = r; }
float ratio() const float ratio() const
{ return m_ratio; } { return m_ratio; }

View File

@ -56,8 +56,8 @@ namespace aux
template<class IO_Control_Command> template<class IO_Control_Command>
struct io_control_visitor_ec: boost::static_visitor<> struct io_control_visitor_ec: boost::static_visitor<>
{ {
io_control_visitor_ec(IO_Control_Command& ioc, error_code& ec_) io_control_visitor_ec(IO_Control_Command& io, error_code& e)
: ioc(ioc), ec(ec_) {} : ioc(io), ec(e) {}
template <class T> template <class T>
void operator()(T* p) const void operator()(T* p) const
@ -76,8 +76,8 @@ namespace aux
struct io_control_visitor struct io_control_visitor
: boost::static_visitor<> : boost::static_visitor<>
{ {
io_control_visitor(IO_Control_Command& ioc) io_control_visitor(IO_Control_Command& io)
: ioc(ioc) {} : ioc(io) {}
template <class T> template <class T>
void operator()(T* p) const void operator()(T* p) const
@ -96,9 +96,9 @@ namespace aux
struct async_connect_visitor struct async_connect_visitor
: boost::static_visitor<> : boost::static_visitor<>
{ {
async_connect_visitor(EndpointType const& endpoint, Handler const& handler) async_connect_visitor(EndpointType const& ep, Handler const& h)
: endpoint(endpoint) : endpoint(ep)
, handler(handler) , handler(h)
{} {}
template <class T> template <class T>
@ -357,9 +357,9 @@ namespace aux
struct async_read_some_visitor struct async_read_some_visitor
: boost::static_visitor<> : boost::static_visitor<>
{ {
async_read_some_visitor(Mutable_Buffers const& buffers, Handler const& handler) async_read_some_visitor(Mutable_Buffers const& bufs, Handler const& h)
: buffers(buffers) : buffers(bufs)
, handler(handler) , handler(h)
{} {}
template <class T> template <class T>
@ -381,8 +381,8 @@ namespace aux
struct read_some_visitor struct read_some_visitor
: boost::static_visitor<std::size_t> : boost::static_visitor<std::size_t>
{ {
read_some_visitor(Mutable_Buffers const& buffers) read_some_visitor(Mutable_Buffers const& bufs)
: buffers(buffers) : buffers(bufs)
{} {}
template <class T> template <class T>
@ -400,9 +400,9 @@ namespace aux
struct read_some_visitor_ec struct read_some_visitor_ec
: boost::static_visitor<std::size_t> : boost::static_visitor<std::size_t>
{ {
read_some_visitor_ec(Mutable_Buffers const& buffers, error_code& ec_) read_some_visitor_ec(Mutable_Buffers const& bufs, error_code& e)
: buffers(buffers) : buffers(bufs)
, ec(ec_) , ec(e)
{} {}
template <class T> template <class T>
@ -422,9 +422,9 @@ namespace aux
struct async_write_some_visitor struct async_write_some_visitor
: boost::static_visitor<> : boost::static_visitor<>
{ {
async_write_some_visitor(Const_Buffers const& buffers, Handler const& handler) async_write_some_visitor(Const_Buffers const& bufs, Handler const& h)
: buffers(buffers) : buffers(bufs)
, handler(handler) , handler(h)
{} {}
template <class T> template <class T>