add LGTM badge to README and fix warnings

This commit is contained in:
Arvid Norberg 2018-10-19 14:35:19 +02:00 committed by Arvid Norberg
parent 911e4a892b
commit ede7dbf0aa
19 changed files with 70 additions and 3349 deletions

View File

@ -10,6 +10,9 @@ libtorrent
.. image:: https://doozer.io/badge/arvidn/libtorrent/buildstatus/master
:target: https://doozer.io/user/arvidn/libtorrent
.. image:: https://img.shields.io/lgtm/alerts/g/arvidn/libtorrent.svg?logo=lgtm&logoWidth=18
:target: https://lgtm.com/projects/g/arvidn/libtorrent/alerts/
.. image:: https://codecov.io/github/arvidn/libtorrent/coverage.svg?branch=master
:target: https://codecov.io/github/arvidn/libtorrent?branch=master&view=all#sort=missing&dir=desc

View File

@ -162,7 +162,7 @@ def add_torrent(ses, filename, options):
atp.ti = lt.torrent_info(filename)
try:
atp.resume_data = open(os.path.join(options.save_path, atp.info.name() + '.fastresume'), 'rb').read()
except BaseException:
except Exception:
pass
atp.save_path = options.save_path
@ -303,7 +303,7 @@ def main():
out += progress_bar(p / float(f.size), 20)
out += ' ' + f.path + '\n'
write_line(console, out)
except BaseException:
except Exception:
pass
write_line(console, 76 * '-' + '\n')

View File

@ -55,13 +55,13 @@ def target_specific():
try:
with open('compile_flags') as _file:
extra_cmd = _file.read()
except BaseException:
except Exception:
extra_cmd = None
try:
with open('link_flags') as _file:
ldflags = _file.read()
except BaseException:
except Exception:
ldflags = None
# this is to pull out compiler arguments from the CXX flags set up by the
@ -75,7 +75,7 @@ try:
while len(cmd) > 0 and not cmd[0].startswith('-'):
cmd = cmd[1:]
extra_cmd += ' '.join(cmd)
except BaseException:
except Exception:
pass
ext = None
@ -131,19 +131,19 @@ if '--bjam' in sys.argv:
try:
os.mkdir('build')
except BaseException:
except Exception:
pass
try:
shutil.rmtree('build/lib')
except BaseException:
except Exception:
pass
try:
os.mkdir('build/lib')
except BaseException:
except Exception:
pass
try:
os.mkdir('libtorrent')
except BaseException:
except Exception:
pass
shutil.copyfile('libtorrent' + file_ext,
'build/lib/libtorrent' + file_ext)

View File

@ -30,7 +30,8 @@ POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef TORRENT_ALLOCA
#ifndef TORRENT_ALLOCA_HPP_INCLUDED
#define TORRENT_ALLOCA_HPP_INCLUDED
#include "libtorrent/config.hpp"
#include "libtorrent/aux_/typed_span.hpp"
@ -108,4 +109,4 @@ struct alloca_destructor
#endif
#endif
#endif // TORRENT_ALLOCA_HPP_INCLUDED

View File

@ -30,6 +30,9 @@ POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef TORRENT_CHOKER_HPP_INCLUDED
#define TORRENT_CHOKER_HPP_INCLUDED
#include "libtorrent/config.hpp"
#include "libtorrent/time.hpp" // for time_duration
#include <vector>
@ -50,3 +53,5 @@ namespace libtorrent {
, aux::session_settings const& sett);
}
#endif // TORRENT_CHOKER_INCLUDED

View File

@ -30,11 +30,11 @@ POSSIBILITY OF SUCH DAMAGE.
*/
#if !defined TORRENT_DISABLE_ENCRYPTION
#ifndef TORRENT_PE_CRYPTO_HPP_INCLUDED
#define TORRENT_PE_CRYPTO_HPP_INCLUDED
#if !defined TORRENT_DISABLE_ENCRYPTION
#include "libtorrent/config.hpp"
#include "libtorrent/aux_/disable_warnings_push.hpp"
@ -157,5 +157,6 @@ namespace libtorrent {
} // namespace libtorrent
#endif // TORRENT_PE_CRYPTO_HPP_INCLUDED
#endif // TORRENT_DISABLE_ENCRYPTION
#endif // TORRENT_PE_CRYPTO_HPP_INCLUDED

View File

@ -30,6 +30,9 @@ POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef TORRENT_RANDOM_HPP_INCLUDED
#define TORRENT_RANDOM_HPP_INCLUDED
#include "libtorrent/config.hpp"
#include "libtorrent/span.hpp"
@ -59,3 +62,5 @@ namespace libtorrent { namespace aux {
TORRENT_EXTRA_EXPORT std::uint32_t random(std::uint32_t m);
}
#endif // TORRENT_RANDOM_HPP_INCLUDED

View File

@ -1016,22 +1016,19 @@ namespace {
received_bytes(0, received);
return;
}
if (recv_pos >= 13)
char const* ptr = recv_buffer.begin() + 9;
int const list_size = detail::read_int32(ptr);
if (list_size > m_recv_buffer.packet_size() - 13)
{
char const* ptr = recv_buffer.begin() + 9;
int const list_size = detail::read_int32(ptr);
disconnect(errors::invalid_hash_list, operation_t::bittorrent, peer_error);
return;
}
if (list_size > m_recv_buffer.packet_size() - 13)
{
disconnect(errors::invalid_hash_list, operation_t::bittorrent, peer_error);
return;
}
if (m_recv_buffer.packet_size() - 13 - list_size > t->block_size())
{
disconnect(errors::packet_too_large, operation_t::bittorrent, peer_error);
return;
}
if (m_recv_buffer.packet_size() - 13 - list_size > t->block_size())
{
disconnect(errors::packet_too_large, operation_t::bittorrent, peer_error);
return;
}
}
else

View File

@ -82,10 +82,10 @@ namespace libtorrent {
// is greater than the send quanta, and it has been unchoked for at least one minute
// then it's done with its upload slot, and we can de-prioritize it
bool const c1_quota_complete = !lhs->is_choked()
&& u1 > t1->torrent_file().piece_length() * pieces
&& u1 > std::int64_t(t1->torrent_file().piece_length()) * pieces
&& aux::time_now() - lhs->time_of_last_unchoke() > minutes(1);
bool const c2_quota_complete = !rhs->is_choked()
&& u2 > t2->torrent_file().piece_length() * pieces
&& u2 > std::int64_t(t2->torrent_file().piece_length()) * pieces
&& aux::time_now() - rhs->time_of_last_unchoke() > minutes(1);
// if c2 has completed a quanta, it should be de-prioritized

View File

@ -257,7 +257,7 @@ void lsd::on_announce(udp::endpoint const& from, span<char const> buf)
sha1_hash ih;
aux::from_hex(ih_str, ih.data());
if (!ih.is_all_zeros() && port != 0)
if (!ih.is_all_zeros())
{
#ifndef TORRENT_DISABLE_LOGGING
if (should_log())

View File

@ -960,7 +960,7 @@ bool is_downloading_state(int const st)
if (mask & torrent_flags::paused)
{
if (flags & torrent_flags::paused)
graceful_pause();
pause(torrent_handle::graceful_pause);
else
resume();
}

View File

@ -18,7 +18,7 @@ def clean():
'build-aux',
'.deps',
'test_tmp_*',
'bjam_build.*.xml'
'bjam_build.*.xml',
'*.exe',
'*.pdb',
'*.pyd',

File diff suppressed because it is too large Load Diff

View File

@ -81,7 +81,7 @@ for line in f:
client_histogram[v[0:2]] = 1
else:
client_histogram[v[0:2]] += 1
except BaseException:
except Exception:
pass
if 'announce-distance:' in line:
@ -153,7 +153,7 @@ for line in f:
start_time = convert_timestamp(s[0]['t'])
for i in range(len(s)):
s[i]['t'] = convert_timestamp(s[i]['t']) - start_time
except BaseException:
except Exception:
pass
searches.append(s)
del outstanding_searches[search_id]

View File

@ -64,7 +64,7 @@ def plot_nodes(nodes, frame):
if nodes[dst]['c'] != 'white' and nodes[e]['c'] != 'white':
style = 'solid'
col = 'black'
print('"%s" -- "%s" [style="%s" color="%s"];' % (e, dst, style, col), file=out)
print('"%s" -- "%s" [style="%s" color="%s"];' % (e, dst, style, col), file=out)
print('}', file=out)
out.close()

View File

@ -27,7 +27,7 @@ fold = -1
try:
sample_limit = int(sys.argv[2])
except BaseException:
except Exception:
sample_limit = 5
fun_samples = {}

View File

@ -54,7 +54,7 @@ keys = line.split('session stats header:')[1].strip().split(', ')
try:
os.mkdir(output_dir)
except BaseException:
except Exception:
pass
data_out = open(os.path.join(output_dir, 'counters.dat'), 'w+')
@ -91,8 +91,8 @@ for i in range(0, len(pattern) * 3):
op = i / len(pattern)
c = list(pattern[i % len(pattern)])
for i in range(3):
c[i] *= 0xff
for j in range(3):
c[j] *= 0xff
c = process_color(c, op)
c = '#%02x%02x%02x' % (c[0], c[1], c[2])
@ -156,7 +156,7 @@ def gen_report(name, unit, lines, short_unit, generation, log_file, options):
sys.stdout.write('.')
return None
except BaseException:
except Exception:
pass
script = os.path.join(output_dir, '%s_%04d.gnuplot' % (name, generation))
@ -180,7 +180,7 @@ def gen_report(name, unit, lines, short_unit, generation, log_file, options):
colors = gradient6_colors
if options['colors'] == 'gradient18':
colors = gradient18_colors
except BaseException:
except Exception:
pass
if options['type'] == histogram:
@ -197,7 +197,7 @@ def gen_report(name, unit, lines, short_unit, generation, log_file, options):
k = lines[0]
try:
column = keys.index(k) + 2
except BaseException:
except Exception:
print('"%s" not found' % k)
return
print('plot "%s" using (bin($%d,binwidth)):(1.0) smooth freq with boxes' % (log_file, column), file=out)
@ -212,7 +212,6 @@ def gen_report(name, unit, lines, short_unit, generation, log_file, options):
print('set format y "%%.1s%%c%s";' % short_unit, file=out)
print('set style fill solid 1.0 noborder', file=out)
print('plot', end=' ', file=out)
column = 2
first = True
graph = ''
plot_expression = ''
@ -220,7 +219,7 @@ def gen_report(name, unit, lines, short_unit, generation, log_file, options):
for k in lines:
try:
column = keys.index(k) + 2
except BaseException:
except Exception:
print('"%s" not found' % k)
continue
if not first:
@ -238,14 +237,13 @@ def gen_report(name, unit, lines, short_unit, generation, log_file, options):
print('set ylabel "%s"' % unit, file=out)
print('set xlabel "time (s)"', file=out)
print('set format y "%%.1s%%c%s";' % short_unit, file=out)
column = 2
first = True
graph = ''
title = ''
for k in lines:
try:
column = keys.index(k) + 2
except BaseException:
except Exception:
print('"%s" not found' % k)
continue
if not first:
@ -261,13 +259,12 @@ def gen_report(name, unit, lines, short_unit, generation, log_file, options):
print('set xlabel "time (s)"', file=out)
print('set format y "%%.1s%%c%s";' % short_unit, file=out)
print('plot', end=' ', file=out)
column = 2
first = True
color = 0
for k in lines:
try:
column = keys.index(k) + 2
except BaseException:
except Exception:
print('"%s" not found' % k)
continue
if not first:
@ -643,7 +640,7 @@ print('[%s] %04d\r[' % (' ' * len(reports), g), end='')
for i in reports:
try:
options = i[5]
except BaseException:
except Exception:
options = {}
if 'type' not in options:
options['type'] = line_graph

View File

@ -27,7 +27,7 @@ if socket_filter is None:
try:
a = l.strip().split(" ")
socket_index = a[1][:-1]
except BaseException:
except Exception:
continue
# msvc's runtime library doesn't prefix pointers
@ -127,7 +127,7 @@ for line in file:
a = line.strip().split(" ")
t = a[0][1:-1]
socket_index = a[1][:-1]
except BaseException:
except Exception:
continue
# if socket_index[:2] != '0x':
# continue
@ -179,7 +179,7 @@ for line in file:
for i in a[2:]:
try:
n, v = i.split(':')
except BaseException:
except Exception:
continue
v = float(v)
if n == "our_delay":

View File

@ -44,7 +44,7 @@ if not os.path.exists('cpu_benchmark.torrent'):
try:
shutil.rmtree('t')
except BaseException:
except Exception:
pass
@ -53,22 +53,22 @@ def run_test(name, test_cmd, client_arg, num_peers):
try:
shutil.rmtree(output_dir)
except BaseException:
except Exception:
pass
try:
os.mkdir(output_dir)
except BaseException:
except Exception:
pass
port = (int(time.time()) % 50000) + 2000
try:
shutil.rmtree('session_stats')
except BaseException:
except Exception:
pass
try:
shutil.rmtree('session_stats_report')
except BaseException:
except Exception:
pass
start = time.time()
@ -92,7 +92,7 @@ def run_test(name, test_cmd, client_arg, num_peers):
try:
c.communicate('q')
except BaseException:
except Exception:
pass
c.wait()
@ -108,11 +108,11 @@ def run_test(name, test_cmd, client_arg, num_peers):
os.system('python parse_session_stats.py session_stats/*.log')
try:
shutil.move('session_stats_report', '%s/session_stats_report' % output_dir)
except BaseException:
except Exception:
pass
try:
shutil.move('session_stats', '%s/session_stats' % output_dir)
except BaseException:
except Exception:
pass