Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix and suppress some new clang warnings util addressed (in master) #7609

Merged
merged 1 commit into from
Feb 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ jobs:
- name: install boost
run: |
sudo apt install libboost-tools-dev libboost-dev
echo "using clang_tidy : : clang-tidy \"-checks=-clang-analyzer-core.*,-clang-analyzer-unix.*\" : <cxxflags>-std=c++14 <cxxflags>-I/usr/local/clang-7.0.0/include/c++/v1 <cxxflags>-stdlib=libc++ <linkflags>-stdlib=libc++ ;" >> ~/user-config.jam;
echo "using clang_tidy : : clang-tidy \"-checks=-clang-analyzer-core.*,-clang-analyzer-unix.*\" : <cxxflags>-std=c++14 <cxxflags>-I/usr/local/clang-7.0.0/include/c++/v1 <cxxflags>-stdlib=libc++ <cxxflags>-Wno-unknown-warning-option <linkflags>-stdlib=libc++ ;" >> ~/user-config.jam;

- name: analyze
run: |
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES Clang)
-Wno-exit-time-destructors
-Wno-weak-vtables
-Wno-return-std-move-in-c++11
-Wno-unsafe-buffer-usage
-Wno-unknown-warning-option
)
elseif(CMAKE_CXX_COMPILER_ID MATCHES GNU)
Expand Down
4 changes: 4 additions & 0 deletions Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,10 @@ rule warnings ( properties * )

# libtorrent uses alloca() carefully
result += <cxxflags>-Wno-alloca ;

# these warnings should all be addressed. Either by transitioning to span and
# array, or by suppressing the warning for specific code
result += <cxxflags>-Wno-unsafe-buffer-usage ;
}

if <toolset>gcc in $(properties)
Expand Down
2 changes: 1 addition & 1 deletion include/libtorrent/flags.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ struct bit_t
int m_bit_idx;
};

constexpr bit_t operator "" _bit(unsigned long long int b) { return bit_t{static_cast<int>(b)}; }
constexpr bit_t operator ""_bit(unsigned long long int b) { return bit_t{static_cast<int>(b)}; }

namespace flags {

Expand Down
16 changes: 8 additions & 8 deletions src/ip_notifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ struct ip_change_notifier_impl final : ip_change_notifier

void async_wait(std::function<void(error_code const&)> cb) override
{
post(m_ios, [cb]()
{ cb(make_error_code(boost::system::errc::not_supported)); });
post(m_ios, [cb1=std::move(cb)]()
{ cb1(make_error_code(boost::system::errc::not_supported)); });
}

void cancel() override {}
Expand Down Expand Up @@ -153,10 +153,10 @@ struct ip_change_notifier_impl final : ip_change_notifier
void async_wait(std::function<void(error_code const&)> cb) override
{
m_socket.async_receive(boost::asio::buffer(m_buf)
, [cb=std::move(cb), this] (error_code const& ec, std::size_t const bytes_transferred)
, [cb1=std::move(cb), this] (error_code const& ec, std::size_t const bytes_transferred)
{
if (ec) cb(ec);
else this->on_notify(int(bytes_transferred), std::move(cb));
if (ec) cb1(ec);
else this->on_notify(int(bytes_transferred), std::move(cb1));
});
}

Expand Down Expand Up @@ -216,10 +216,10 @@ struct ip_change_notifier_impl final : ip_change_notifier
if (!pertinent)
{
m_socket.async_receive(boost::asio::buffer(m_buf)
, [cb=std::move(cb), this] (error_code const& ec, std::size_t const bytes_transferred)
, [cb1=std::move(cb), this] (error_code const& ec, std::size_t const bytes_transferred)
{
if (ec) cb(ec);
else this->on_notify(int(bytes_transferred), std::move(cb));
if (ec) cb1(ec);
else this->on_notify(int(bytes_transferred), std::move(cb1));
});
}
else
Expand Down
2 changes: 2 additions & 0 deletions src/ssl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ void set_server_name_callback(context_handle_type c, server_name_callback_type c
#if defined __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wold-style-cast"
#pragma clang diagnostic ignored "-Wcast-function-type-strict"
#pragma clang diagnostic ignored "-Wunknown-warning-option"
#endif
SSL_CTX_set_tlsext_servername_callback(c, cb);
SSL_CTX_set_tlsext_servername_arg(c, arg);
Expand Down
11 changes: 4 additions & 7 deletions src/torrent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2440,9 +2440,9 @@ bool is_downloading_state(int const st)

span<sha256_hash> v2_span(hashes);
m_ses.disk_thread().async_hash(m_storage, m_checking_piece, v2_span, flags
, [self = shared_from_this(), hashes = std::move(hashes)]
, [self = shared_from_this(), hashes1 = std::move(hashes)]
(piece_index_t p, sha1_hash const& h, storage_error const& error) mutable
{ self->on_piece_hashed(std::move(hashes), p, h, error); });
{ self->on_piece_hashed(std::move(hashes1), p, h, error); });
++m_checking_piece;
if (m_checking_piece >= m_torrent_file->end_piece()) break;
}
Expand Down Expand Up @@ -10366,7 +10366,6 @@ namespace {
int num_peers = 0;
int num_downloaders = 0;
int missing_pieces = 0;
int num_interested = 0;
for (auto const p : m_connections)
{
TORRENT_INCREMENT(m_iterating_connections);
Expand All @@ -10382,8 +10381,6 @@ namespace {
if (p->share_mode()) continue;
if (p->upload_only()) continue;

if (p->is_peer_interested()) ++num_interested;

++num_downloaders;
missing_pieces += pieces_in_torrent - p->num_have_pieces();
}
Expand Down Expand Up @@ -11335,9 +11332,9 @@ namespace {

span<sha256_hash> v2_span(hashes);
m_ses.disk_thread().async_hash(m_storage, piece, v2_span, flags
, [self = shared_from_this(), hashes = std::move(hashes)]
, [self = shared_from_this(), hashes1 = std::move(hashes)]
(piece_index_t p, sha1_hash const& h, storage_error const& error) mutable
{ self->on_piece_verified(std::move(hashes), p, h, error); });
{ self->on_piece_verified(std::move(hashes1), p, h, error); });
m_picker->started_hash_job(piece);
m_ses.deferred_submit_jobs();
}
Expand Down
2 changes: 1 addition & 1 deletion test/test_http_connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ TORRENT_TEST(socks5_pw_proxy_ssl) { run_suite("https", settings_pack::socks5_pw)
#endif // USE_SSL

TORRENT_TEST(http_proxy) { run_suite("http", settings_pack::http); }
TORRENT_TEST(http__pwproxy) { run_suite("http", settings_pack::http_pw); }
TORRENT_TEST(http_pwproxy) { run_suite("http", settings_pack::http_pw); }
TORRENT_TEST(socks5_proxy) { run_suite("http", settings_pack::socks5); }
TORRENT_TEST(socks5_pw_proxy) { run_suite("http", settings_pack::socks5_pw); }

Expand Down
Loading