fixed a whole bunch of build warnings on gcc and msvc, along with some fixes discovered along the way

This commit is contained in:
Arvid Norberg
2011-02-21 05:24:41 +00:00
parent 9fe69e7596
commit 141ada013f
73 changed files with 353 additions and 248 deletions

View File

@@ -774,7 +774,7 @@ void scan_dir(std::string const& dir_path
torrent_status const& get_active_torrent(std::vector<torrent_status> const& torrents)
{
if (active_torrent >= torrents.size()
if (active_torrent >= int(torrents.size())
|| active_torrent < 0) active_torrent = 0;
std::vector<torrent_status>::const_iterator i = torrents.begin();
std::advance(i, active_torrent);
@@ -817,7 +817,7 @@ int save_file(std::string const& filename, std::vector<char>& v)
if (ec) return -1;
file::iovec_t b = {&v[0], v.size()};
size_type written = f.writev(0, &b, 1, ec);
if (written != v.size()) return -3;
if (written != int(v.size())) return -3;
if (ec) return -3;
return 0;
}
@@ -1153,7 +1153,12 @@ int main(int argc, char* argv[])
ses.set_proxy(ps);
ses.listen_on(std::make_pair(listen_port, listen_port + 10)
, bind_to_interface.c_str());
, ec, bind_to_interface.c_str());
if (ec)
{
fprintf(stderr, "failed to listen on %s on ports %d-%d: %s\n"
, bind_to_interface.c_str(), listen_port, listen_port+1, ec.message().c_str());
}
#ifndef TORRENT_DISABLE_DHT
if (start_dht)
@@ -1241,7 +1246,7 @@ int main(int argc, char* argv[])
handles.clear();
memset(counters, 0, sizeof(counters));
ses.get_torrent_status(&handles, boost::bind(&show_torrent, _1, torrent_filter, (int*)counters));
if (active_torrent >= handles.size()) active_torrent = handles.size() - 1;
if (active_torrent >= int(handles.size())) active_torrent = handles.size() - 1;
std::sort(handles.begin(), handles.end(), &compare_torrent);
@@ -1272,7 +1277,7 @@ int main(int argc, char* argv[])
handles.clear();
memset(counters, 0, sizeof(counters));
ses.get_torrent_status(&handles, boost::bind(&show_torrent, _1, torrent_filter, (int*)counters));
if (active_torrent >= handles.size()) active_torrent = handles.size() - 1;
if (active_torrent >= int(handles.size())) active_torrent = handles.size() - 1;
std::sort(handles.begin(), handles.end(), &compare_torrent);
}
}
@@ -1285,7 +1290,7 @@ int main(int argc, char* argv[])
handles.clear();
memset(counters, 0, sizeof(counters));
ses.get_torrent_status(&handles, boost::bind(&show_torrent, _1, torrent_filter, (int*)counters));
if (active_torrent >= handles.size()) active_torrent = handles.size() - 1;
if (active_torrent >= int(handles.size())) active_torrent = handles.size() - 1;
std::sort(handles.begin(), handles.end(), &compare_torrent);
}
}
@@ -1299,7 +1304,7 @@ int main(int argc, char* argv[])
{
// arrow down
++active_torrent;
if (active_torrent >= handles.size()) active_torrent = handles.size() - 1;
if (active_torrent >= int(handles.size())) active_torrent = handles.size() - 1;
}
}
@@ -1469,7 +1474,7 @@ int main(int argc, char* argv[])
"[5] toggle peer rate [6] toggle failures [7] toggle send buffers [R] save resume data\n";
char const* filter_names[] = { "all", "downloading", "non-paused", "seeding", "queued", "stopped", "checking"};
for (int i = 0; i < sizeof(filter_names)/sizeof(filter_names[0]); ++i)
for (int i = 0; i < int(sizeof(filter_names)/sizeof(filter_names[0])); ++i)
{
char filter[200];
snprintf(filter, sizeof(filter), "%s[%s (%d)]%s", torrent_filter == i?esc("7"):""

View File

@@ -61,7 +61,7 @@ struct peer_conn
, outstanding_requests(0)
{
// build a list of all pieces and request them all!
for (int i = 0; i < pieces.size(); ++i)
for (int i = 0; i < int(pieces.size()); ++i)
pieces[i] = i;
std::random_shuffle(pieces.begin(), pieces.end());

View File

@@ -49,7 +49,7 @@ int save_file(std::string const& filename, std::vector<char>& v)
if (ec) return -1;
file::iovec_t b = {&v[0], v.size()};
size_type written = f.writev(0, &b, 1, ec);
if (written != v.size()) return -3;
if (written != int(v.size())) return -3;
if (ec) return -3;
return 0;
}

View File

@@ -47,10 +47,15 @@ int main(int argc, char* argv[])
}
session s;
s.listen_on(std::make_pair(6881, 6889));
error_code ec;
s.listen_on(std::make_pair(6881, 6889), ec);
if (ec)
{
fprintf(stderr, "failed to open listen socket: %s\n", ec.message().c_str());
return 1;
}
add_torrent_params p;
p.save_path = "./";
error_code ec;
p.ti = new torrent_info(argv[1], ec);
if (ec)
{