diff --git a/.travis.yml b/.travis.yml index f1887ef38..3672d2ed7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -172,19 +172,24 @@ script: - 'if [[ "$analyze" == "1" ]]; then cppcheck --version && find src test examples tools -type f | grep ".*\.cpp$" >cppcheck.files && - find simulation -type f -depth -2 | grep ".*\.cpp$" >>cppcheck.files && + find simulation -maxdepth 1 -type f | grep ".*\.cpp$" >>cppcheck.files && cppcheck -DTORRENT_USE_IPV6="1" -DTORRENT_USE_I2P="1" -DTORRENT_USE_OPENSSL="1" -DTORRENT_USE_INVARIANT_CHECKS="1" -DTORRENT_EXPENSIVE_INVARIANT_CHECKS="1" -DTORRENT_USE_ASSERTS="1" -UTORRENT_DISABLE_MUTABLE_TORRENTS -UTORRENT_DISABLE_LOGGING -UTORRENT_DEBUG_BUFFERS -UTORRENT_EXPORT_EXTRA --suppress=preprocessorErrorDirective + --suppress=uninitVar + --suppress=arrayIndexOutOfBounds + --suppress=unusedStructMember + --suppress=operatorEqVarError --suppress=noConstructor --suppress=syntaxError --enable=style --template "{file}({line}): {severity} ({id}): {message}" --inline-suppr --force --std=c++11 -j2 -I include -I /usr/local/include - --file-list=cppcheck.files 2> cppcheck.txt; + -I test -I simulation/libsimulator/include + --file-list=cppcheck.files 2> cppcheck.txt && if [ -s cppcheck.txt ]; then echo " ======= CPPCHECK ERRORS ====="; cat cppcheck.txt; diff --git a/include/libtorrent/broadcast_socket.hpp b/include/libtorrent/broadcast_socket.hpp index 72ca96447..f3713dbd1 100644 --- a/include/libtorrent/broadcast_socket.hpp +++ b/include/libtorrent/broadcast_socket.hpp @@ -73,7 +73,7 @@ namespace libtorrent void open(receive_handler_t const& handler, io_service& ios , error_code& ec, bool loopback = true); - enum flags_t { broadcast = 1 }; + enum flags_t { flag_broadcast = 1 }; void send(char const* buffer, int size, error_code& ec, int flags = 0); void close(); @@ -117,7 +117,7 @@ namespace libtorrent #endif } }; - + void on_receive(socket_entry* s, error_code const& ec , std::size_t bytes_transferred); void open_unicast_socket(io_service& ios, address const& addr diff --git a/simulation/test_thread_pool.cpp b/simulation/test_thread_pool.cpp index 38d88da3a..58168b781 100644 --- a/simulation/test_thread_pool.cpp +++ b/simulation/test_thread_pool.cpp @@ -39,9 +39,7 @@ namespace lt = libtorrent; struct test_threads : lt::pool_thread_interface { - test_threads() - : m_active_threads(0) - {} + test_threads() {} virtual void notify_all() override { m_cond.notify_all(); } virtual void thread_fun(lt::io_service::work w) override @@ -106,9 +104,9 @@ struct test_threads : lt::pool_thread_interface std::condition_variable m_exit_cond; // must hold m_mutex to access - int m_active_threads; + int m_active_threads = 0; // must hold m_mutex to access - int m_target_active_threads; + int m_target_active_threads = 0; }; TORRENT_TEST(disk_io_thread_pool_idle_reaping) diff --git a/src/broadcast_socket.cpp b/src/broadcast_socket.cpp index 226e64509..0dc5d63bd 100644 --- a/src/broadcast_socket.cpp +++ b/src/broadcast_socket.cpp @@ -276,7 +276,7 @@ namespace libtorrent // if the user specified the broadcast flag, send one to the broadcast // address as well - if ((flags & broadcast_socket::broadcast) && i->can_broadcast()) + if ((flags & broadcast_socket::flag_broadcast) && i->can_broadcast()) i->socket->send_to(boost::asio::buffer(buffer, size) , udp::endpoint(i->broadcast_address(), m_multicast_endpoint.port()), 0, e); diff --git a/src/lsd.cpp b/src/lsd.cpp index 9388b3c48..18fa0d1f2 100644 --- a/src/lsd.cpp +++ b/src/lsd.cpp @@ -154,7 +154,7 @@ void lsd::announce_impl(sha1_hash const& ih, int listen_port, bool broadcast { int msg_len = render_lsd_packet(msg, sizeof(msg), listen_port, ih_hex , m_cookie, "239.192.152.143"); - m_socket.send(msg, msg_len, ec, broadcast ? broadcast_socket::broadcast : 0); + m_socket.send(msg, msg_len, ec, broadcast ? broadcast_socket::flag_broadcast : 0); if (ec) { m_disabled = true; @@ -170,7 +170,7 @@ void lsd::announce_impl(sha1_hash const& ih, int listen_port, bool broadcast { int msg_len = render_lsd_packet(msg, sizeof(msg), listen_port, ih_hex , m_cookie, "[ff15::efc0:988f]"); - m_socket6.send(msg, msg_len, ec, broadcast ? broadcast_socket::broadcast : 0); + m_socket6.send(msg, msg_len, ec, broadcast ? broadcast_socket::flag_broadcast : 0); if (ec) { m_disabled6 = true; diff --git a/tools/fuzz_torrent.cpp b/tools/fuzz_torrent.cpp index 3390e2ca3..cc4ce85b3 100644 --- a/tools/fuzz_torrent.cpp +++ b/tools/fuzz_torrent.cpp @@ -373,7 +373,7 @@ int main(int argc, char const* argv[]) } bdecode_node e; - if (buf.size() == 0 || bdecode(&buf[0], &buf[0] + buf.size(), e, ec) != 0) + if (buf.empty() || bdecode(&buf[0], &buf[0] + buf.size(), e, ec) != 0) { std::fprintf(stderr, "ERROR parsing file: %s\n%s\n" , *argv, ec.message().c_str());