diff options
author | 2025-02-25 12:02:34 -0800 | |
---|---|---|
committer | 2025-02-25 12:02:34 -0800 | |
commit | fa55a6fb0a1de13a62cba65a1703546af183b548 (patch) | |
tree | 6e369a4f8edd0fcdea23833ee7ed296e0ffe5537 | |
parent | e1ff1b5c6d06320614e6918ee2314f6dc1e3d7c0 (diff) | |
parent | c5e18a63495955be9c1eabf4b9bc431f9395ba3b (diff) |
Merge "system/gd: Enforce -Wmissing-prototypes" into main
-rw-r--r-- | system/gd/Android.bp | 1 | ||||
-rw-r--r-- | system/gd/common/metric_id_manager_unittest.cc | 7 | ||||
-rw-r--r-- | system/gd/common/strings_test.cc | 5 | ||||
-rw-r--r-- | system/gd/fuzz_test.cc | 3 | ||||
-rw-r--r-- | system/gd/hal/snoop_logger_test.cc | 5 | ||||
-rw-r--r-- | system/gd/hci/acl_manager/classic_impl_test.cc | 11 | ||||
-rw-r--r-- | system/gd/hci/controller_test.cc | 7 | ||||
-rw-r--r-- | system/gd/hci/fuzz/acl_manager_fuzz_test.cc | 3 | ||||
-rw-r--r-- | system/gd/hci/fuzz/hci_layer_fuzz_test.cc | 3 | ||||
-rw-r--r-- | system/gd/hci/hci_layer_unittest.cc | 11 | ||||
-rw-r--r-- | system/gd/hci/hci_packets_fuzz_test.cc | 3 | ||||
-rw-r--r-- | system/gd/hci/le_address_manager.cc | 5 | ||||
-rw-r--r-- | system/gd/hci/le_advertising_manager.cc | 7 | ||||
-rw-r--r-- | system/gd/metrics/bluetooth_event.cc | 7 | ||||
-rw-r--r-- | system/gd/os/linux_generic/alarm_timerfd_unittest.cc | 16 | ||||
-rw-r--r-- | system/gd/os/linux_generic/wakelock_manager.cc | 5 |
16 files changed, 13 insertions, 86 deletions
diff --git a/system/gd/Android.bp b/system/gd/Android.bp index dd70c9cf80..a57b83073d 100644 --- a/system/gd/Android.bp +++ b/system/gd/Android.bp @@ -535,6 +535,7 @@ cc_defaults { cflags: [ "-DFUZZ_TARGET", "-DUSE_FAKE_TIMERS", + "-Wno-missing-prototypes", ], target: { android: { diff --git a/system/gd/common/metric_id_manager_unittest.cc b/system/gd/common/metric_id_manager_unittest.cc index 6c36187a55..3caca10b4a 100644 --- a/system/gd/common/metric_id_manager_unittest.cc +++ b/system/gd/common/metric_id_manager_unittest.cc @@ -22,14 +22,11 @@ #include <thread> -// TODO(b/369381361) Enfore -Wmissing-prototypes -#pragma GCC diagnostic ignored "-Wmissing-prototypes" - namespace testing { using bluetooth::common::MetricIdManager; -bluetooth::hci::Address kthAddress(uint32_t k) { +static bluetooth::hci::Address kthAddress(uint32_t k) { uint8_t array[6] = {0, 0, 0, 0, 0, 0}; for (int i = 5; i >= 2; i--) { array[i] = k % 256; @@ -39,7 +36,7 @@ bluetooth::hci::Address kthAddress(uint32_t k) { return addr; } -std::unordered_map<bluetooth::hci::Address, int> generateAddresses(const uint32_t num) { +static std::unordered_map<bluetooth::hci::Address, int> generateAddresses(const uint32_t num) { // generate first num of mac address -> id pairs // input may is always valid 256^6 = 2^48 > 2^32 std::unordered_map<bluetooth::hci::Address, int> device_map; diff --git a/system/gd/common/strings_test.cc b/system/gd/common/strings_test.cc index 63a9804ab7..9188eae528 100644 --- a/system/gd/common/strings_test.cc +++ b/system/gd/common/strings_test.cc @@ -23,9 +23,6 @@ #include <array> #include <memory> -// TODO(b/369381361) Enfore -Wmissing-prototypes -#pragma GCC diagnostic ignored "-Wmissing-prototypes" - namespace testing { using bluetooth::common::BoolFromString; @@ -269,7 +266,7 @@ TEST(StringsTest, string_format_time_with_ms_test) { } class ExampleClass {}; -std::ostream& operator<<(std::ostream& os, const ExampleClass& /* obj */) { +static std::ostream& operator<<(std::ostream& os, const ExampleClass& /* obj */) { os << "ExampleClass"; return os; } diff --git a/system/gd/fuzz_test.cc b/system/gd/fuzz_test.cc index 8b4b2b9786..bdb007b295 100644 --- a/system/gd/fuzz_test.cc +++ b/system/gd/fuzz_test.cc @@ -17,9 +17,6 @@ #include <stddef.h> #include <stdint.h> -// TODO(b/369381361) Enfore -Wmissing-prototypes -#pragma GCC diagnostic ignored "-Wmissing-prototypes" - void RunHciPacketFuzzTest(const uint8_t* data, size_t size); extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) { diff --git a/system/gd/hal/snoop_logger_test.cc b/system/gd/hal/snoop_logger_test.cc index 1f4d2daa64..4681f82f30 100644 --- a/system/gd/hal/snoop_logger_test.cc +++ b/system/gd/hal/snoop_logger_test.cc @@ -34,9 +34,6 @@ #include "os/system_properties.h" #include "os/utils.h" -// TODO(b/369381361) Enfore -Wmissing-prototypes -#pragma GCC diagnostic ignored "-Wmissing-prototypes" - namespace testing { using bluetooth::hal::SnoopLoggerCommon; @@ -368,7 +365,7 @@ TEST_F(SnoopLoggerModuleTest, snoop_log_persists) { ASSERT_TRUE(std::filesystem::exists(temp_snooz_log_)); } -void sync_handler(bluetooth::os::Handler* handler) { +static void sync_handler(bluetooth::os::Handler* handler) { std::promise<void> promise; auto future = promise.get_future(); handler->Post(bluetooth::common::BindOnce(&std::promise<void>::set_value, diff --git a/system/gd/hci/acl_manager/classic_impl_test.cc b/system/gd/hci/acl_manager/classic_impl_test.cc index e5aa6d61ae..6b57eac662 100644 --- a/system/gd/hci/acl_manager/classic_impl_test.cc +++ b/system/gd/hci/acl_manager/classic_impl_test.cc @@ -33,9 +33,6 @@ #include "packet/bit_inserter.h" #include "packet/raw_builder.h" -// TODO(b/369381361) Enfore -Wmissing-prototypes -#pragma GCC diagnostic ignored "-Wmissing-prototypes" - using namespace bluetooth; using namespace std::chrono_literals; @@ -143,14 +140,6 @@ public: } }; -PacketView<kLittleEndian> GetPacketView(std::unique_ptr<packet::BasePacketBuilder> packet) { - auto bytes = std::make_shared<std::vector<uint8_t>>(); - BitInserter i(*bytes); - bytes->reserve(packet->size()); - packet->Serialize(i); - return packet::PacketView<packet::kLittleEndian>(bytes); -} - class ClassicImplTest : public ::testing::Test { protected: void SetUp() override { diff --git a/system/gd/hci/controller_test.cc b/system/gd/hci/controller_test.cc index 05dcaf9d7e..0743204ffd 100644 --- a/system/gd/hci/controller_test.cc +++ b/system/gd/hci/controller_test.cc @@ -32,9 +32,6 @@ #include "os/thread.h" #include "packet/raw_builder.h" -// TODO(b/369381361) Enfore -Wmissing-prototypes -#pragma GCC diagnostic ignored "-Wmissing-prototypes" - using namespace bluetooth; using namespace std::chrono_literals; @@ -580,7 +577,7 @@ TEST_F(Controller104Test, feature_spec_version_104_test) { std::promise<void> credits1_set; std::promise<void> credits2_set; -void CheckReceivedCredits(uint16_t handle, uint16_t credits) { +static void CheckReceivedCredits(uint16_t handle, uint16_t credits) { switch (handle) { case (kHandle1): ASSERT_EQ(kCredits1, credits); @@ -624,7 +621,7 @@ TEST_F(ControllerTest, aclCreditCallbackListenerUnregistered) { std::promise<uint64_t> le_rand_set; -void le_rand_callback(uint64_t random) { le_rand_set.set_value(random); } +static void le_rand_callback(uint64_t random) { le_rand_set.set_value(random); } TEST_F(ControllerTest, leRandTest) { le_rand_set = std::promise<uint64_t>(); diff --git a/system/gd/hci/fuzz/acl_manager_fuzz_test.cc b/system/gd/hci/fuzz/acl_manager_fuzz_test.cc index 06544789b7..d9c039415c 100644 --- a/system/gd/hci/fuzz/acl_manager_fuzz_test.cc +++ b/system/gd/hci/fuzz/acl_manager_fuzz_test.cc @@ -25,9 +25,6 @@ #include "module.h" #include "os/fake_timer/fake_timerfd.h" -// TODO(b/369381361) Enfore -Wmissing-prototypes -#pragma GCC diagnostic ignored "-Wmissing-prototypes" - using bluetooth::FuzzTestModuleRegistry; using bluetooth::fuzz::GetArbitraryBytes; using bluetooth::hci::AclManager; diff --git a/system/gd/hci/fuzz/hci_layer_fuzz_test.cc b/system/gd/hci/fuzz/hci_layer_fuzz_test.cc index 392ffdd3e6..1fed31e882 100644 --- a/system/gd/hci/fuzz/hci_layer_fuzz_test.cc +++ b/system/gd/hci/fuzz/hci_layer_fuzz_test.cc @@ -25,9 +25,6 @@ #include "module.h" #include "os/fake_timer/fake_timerfd.h" -// TODO(b/369381361) Enfore -Wmissing-prototypes -#pragma GCC diagnostic ignored "-Wmissing-prototypes" - using bluetooth::FuzzTestModuleRegistry; using bluetooth::fuzz::GetArbitraryBytes; using bluetooth::hal::HciHal; diff --git a/system/gd/hci/hci_layer_unittest.cc b/system/gd/hci/hci_layer_unittest.cc index 1f2526e46d..5abc0c74fc 100644 --- a/system/gd/hci/hci_layer_unittest.cc +++ b/system/gd/hci/hci_layer_unittest.cc @@ -34,9 +34,6 @@ #include "os/thread.h" #include "packet/raw_builder.h" -// TODO(b/369381361) Enfore -Wmissing-prototypes -#pragma GCC diagnostic ignored "-Wmissing-prototypes" - using namespace std::chrono_literals; namespace { @@ -72,14 +69,6 @@ using packet::kLittleEndian; using packet::PacketView; using packet::RawBuilder; -std::vector<uint8_t> GetPacketBytes(std::unique_ptr<packet::BasePacketBuilder> packet) { - std::vector<uint8_t> bytes; - BitInserter i(bytes); - bytes.reserve(packet->size()); - packet->Serialize(i); - return bytes; -} - static std::chrono::milliseconds getHciTimeoutMs() { static auto sHciTimeoutMs = std::chrono::milliseconds(bluetooth::os::GetSystemPropertyUint32Base( "bluetooth.hci.timeout_milliseconds", HciLayer::kHciTimeoutMs.count())); diff --git a/system/gd/hci/hci_packets_fuzz_test.cc b/system/gd/hci/hci_packets_fuzz_test.cc index 2868477c46..00a053273c 100644 --- a/system/gd/hci/hci_packets_fuzz_test.cc +++ b/system/gd/hci/hci_packets_fuzz_test.cc @@ -21,9 +21,6 @@ #include "packet/bit_inserter.h" #include "packet/raw_builder.h" -// TODO(b/369381361) Enfore -Wmissing-prototypes -#pragma GCC diagnostic ignored "-Wmissing-prototypes" - using bluetooth::packet::BitInserter; using bluetooth::packet::RawBuilder; using std::vector; diff --git a/system/gd/hci/le_address_manager.cc b/system/gd/hci/le_address_manager.cc index bddbcaf4d1..034f251b0e 100644 --- a/system/gd/hci/le_address_manager.cc +++ b/system/gd/hci/le_address_manager.cc @@ -28,9 +28,6 @@ // TODO(b/378143579) For peer address not in resolving list -// TODO(b/369381361) Enfore -Wmissing-prototypes -#pragma GCC diagnostic ignored "-Wmissing-prototypes" - namespace bluetooth { namespace hci { @@ -53,7 +50,7 @@ std::string LeAddressManager::ClientStateText(const ClientState cs) { RETURN_UNKNOWN_TYPE_STRING(ClientState, cs); } -std::string AddressPolicyText(const LeAddressManager::AddressPolicy policy) { +static std::string AddressPolicyText(const LeAddressManager::AddressPolicy policy) { switch (policy) { CASE_RETURN_STRING(LeAddressManager::AddressPolicy::POLICY_NOT_SET); CASE_RETURN_STRING(LeAddressManager::AddressPolicy::USE_PUBLIC_ADDRESS); diff --git a/system/gd/hci/le_advertising_manager.cc b/system/gd/hci/le_advertising_manager.cc index acf3da1188..afa8fd300b 100644 --- a/system/gd/hci/le_advertising_manager.cc +++ b/system/gd/hci/le_advertising_manager.cc @@ -35,9 +35,6 @@ #include "os/system_properties.h" #include "packet/fragmenting_inserter.h" -// TODO(b/369381361) Enfore -Wmissing-prototypes -#pragma GCC diagnostic ignored "-Wmissing-prototypes" - namespace bluetooth { namespace hci { @@ -102,7 +99,7 @@ struct Advertiser { * (2) if the host supports only non-resolvable addresses, then advertisements will never use RPA * (3) if the host supports RPAs, then the requested type will always be honored */ -AdvertiserAddressType GetAdvertiserAddressTypeFromRequestedTypeAndPolicy( +static AdvertiserAddressType GetAdvertiserAddressTypeFromRequestedTypeAndPolicy( AdvertiserAddressType requested_address_type, LeAddressManager::AddressPolicy address_policy) { switch (address_policy) { @@ -127,7 +124,7 @@ AdvertiserAddressType GetAdvertiserAddressTypeFromRequestedTypeAndPolicy( * can use both Public and NRPA if requested. Use NRPA if RPA is requested. * (2) in other cases, based on the requested type and the address manager policy. */ -AdvertiserAddressType GetAdvertiserAddressTypeNonConnectable( +static AdvertiserAddressType GetAdvertiserAddressTypeNonConnectable( AdvertiserAddressType requested_address_type, LeAddressManager::AddressPolicy address_policy) { switch (address_policy) { diff --git a/system/gd/metrics/bluetooth_event.cc b/system/gd/metrics/bluetooth_event.cc index f9202f506c..26ce918099 100644 --- a/system/gd/metrics/bluetooth_event.cc +++ b/system/gd/metrics/bluetooth_event.cc @@ -21,9 +21,6 @@ #include "main/shim/helpers.h" #include "os/metrics.h" -// TODO(b/369381361) Enfore -Wmissing-prototypes -#pragma GCC diagnostic ignored "-Wmissing-prototypes" - namespace bluetooth { namespace metrics { @@ -170,7 +167,7 @@ State MapErrorCodeToState(ErrorCode reason) { } } -State MapHCIStatusToState(tHCI_STATUS status) { +static State MapHCIStatusToState(tHCI_STATUS status) { switch (status) { case tHCI_STATUS::HCI_SUCCESS: return State::SUCCESS; @@ -261,7 +258,7 @@ State MapHCIStatusToState(tHCI_STATUS status) { } } -State MapSmpStatusCodeToState(tSMP_STATUS status) { +static State MapSmpStatusCodeToState(tSMP_STATUS status) { switch (status) { case tSMP_STATUS::SMP_SUCCESS: return State::SUCCESS; diff --git a/system/gd/os/linux_generic/alarm_timerfd_unittest.cc b/system/gd/os/linux_generic/alarm_timerfd_unittest.cc index 03d99bb476..bcf802b86d 100644 --- a/system/gd/os/linux_generic/alarm_timerfd_unittest.cc +++ b/system/gd/os/linux_generic/alarm_timerfd_unittest.cc @@ -23,22 +23,6 @@ #include "gtest/gtest.h" #include "os/alarm.h" -// TODO(b/369381361) Enfore -Wmissing-prototypes -#pragma GCC diagnostic ignored "-Wmissing-prototypes" - -namespace bluetooth::common { - -struct IsSpace { - bool operator()(std::string::value_type v) { return isspace(static_cast<int>(v)); } -}; - -std::string StringTrim(std::string str) { - str.erase(str.begin(), std::find_if_not(str.begin(), str.end(), IsSpace{})); - str.erase(std::find_if_not(str.rbegin(), str.rend(), IsSpace{}).base(), str.end()); - return str; -} -} // namespace bluetooth::common - namespace bluetooth::os { using common::BindOnce; diff --git a/system/gd/os/linux_generic/wakelock_manager.cc b/system/gd/os/linux_generic/wakelock_manager.cc index 7cca56201a..ad31b82063 100644 --- a/system/gd/os/linux_generic/wakelock_manager.cc +++ b/system/gd/os/linux_generic/wakelock_manager.cc @@ -27,16 +27,13 @@ #include "os/internal/wakelock_native.h" -// TODO(b/369381361) Enfore -Wmissing-prototypes -#pragma GCC diagnostic ignored "-Wmissing-prototypes" - namespace bluetooth { namespace os { using internal::WakelockNative; using StatusCode = WakelockNative::StatusCode; -uint64_t now_ms() { +static uint64_t now_ms() { struct timespec ts = {}; if (clock_gettime(CLOCK_BOOTTIME, &ts) == -1) { log::error("unable to get current time: {}", strerror(errno)); |