diff options
author | Christopher Wiley <wiley@google.com> | 2016-01-04 18:15:05 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-01-04 18:15:05 +0000 |
commit | 5493d1ee1bbff0ce1b848ff52a6669f031caff24 (patch) | |
tree | ea8b5c0f5114a86f0bfa53cc00deb292bee5772d | |
parent | f4e4c2d6048f6fff504f0ee208abc195f83290cf (diff) | |
parent | 2fd46ba1458275cd16b0949675bff70cc8abcdad (diff) | |
download | platform_external_libbrillo-5493d1ee1bbff0ce1b848ff52a6669f031caff24.tar.gz platform_external_libbrillo-5493d1ee1bbff0ce1b848ff52a6669f031caff24.tar.bz2 platform_external_libbrillo-5493d1ee1bbff0ce1b848ff52a6669f031caff24.zip |
Fix compiler warnings in libbrillo
am: 2fd46ba145
* commit '2fd46ba1458275cd16b0949675bff70cc8abcdad':
Fix compiler warnings in libbrillo
35 files changed, 126 insertions, 110 deletions
@@ -140,12 +140,11 @@ libbrillo_dbus_test_sources := \ brillo/dbus/test.proto \ brillo/variant_dictionary_unittest.cc \ -libbrillo_CFLAGS := -Wall \ - -Wno-char-subscripts -Wno-missing-field-initializers \ - -Wno-unused-function -Wno-unused-parameter -Werror \ +libbrillo_CFLAGS := \ + -Wall \ + -Werror \ -DUSE_DBUS=$(BRILLO_USE_DBUS) -libbrillo_CPPFLAGS := -Wno-non-virtual-dtor -Wno-sign-promo \ - -Wno-strict-aliasing +libbrillo_CPPFLAGS := libbrillo_includes := external/gtest/include libbrillo_shared_libraries := libchrome diff --git a/brillo/any_internal_impl.h b/brillo/any_internal_impl.h index 29126a1..d4fa39e 100644 --- a/brillo/any_internal_impl.h +++ b/brillo/any_internal_impl.h @@ -40,7 +40,7 @@ TryConvert(const From& in, To* out) { } template <typename From, typename To> inline typename std::enable_if<!IsConvertible<From, To>::value, bool>::type -TryConvert(const From& in, To* out) { +TryConvert(const From& /* in */, To* /* out */) { return false; } @@ -69,7 +69,7 @@ struct IsEqualityComparableHelper { // IntWrapper when both overloads are provided. // Also this constructor must NOT be explicit. // NOLINTNEXTLINE(runtime/explicit) - IntWrapper(int dummy) {} // do nothing + IntWrapper(int /* dummy */) {} // do nothing }; // Here is an obscure trick to determine if a type U has operator==(). @@ -124,7 +124,7 @@ struct IsEqualityComparable : IsEqualityComparableHelper<T>::type {}; // EqCompare() overload for non-comparable types. Always returns false. template<typename T> inline typename std::enable_if<!IsEqualityComparable<T>::value, bool>::type -EqCompare(const T& v1, const T& v2) { +EqCompare(const T& /* v1 */, const T& /* v2 */) { return false; } @@ -186,7 +186,7 @@ struct TypedData : public Data { } template<typename U> static typename std::enable_if<!dbus_utils::IsTypeSupported<U>::value>::type - AppendValueHelper(dbus::MessageWriter* writer, const U& value) { + AppendValueHelper(dbus::MessageWriter* /* writer */, const U& /* value */) { LOG(FATAL) << "Type '" << GetUndecoratedTypeName<U>() << "' is not supported by D-Bus"; } diff --git a/brillo/binder_watcher.cc b/brillo/binder_watcher.cc index 53494bb..32ab101 100644 --- a/brillo/binder_watcher.cc +++ b/brillo/binder_watcher.cc @@ -47,7 +47,7 @@ bool BinderWatcher::Init() { return true; } -void BinderWatcher::OnFileCanReadWithoutBlocking(int fd) { +void BinderWatcher::OnFileCanReadWithoutBlocking(int /* fd */) { IPCThreadState::self()->handlePolledCommands(); } diff --git a/brillo/daemons/daemon.cc b/brillo/daemons/daemon.cc index 11700f1..6eab901 100644 --- a/brillo/daemons/daemon.cc +++ b/brillo/daemons/daemon.cc @@ -68,7 +68,7 @@ int Daemon::OnInit() { return EX_OK; } -void Daemon::OnShutdown(int* exit_code) { +void Daemon::OnShutdown(int* /* exit_code */) { // Do nothing. } @@ -77,12 +77,12 @@ bool Daemon::OnRestart() { return false; // Returning false will shut down the daemon instead. } -bool Daemon::Shutdown(const signalfd_siginfo& info) { +bool Daemon::Shutdown(const signalfd_siginfo& /* info */) { Quit(); return true; // Unregister the signal handler. } -bool Daemon::Restart(const signalfd_siginfo& info) { +bool Daemon::Restart(const signalfd_siginfo& /* info */) { if (OnRestart()) return false; // Keep listening to the signal. Quit(); diff --git a/brillo/daemons/dbus_daemon.cc b/brillo/daemons/dbus_daemon.cc index ebbfd94..6e90686 100644 --- a/brillo/daemons/dbus_daemon.cc +++ b/brillo/daemons/dbus_daemon.cc @@ -74,7 +74,7 @@ int DBusServiceDaemon::OnInit() { } void DBusServiceDaemon::RegisterDBusObjectsAsync( - dbus_utils::AsyncEventSequencer* sequencer) { + dbus_utils::AsyncEventSequencer* /* sequencer */) { // Do nothing here. // Overload this method to export custom D-Bus objects at daemon startup. } diff --git a/brillo/dbus/async_event_sequencer.cc b/brillo/dbus/async_event_sequencer.cc index 862aa30..8861e21 100644 --- a/brillo/dbus/async_event_sequencer.cc +++ b/brillo/dbus/async_event_sequencer.cc @@ -53,7 +53,7 @@ void IgnoreSuccess(const AsyncEventSequencer::CompletionTask& task, bool /*success*/) { task.Run(); } -void DoNothing(bool success) { +void DoNothing(bool /* success */) { } } // namespace diff --git a/brillo/dbus/data_serialization.h b/brillo/dbus/data_serialization.h index 3a3027e..46da165 100644 --- a/brillo/dbus/data_serialization.h +++ b/brillo/dbus/data_serialization.h @@ -647,8 +647,10 @@ struct TupleIterator { template<size_t N, typename... T> struct TupleIterator<N, N, T...> { using Tuple = std::tuple<T...>; - static void Write(dbus::MessageWriter* writer, const Tuple& value) {} - static bool Read(dbus::MessageReader* reader, Tuple* value) { return true; } + static void Write(dbus::MessageWriter* /* writer */, + const Tuple& /* value */) {} + static bool Read(dbus::MessageReader* /* reader */, + Tuple* /* value */) { return true; } }; } // namespace details diff --git a/brillo/dbus/dbus_method_invoker_unittest.cc b/brillo/dbus/dbus_method_invoker_unittest.cc index f79b06b..9207932 100644 --- a/brillo/dbus/dbus_method_invoker_unittest.cc +++ b/brillo/dbus/dbus_method_invoker_unittest.cc @@ -60,7 +60,7 @@ class DBusMethodInvokerTest : public testing::Test { void TearDown() override { bus_ = nullptr; } Response* CreateResponse(dbus::MethodCall* method_call, - int timeout_ms, + int /* timeout_ms */, dbus::ScopedDBusError* dbus_error) { if (method_call->GetInterface() == kTestInterface) { if (method_call->GetMember() == kTestMethod1) { @@ -217,7 +217,7 @@ class AsyncDBusMethodInvokerTest : public testing::Test { void TearDown() override { bus_ = nullptr; } void HandleCall(dbus::MethodCall* method_call, - int timeout_ms, + int /* timeout_ms */, dbus::ObjectProxy::ResponseCallback success_callback, dbus::ObjectProxy::ErrorCallback error_callback) { if (method_call->GetInterface() == kTestInterface) { diff --git a/brillo/dbus/dbus_object.cc b/brillo/dbus/dbus_object.cc index 7b5834d..d4e982a 100644 --- a/brillo/dbus/dbus_object.cc +++ b/brillo/dbus/dbus_object.cc @@ -31,7 +31,7 @@ void DBusInterface::AddProperty(const std::string& property_name, void DBusInterface::ExportAsync( ExportedObjectManager* object_manager, - dbus::Bus* bus, + dbus::Bus* /* bus */, dbus::ExportedObject* exported_object, const dbus::ObjectPath& object_path, const AsyncEventSequencer::CompletionAction& completion_callback) { @@ -67,7 +67,7 @@ void DBusInterface::ExportAsync( void DBusInterface::ExportAndBlock( ExportedObjectManager* object_manager, - dbus::Bus* bus, + dbus::Bus* /* bus */, dbus::ExportedObject* exported_object, const dbus::ObjectPath& object_path) { VLOG(1) << "Registering D-Bus interface '" << interface_name_ << "' for '" diff --git a/brillo/dbus/dbus_object_unittest.cc b/brillo/dbus/dbus_object_unittest.cc index f833530..eaec3d8 100644 --- a/brillo/dbus/dbus_object_unittest.cc +++ b/brillo/dbus/dbus_object_unittest.cc @@ -76,7 +76,7 @@ bool CheckNonEmpty(ErrorPtr* error, const std::string& str) { void NoOp() {} -bool TestWithMessage(ErrorPtr* error, +bool TestWithMessage(ErrorPtr* /* error */, dbus::Message* message, std::string* str) { *str = message->GetSender(); diff --git a/brillo/dbus/dbus_param_writer.h b/brillo/dbus/dbus_param_writer.h index 737e425..7c7f45e 100644 --- a/brillo/dbus/dbus_param_writer.h +++ b/brillo/dbus/dbus_param_writer.h @@ -45,7 +45,7 @@ class DBusParamWriter final { // Handles non-pointer parameter by just skipping over it. template<typename ParamType, typename... RestOfParams> static void AppendDBusOutParams(dbus::MessageWriter* writer, - const ParamType& param, + const ParamType& /* param */, const RestOfParams&... rest) { // Skip the current |param| and call Append() with one fewer arguments, // until none is left and stand-alone version of diff --git a/brillo/flag_helper.cc b/brillo/flag_helper.cc index 337e8da..bb51818 100644 --- a/brillo/flag_helper.cc +++ b/brillo/flag_helper.cc @@ -32,7 +32,7 @@ class HelpFlag : public brillo::Flag { public: HelpFlag() : Flag("help", "false", "Show this help message", true) {} - bool SetValue(const std::string& value) override { return true; }; + bool SetValue(const std::string& /* value */) override { return true; }; const char* GetType() const override { return "bool"; } }; diff --git a/brillo/http/http_connection_curl.cc b/brillo/http/http_connection_curl.cc index 4b8e96d..3720330 100644 --- a/brillo/http/http_connection_curl.cc +++ b/brillo/http/http_connection_curl.cc @@ -15,11 +15,11 @@ namespace brillo { namespace http { namespace curl { -static int curl_trace(CURL* handle, +static int curl_trace(CURL* /* handle */, curl_infotype type, char* data, size_t size, - void* userp) { + void* /* userp */) { std::string msg(data, size); switch (type) { @@ -72,12 +72,13 @@ Connection::~Connection() { } bool Connection::SendHeaders(const HeaderList& headers, - brillo::ErrorPtr* error) { + brillo::ErrorPtr* /* error */) { headers_.insert(headers.begin(), headers.end()); return true; } -bool Connection::SetRequestData(StreamPtr stream, brillo::ErrorPtr* error) { +bool Connection::SetRequestData(StreamPtr stream, + brillo::ErrorPtr* /* error */) { request_data_stream_ = std::move(stream); return true; } diff --git a/brillo/http/http_connection_fake.cc b/brillo/http/http_connection_fake.cc index dfb40a3..36506fe 100644 --- a/brillo/http/http_connection_fake.cc +++ b/brillo/http/http_connection_fake.cc @@ -27,17 +27,18 @@ Connection::~Connection() { } bool Connection::SendHeaders(const HeaderList& headers, - brillo::ErrorPtr* error) { + brillo::ErrorPtr* /* error */) { request_.AddHeaders(headers); return true; } -bool Connection::SetRequestData(StreamPtr stream, brillo::ErrorPtr* error) { +bool Connection::SetRequestData(StreamPtr stream, + brillo::ErrorPtr* /* error */) { request_.SetData(std::move(stream)); return true; } -bool Connection::FinishRequest(brillo::ErrorPtr* error) { +bool Connection::FinishRequest(brillo::ErrorPtr* /* error */) { using brillo::string_utils::ToString; request_.AddHeaders( {{request_header::kContentLength, ToString(request_.GetData().size())}}); diff --git a/brillo/http/http_connection_fake.h b/brillo/http/http_connection_fake.h index f880b25..a6ebeee 100644 --- a/brillo/http/http_connection_fake.h +++ b/brillo/http/http_connection_fake.h @@ -29,7 +29,7 @@ class Connection : public http::Connection { // See http_connection.h for description of these methods. bool SendHeaders(const HeaderList& headers, brillo::ErrorPtr* error) override; bool SetRequestData(StreamPtr stream, brillo::ErrorPtr* error) override; - void SetResponseData(StreamPtr stream) override {} + void SetResponseData(StreamPtr /* stream */) override {} bool FinishRequest(brillo::ErrorPtr* error) override; RequestID FinishRequestAsync(const SuccessCallback& success_callback, const ErrorCallback& error_callback) override; diff --git a/brillo/http/http_transport_curl.cc b/brillo/http/http_transport_curl.cc index e2f314a..f7e3b71 100644 --- a/brillo/http/http_transport_curl.cc +++ b/brillo/http/http_transport_curl.cc @@ -388,7 +388,7 @@ int Transport::MultiSocketCallback(CURL* easy, } // CURL actually uses "long" types in callback signatures, so we must comply. -int Transport::MultiTimerCallback(CURLM* multi, +int Transport::MultiTimerCallback(CURLM* /* multi */, long timeout_ms, // NOLINT(runtime/int) void* userp) { auto transport = static_cast<Transport*>(userp); diff --git a/brillo/http/http_transport_curl_unittest.cc b/brillo/http/http_transport_curl_unittest.cc index 131c066..148346c 100644 --- a/brillo/http/http_transport_curl_unittest.cc +++ b/brillo/http/http_transport_curl_unittest.cc @@ -206,12 +206,13 @@ TEST_F(HttpCurlTransportAsyncTest, StartAsyncTransfer) { // Success/error callback needed to report the result of an async operation. int success_call_count = 0; auto success_callback = [&success_call_count, &run_loop]( - RequestID request_id, std::unique_ptr<http::Response> resp) { + RequestID /* request_id */, std::unique_ptr<http::Response> /* resp */) { base::MessageLoop::current()->PostTask(FROM_HERE, run_loop.QuitClosure()); success_call_count++; }; - auto error_callback = [](RequestID request_id, const Error* error) { + auto error_callback = [](RequestID /* request_id */, + const Error* /* error */) { FAIL() << "This callback shouldn't have been called"; }; diff --git a/brillo/http/http_transport_fake.cc b/brillo/http/http_transport_fake.cc index 3833449..d305aa6 100644 --- a/brillo/http/http_transport_fake.cc +++ b/brillo/http/http_transport_fake.cc @@ -63,8 +63,9 @@ std::shared_ptr<http::Connection> Transport::CreateConnection( return connection; } -void Transport::RunCallbackAsync(const tracked_objects::Location& from_here, - const base::Closure& callback) { +void Transport::RunCallbackAsync( + const tracked_objects::Location& /* from_here */, + const base::Closure& callback) { if (!async_) { callback.Run(); return; @@ -88,19 +89,19 @@ void Transport::HandleAllAsyncRequests() { } http::RequestID Transport::StartAsyncTransfer( - http::Connection* connection, - const SuccessCallback& success_callback, - const ErrorCallback& error_callback) { + http::Connection* /* connection */, + const SuccessCallback& /* success_callback */, + const ErrorCallback& /* error_callback */) { // Fake transport doesn't use this method. LOG(FATAL) << "This method should not be called on fake transport"; return 0; } -bool Transport::CancelRequest(RequestID request_id) { +bool Transport::CancelRequest(RequestID /* request_id */) { return false; } -void Transport::SetDefaultTimeout(base::TimeDelta timeout) { +void Transport::SetDefaultTimeout(base::TimeDelta /* timeout */) { } static inline std::string GetHandlerMapKey(const std::string& url, @@ -121,7 +122,7 @@ void Transport::AddSimpleReplyHandler(const std::string& url, const std::string& reply_text, const std::string& mime_type) { auto handler = [status_code, reply_text, mime_type]( - const ServerRequest& request, ServerResponse* response) { + const ServerRequest& /* request */, ServerResponse* response) { response->ReplyText(status_code, reply_text, mime_type); }; AddHandler(url, method, base::Bind(handler)); diff --git a/brillo/http/http_utils_unittest.cc b/brillo/http/http_utils_unittest.cc index ee408b8..aa54cb0 100644 --- a/brillo/http/http_utils_unittest.cc +++ b/brillo/http/http_utils_unittest.cc @@ -69,13 +69,14 @@ TEST(HttpUtils, SendRequestAsync_BinaryData) { // Test binary data round-tripping. std::vector<uint8_t> custom_data{0xFF, 0x00, 0x80, 0x40, 0xC0, 0x7F}; auto success_callback = - [&custom_data](RequestID id, std::unique_ptr<http::Response> response) { + [&custom_data](RequestID /* id */, + std::unique_ptr<http::Response> response) { EXPECT_TRUE(response->IsSuccessful()); EXPECT_EQ(brillo::mime::application::kOctet_stream, response->GetContentType()); EXPECT_EQ(custom_data, response->ExtractData()); }; - auto error_callback = [](RequestID id, const Error* error) { + auto error_callback = [](RequestID /* id */, const Error* /* error */) { FAIL() << "This callback shouldn't have been called"; }; http::SendRequest(request_type::kPost, @@ -158,11 +159,12 @@ TEST(HttpUtils, SendRequestAsync_NotFound) { std::shared_ptr<fake::Transport> transport(new fake::Transport); // Test failed response (URL not found). auto success_callback = - [](RequestID request_id, std::unique_ptr<http::Response> response) { + [](RequestID /* request_id */, std::unique_ptr<http::Response> response) { EXPECT_FALSE(response->IsSuccessful()); EXPECT_EQ(status_code::NotFound, response->GetStatusCode()); }; - auto error_callback = [](RequestID request_id, const Error* error) { + auto error_callback = [](RequestID /* request_id */, + const Error* /* error */) { FAIL() << "This callback shouldn't have been called"; }; http::SendRequestWithNoData(request_type::kGet, @@ -464,10 +466,11 @@ TEST(HttpUtils, SendRequestAsync_Failure) { Error::AddTo(&error, FROM_HERE, "test_domain", "test_code", "Test message"); transport->SetCreateConnectionError(std::move(error)); auto success_callback = - [](RequestID request_id, std::unique_ptr<http::Response> response) { + [](RequestID /* request_id */, + std::unique_ptr<http::Response> /* response */) { FAIL() << "This callback shouldn't have been called"; }; - auto error_callback = [](RequestID request_id, const Error* error) { + auto error_callback = [](RequestID /* request_id */, const Error* error) { EXPECT_EQ("test_domain", error->GetDomain()); EXPECT_EQ("test_code", error->GetCode()); EXPECT_EQ("Test message", error->GetMessage()); diff --git a/brillo/process_reaper.cc b/brillo/process_reaper.cc index c2f81b2..c4cb1cf 100644 --- a/brillo/process_reaper.cc +++ b/brillo/process_reaper.cc @@ -49,7 +49,8 @@ bool ProcessReaper::ForgetChild(pid_t pid) { return watched_processes_.erase(pid) != 0; } -bool ProcessReaper::HandleSIGCHLD(const struct signalfd_siginfo& sigfd_info) { +bool ProcessReaper::HandleSIGCHLD( + const struct signalfd_siginfo& /* sigfd_info */) { // One SIGCHLD may correspond to multiple terminated children, so ignore // sigfd_info and reap any available children. while (true) { diff --git a/brillo/process_reaper_unittest.cc b/brillo/process_reaper_unittest.cc index ae888d2..11db54d 100644 --- a/brillo/process_reaper_unittest.cc +++ b/brillo/process_reaper_unittest.cc @@ -121,7 +121,7 @@ TEST_F(ProcessReaperTest, ReapKilledChild) { TEST_F(ProcessReaperTest, ReapKilledAndForgottenChild) { pid_t pid = ForkChildAndExit(0); EXPECT_TRUE(process_reaper_.WatchForChild(FROM_HERE, pid, base::Bind( - [this](const siginfo_t& info) { + [this](const siginfo_t& /* info */) { ADD_FAILURE() << "Child process was still tracked."; this->brillo_loop_.BreakLoop(); }))); diff --git a/brillo/streams/fake_stream.cc b/brillo/streams/fake_stream.cc index db24e95..0428935 100644 --- a/brillo/streams/fake_stream.cc +++ b/brillo/streams/fake_stream.cc @@ -167,13 +167,13 @@ bool FakeStream::CanWrite() const { return stream_utils::IsWriteAccessMode(mode_); } -bool FakeStream::SetSizeBlocking(uint64_t size, ErrorPtr* error) { +bool FakeStream::SetSizeBlocking(uint64_t /* size */, ErrorPtr* error) { return stream_utils::ErrorOperationNotSupported(FROM_HERE, error); } -bool FakeStream::Seek(int64_t offset, - Whence whence, - uint64_t* new_position, +bool FakeStream::Seek(int64_t /* offset */, + Whence /* whence */, + uint64_t* /* new_position */, ErrorPtr* error) { return stream_utils::ErrorOperationNotSupported(FROM_HERE, error); } @@ -350,7 +350,7 @@ bool FakeStream::FlushBlocking(ErrorPtr* error) { return success; } -bool FakeStream::CloseBlocking(ErrorPtr* error) { +bool FakeStream::CloseBlocking(ErrorPtr* /* error */) { is_open_ = false; return true; } diff --git a/brillo/streams/fake_stream_unittest.cc b/brillo/streams/fake_stream_unittest.cc index 2aa18fd..5a66704 100644 --- a/brillo/streams/fake_stream_unittest.cc +++ b/brillo/streams/fake_stream_unittest.cc @@ -284,7 +284,7 @@ TEST_F(FakeStreamTest, ReadAsync) { int success_count = 0; int error_count = 0; auto on_success = [&success_count] { success_count++; }; - auto on_failure = [&error_count](const Error* error) { error_count++; }; + auto on_failure = [&error_count](const Error* /* error */) { error_count++; }; EXPECT_TRUE(stream_->ReadAllAsync(buffer.data(), buffer.size(), base::Bind(on_success), @@ -437,7 +437,7 @@ TEST_F(FakeStreamTest, WriteAsync) { int success_count = 0; int error_count = 0; auto on_success = [&success_count] { success_count++; }; - auto on_failure = [&error_count](const Error* error) { error_count++; }; + auto on_failure = [&error_count](const Error* /* error */) { error_count++; }; EXPECT_TRUE(stream_->WriteAllAsync(output_data.data(), output_data.size(), base::Bind(on_success), diff --git a/brillo/streams/file_stream_unittest.cc b/brillo/streams/file_stream_unittest.cc index 5941621..830d31c 100644 --- a/brillo/streams/file_stream_unittest.cc +++ b/brillo/streams/file_stream_unittest.cc @@ -372,7 +372,7 @@ TEST_F(FileStreamTest, ReadAsync) { size_t read_size = 0; bool failed = false; auto success_callback = [&read_size](size_t size) { read_size = size; }; - auto error_callback = [&failed](const Error* error) { failed = true; }; + auto error_callback = [&failed](const Error* /* error */) { failed = true; }; FileStream::FileDescriptorInterface::DataCallback data_callback; EXPECT_CALL(fd_mock(), Read(test_read_buffer_, 100)) @@ -511,7 +511,7 @@ TEST_F(FileStreamTest, WriteAsync) { size_t write_size = 0; bool failed = false; auto success_callback = [&write_size](size_t size) { write_size = size; }; - auto error_callback = [&failed](const Error* error) { failed = true; }; + auto error_callback = [&failed](const Error* /* error */) { failed = true; }; FileStream::FileDescriptorInterface::DataCallback data_callback; EXPECT_CALL(fd_mock(), Write(test_write_buffer_, 100)) @@ -1039,7 +1039,7 @@ TEST_F(FileStreamTest, FromFileDescriptor_ReadAsync) { succeeded = true; }; - auto error_callback = [&failed](const Error* error) { + auto error_callback = [&failed](const Error* /* error */) { failed = true; }; @@ -1084,14 +1084,14 @@ TEST_F(FileStreamTest, FromFileDescriptor_WriteAsync) { ASSERT_EQ(0, pipe(fds)); - auto success_callback = [&succeeded, &data](int read_fd, size_t size) { + auto success_callback = [&succeeded, &data](int read_fd, size_t /* size */) { char buffer[100]; EXPECT_TRUE(base::ReadFromFD(read_fd, buffer, data.size())); EXPECT_EQ(data, (std::string{buffer, buffer + data.size()})); succeeded = true; }; - auto error_callback = [&failed](const Error* error) { + auto error_callback = [&failed](const Error* /* error */) { failed = true; }; diff --git a/brillo/streams/input_stream_set.cc b/brillo/streams/input_stream_set.cc index 913aaa0..986efac 100644 --- a/brillo/streams/input_stream_set.cc +++ b/brillo/streams/input_stream_set.cc @@ -88,7 +88,7 @@ uint64_t InputStreamSet::GetSize() const { return initial_stream_size_; } -bool InputStreamSet::SetSizeBlocking(uint64_t size, ErrorPtr* error) { +bool InputStreamSet::SetSizeBlocking(uint64_t /* size */, ErrorPtr* error) { return stream_utils::ErrorOperationNotSupported(FROM_HERE, error); } @@ -99,9 +99,9 @@ uint64_t InputStreamSet::GetRemainingSize() const { return size; } -bool InputStreamSet::Seek(int64_t offset, - Whence whence, - uint64_t* new_position, +bool InputStreamSet::Seek(int64_t /* offset */, + Whence /* whence */, + uint64_t* /* new_position */, ErrorPtr* error) { return stream_utils::ErrorOperationNotSupported(FROM_HERE, error); } @@ -134,9 +134,9 @@ bool InputStreamSet::ReadNonBlocking(void* buffer, return true; } -bool InputStreamSet::WriteNonBlocking(const void* buffer, - size_t size_to_write, - size_t* size_written, +bool InputStreamSet::WriteNonBlocking(const void* /* buffer */, + size_t /* size_to_write */, + size_t* /* size_written */, ErrorPtr* error) { return stream_utils::ErrorOperationNotSupported(FROM_HERE, error); } diff --git a/brillo/streams/input_stream_set.h b/brillo/streams/input_stream_set.h index 8770b10..9111ff9 100644 --- a/brillo/streams/input_stream_set.h +++ b/brillo/streams/input_stream_set.h @@ -90,7 +90,7 @@ class BRILLO_EXPORT InputStreamSet : public Stream { ErrorPtr* error) override; // == Finalizing/closing streams =========================================== - bool FlushBlocking(ErrorPtr* error) override { return true; } + bool FlushBlocking(ErrorPtr* /* error */) override { return true; } bool CloseBlocking(ErrorPtr* error) override; // == Data availability monitoring ========================================== diff --git a/brillo/streams/memory_containers.cc b/brillo/streams/memory_containers.cc index 6e277b8..c1b842e 100644 --- a/brillo/streams/memory_containers.cc +++ b/brillo/streams/memory_containers.cc @@ -73,19 +73,21 @@ bool ContiguousBufferBase::Write(const void* buffer, return true; } -bool ContiguousReadOnlyBufferBase::Write(const void* buffer, - size_t size_to_write, - size_t offset, - size_t* size_written, +bool ContiguousReadOnlyBufferBase::Write(const void* /* buffer */, + size_t /* size_to_write */, + size_t /* offset */, + size_t* /* size_written */, ErrorPtr* error) { return ErrorStreamReadOnly(FROM_HERE, error); } -bool ContiguousReadOnlyBufferBase::Resize(size_t new_size, ErrorPtr* error) { +bool ContiguousReadOnlyBufferBase::Resize(size_t /* new_size */, + ErrorPtr* error) { return ErrorStreamReadOnly(FROM_HERE, error); } -void* ContiguousReadOnlyBufferBase::GetBuffer(size_t offset, ErrorPtr* error) { +void* ContiguousReadOnlyBufferBase::GetBuffer(size_t /* offset */, + ErrorPtr* error) { ErrorStreamReadOnly(FROM_HERE, error); return nullptr; } @@ -101,16 +103,17 @@ ByteBuffer::~ByteBuffer() { StringPtr::StringPtr(std::string* string) : string_ptr_(string) {} -bool StringPtr::Resize(size_t new_size, ErrorPtr* error) { +bool StringPtr::Resize(size_t new_size, ErrorPtr* /* error */) { string_ptr_->resize(new_size); return true; } -const void* StringPtr::GetReadOnlyBuffer(size_t offset, ErrorPtr* error) const { +const void* StringPtr::GetReadOnlyBuffer(size_t offset, + ErrorPtr* /* error */) const { return string_ptr_->data() + offset; } -void* StringPtr::GetBuffer(size_t offset, ErrorPtr* error) { +void* StringPtr::GetBuffer(size_t offset, ErrorPtr* /* error */) { return &(*string_ptr_)[offset]; } @@ -118,7 +121,7 @@ ReadOnlyStringRef::ReadOnlyStringRef(const std::string& string) : string_ref_(string) {} const void* ReadOnlyStringRef::GetReadOnlyBuffer(size_t offset, - ErrorPtr* error) const { + ErrorPtr* /* error */) const { return string_ref_.data() + offset; } diff --git a/brillo/streams/memory_containers.h b/brillo/streams/memory_containers.h index ba2ebc4..d3cb205 100644 --- a/brillo/streams/memory_containers.h +++ b/brillo/streams/memory_containers.h @@ -131,7 +131,8 @@ class BRILLO_EXPORT ReadOnlyBuffer : public ContiguousReadOnlyBufferBase { : buffer_(buffer), size_(size) {} // Returns the pointer to data at |offset|. - const void* GetReadOnlyBuffer(size_t offset, ErrorPtr* error) const override { + const void* GetReadOnlyBuffer(size_t offset, + ErrorPtr* /* error */) const override { return reinterpret_cast<const uint8_t*>(buffer_) + offset; } // Returns the size of the container. @@ -154,16 +155,17 @@ class VectorPtr : public ContiguousBufferBase { static_assert(sizeof(T) == 1, "Only char/byte is supported"); explicit VectorPtr(std::vector<T>* vector) : vector_ptr_(vector) {} - bool Resize(size_t new_size, ErrorPtr* error) override { + bool Resize(size_t new_size, ErrorPtr* /* error */) override { vector_ptr_->resize(new_size); return true; } size_t GetSize() const override { return vector_ptr_->size(); } bool IsReadOnly() const override { return false; } - const void* GetReadOnlyBuffer(size_t offset, ErrorPtr* error) const override { + const void* GetReadOnlyBuffer(size_t offset, + ErrorPtr* /* error */) const override { return reinterpret_cast<const uint8_t*>(vector_ptr_->data()) + offset; } - void* GetBuffer(size_t offset, ErrorPtr* error) override { + void* GetBuffer(size_t offset, ErrorPtr* /* error */) override { return reinterpret_cast<uint8_t*>(vector_ptr_->data()) + offset; } @@ -184,7 +186,8 @@ class ReadOnlyVectorRef : public ContiguousReadOnlyBufferBase { explicit ReadOnlyVectorRef(const std::vector<T>& vector) : vector_ref_(vector) {} - const void* GetReadOnlyBuffer(size_t offset, ErrorPtr* error) const override { + const void* GetReadOnlyBuffer(size_t offset, + ErrorPtr* /* error */) const override { return reinterpret_cast<const uint8_t*>(vector_ref_.data()) + offset; } size_t GetSize() const override { return vector_ref_.size(); } @@ -210,7 +213,8 @@ class ReadOnlyVectorCopy : public ContiguousReadOnlyBufferBase { ReadOnlyVectorCopy(const T* buffer, size_t size) : vector_copy_(buffer, buffer + size) {} - const void* GetReadOnlyBuffer(size_t offset, ErrorPtr* error) const override { + const void* GetReadOnlyBuffer(size_t offset, + ErrorPtr* /* error */) const override { return reinterpret_cast<const uint8_t*>(vector_copy_.data()) + offset; } size_t GetSize() const override { return vector_copy_.size(); } diff --git a/brillo/streams/memory_stream.cc b/brillo/streams/memory_stream.cc index c9712b0..54f127a 100644 --- a/brillo/streams/memory_stream.cc +++ b/brillo/streams/memory_stream.cc @@ -184,15 +184,15 @@ bool MemoryStream::CheckContainer(ErrorPtr* error) const { bool MemoryStream::WaitForData(AccessMode mode, const base::Callback<void(AccessMode)>& callback, - ErrorPtr* error) { + ErrorPtr* /* error */) { MessageLoop::current()->PostTask(FROM_HERE, base::Bind(callback, mode)); return true; } bool MemoryStream::WaitForDataBlocking(AccessMode in_mode, - base::TimeDelta timeout, + base::TimeDelta /* timeout */, AccessMode* out_mode, - ErrorPtr* error) { + ErrorPtr* /* error */) { if (out_mode) *out_mode = in_mode; return true; diff --git a/brillo/streams/openssl_stream_bio.cc b/brillo/streams/openssl_stream_bio.cc index 54a5536..a63d9c0 100644 --- a/brillo/streams/openssl_stream_bio.cc +++ b/brillo/streams/openssl_stream_bio.cc @@ -47,7 +47,7 @@ int stream_read(BIO* bio, char* buf, int size) { } // NOLINTNEXTLINE(runtime/int) -long stream_ctrl(BIO* bio, int cmd, long num, void* ptr) { +long stream_ctrl(BIO* bio, int cmd, long /* num */, void* /* ptr */) { if (cmd == BIO_CTRL_FLUSH) { brillo::Stream* stream = static_cast<brillo::Stream*>(bio->ptr); return stream->FlushBlocking(nullptr) ? 1 : 0; diff --git a/brillo/streams/stream.cc b/brillo/streams/stream.cc index cd9b0a8..6a40c00 100644 --- a/brillo/streams/stream.cc +++ b/brillo/streams/stream.cc @@ -187,7 +187,7 @@ bool Stream::FlushAsync(const base::Closure& success_callback, void Stream::IgnoreEOSCallback( const base::Callback<void(size_t)>& success_callback, size_t bytes, - bool eos) { + bool /* eos */) { success_callback.Run(bytes); } diff --git a/brillo/streams/stream_unittest.cc b/brillo/streams/stream_unittest.cc index d19b9ac..927b1d8 100644 --- a/brillo/streams/stream_unittest.cc +++ b/brillo/streams/stream_unittest.cc @@ -104,7 +104,7 @@ TEST(Stream, ReadAsync) { read_size = size; succeeded = true; }; - auto error_callback = [&failed](const Error* error) { failed = true; }; + auto error_callback = [&failed](const Error* /* error */) { failed = true; }; MockStreamImpl stream_mock; base::Callback<void(AccessMode)> data_callback; @@ -149,8 +149,8 @@ TEST(Stream, ReadAsync) { TEST(Stream, ReadAsync_DontWaitForData) { bool succeeded = false; bool failed = false; - auto success_callback = [&succeeded](size_t size) { succeeded = true; }; - auto error_callback = [&failed](const Error* error) { failed = true; }; + auto success_callback = [&succeeded](size_t /* size */) { succeeded = true; }; + auto error_callback = [&failed](const Error* /* error */) { failed = true; }; MockStreamImpl stream_mock; char buf[10]; @@ -190,7 +190,7 @@ TEST(Stream, ReadAllAsync) { bool succeeded = false; bool failed = false; auto success_callback = [&succeeded]() { succeeded = true; }; - auto error_callback = [&failed](const Error* error) { failed = true; }; + auto error_callback = [&failed](const Error* /* error */) { failed = true; }; MockStreamImpl stream_mock; base::Callback<void(AccessMode)> data_callback; @@ -352,7 +352,7 @@ TEST(Stream, WriteAsync) { size_t write_size = 0; bool failed = false; auto success_callback = [&write_size](size_t size) { write_size = size; }; - auto error_callback = [&failed](const Error* error) { failed = true; }; + auto error_callback = [&failed](const Error* /* error */) { failed = true; }; MockStreamImpl stream_mock; InSequence s; @@ -391,7 +391,7 @@ TEST(Stream, WriteAllAsync) { bool succeeded = false; bool failed = false; auto success_callback = [&succeeded]() { succeeded = true; }; - auto error_callback = [&failed](const Error* error) { failed = true; }; + auto error_callback = [&failed](const Error* /* error */) { failed = true; }; MockStreamImpl stream_mock; base::Callback<void(AccessMode)> data_callback; diff --git a/brillo/streams/stream_utils_unittest.cc b/brillo/streams/stream_utils_unittest.cc index 8145027..f27d233 100644 --- a/brillo/streams/stream_utils_unittest.cc +++ b/brillo/streams/stream_utils_unittest.cc @@ -166,16 +166,16 @@ class CopyStreamDataTest : public testing::Test { bool failed_{false}; void OnSuccess(uint64_t expected, - StreamPtr in_stream, - StreamPtr out_stream, + StreamPtr /* in_stream */, + StreamPtr /* out_stream */, uint64_t copied) { EXPECT_EQ(expected, copied); succeeded_ = true; } void OnError(const std::string& expected_error, - StreamPtr in_stream, - StreamPtr out_stream, + StreamPtr /* in_stream */, + StreamPtr /* out_stream */, const Error* error) { EXPECT_EQ(expected_error, error->GetCode()); failed_ = true; diff --git a/brillo/streams/tls_stream.cc b/brillo/streams/tls_stream.cc index f82db1a..ac116a4 100644 --- a/brillo/streams/tls_stream.cc +++ b/brillo/streams/tls_stream.cc @@ -24,7 +24,7 @@ namespace { // SSL info callback which is called by OpenSSL when we enable logging level of // at least 3. This logs the information about the internal TLS handshake. -void TlsInfoCallback(const SSL* ssl, int where, int ret) { +void TlsInfoCallback(const SSL* /* ssl */, int where, int ret) { std::string reason; std::vector<std::string> info; if (where & SSL_CB_LOOP) @@ -400,7 +400,7 @@ bool TlsStream::TlsStreamImpl::Init(StreamPtr socket, void TlsStream::TlsStreamImpl::RetryHandshake( const base::Closure& success_callback, const Stream::ErrorCallback& error_callback, - Stream::AccessMode mode) { + Stream::AccessMode /* mode */) { VLOG(1) << "Retrying TLS handshake"; DoHandshake(success_callback, error_callback); } @@ -475,13 +475,13 @@ bool TlsStream::IsOpen() const { return impl_ ? true : false; } -bool TlsStream::SetSizeBlocking(uint64_t size, ErrorPtr* error) { +bool TlsStream::SetSizeBlocking(uint64_t /* size */, ErrorPtr* error) { return stream_utils::ErrorOperationNotSupported(FROM_HERE, error); } -bool TlsStream::Seek(int64_t offset, - Whence whence, - uint64_t* new_position, +bool TlsStream::Seek(int64_t /* offset */, + Whence /* whence */, + uint64_t* /* new_position*/, ErrorPtr* error) { return stream_utils::ErrorOperationNotSupported(FROM_HERE, error); } diff --git a/brillo/syslog_logging.cc b/brillo/syslog_logging.cc index 045c6e3..40b064a 100644 --- a/brillo/syslog_logging.cc +++ b/brillo/syslog_logging.cc @@ -34,8 +34,8 @@ static bool s_log_to_stderr; static bool s_log_header; static bool HandleMessage(int severity, - const char* file, - int line, + const char* /* file */, + int /* line */, size_t message_start, const std::string& message) { switch (severity) { |