fix cppcheck (#887)

fix cppcheck
This commit is contained in:
Arvid Norberg 2016-07-05 08:42:11 -04:00 committed by GitHub
parent 3ec48ec5b4
commit c299149dc0
6 changed files with 16 additions and 13 deletions

View File

@ -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;

View File

@ -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

View File

@ -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)

View File

@ -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);

View File

@ -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;

View File

@ -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());