diff options
author | 2025-02-25 01:47:13 +0000 | |
---|---|---|
committer | 2025-02-25 09:47:05 -0800 | |
commit | eeb79025bc5d0573ba63be8724129a9dd66fc372 (patch) | |
tree | 731cbba1079b7b83d655886f28061c273085c130 | |
parent | dc7709937757fcac332e33af9518d3fef642c397 (diff) |
system/common: Enforce -Wmissing-prototypes
Bug: 369381361
Test: m com.android.bt
Flag: EXEMPT, no logical change
Change-Id: I84d7c6ad452350b142a4ba05389b5aeb29969017
-rw-r--r-- | system/common/benchmark/thread_performance_benchmark.cc | 11 | ||||
-rw-r--r-- | system/common/metric_id_allocator_unittest.cc | 7 | ||||
-rw-r--r-- | system/common/metrics_linux.cc | 8 | ||||
-rw-r--r-- | system/common/metrics_unittest.cc | 56 | ||||
-rw-r--r-- | system/common/os_utils.cc | 5 | ||||
-rw-r--r-- | system/common/test/thread_performance_test.cc | 5 |
6 files changed, 27 insertions, 65 deletions
diff --git a/system/common/benchmark/thread_performance_benchmark.cc b/system/common/benchmark/thread_performance_benchmark.cc index 97f0c93b2d..3ae5033c69 100644 --- a/system/common/benchmark/thread_performance_benchmark.cc +++ b/system/common/benchmark/thread_performance_benchmark.cc @@ -30,9 +30,6 @@ #include "osi/include/fixed_queue.h" #include "osi/include/thread.h" -// TODO(b/369381361) Enfore -Wmissing-prototypes -#pragma GCC diagnostic ignored "-Wmissing-prototypes" - using ::benchmark::State; using bluetooth::common::MessageLoopThread; @@ -41,7 +38,7 @@ using bluetooth::common::MessageLoopThread; static std::atomic<int> g_counter = 0; static std::unique_ptr<std::promise<void>> g_counter_promise = nullptr; -void pthread_callback_batch(void* context) { +static void pthread_callback_batch(void* context) { auto queue = static_cast<fixed_queue_t*>(context); bluetooth::log::assert_that(queue != nullptr, "assert failed: queue != nullptr"); fixed_queue_dequeue(queue); @@ -51,15 +48,15 @@ void pthread_callback_batch(void* context) { } } -void callback_sequential(void* /* context */) { g_counter_promise->set_value(); } +static void callback_sequential(void* /* context */) { g_counter_promise->set_value(); } -void callback_sequential_queue(fixed_queue_t* queue, void* /* context */) { +static void callback_sequential_queue(fixed_queue_t* queue, void* /* context */) { bluetooth::log::assert_that(queue != nullptr, "assert failed: queue != nullptr"); fixed_queue_dequeue(queue); g_counter_promise->set_value(); } -void callback_batch(fixed_queue_t* queue, void* /* data */) { +static void callback_batch(fixed_queue_t* queue, void* /* data */) { bluetooth::log::assert_that(queue != nullptr, "assert failed: queue != nullptr"); fixed_queue_dequeue(queue); g_counter++; diff --git a/system/common/metric_id_allocator_unittest.cc b/system/common/metric_id_allocator_unittest.cc index 778163c62d..8172d57319 100644 --- a/system/common/metric_id_allocator_unittest.cc +++ b/system/common/metric_id_allocator_unittest.cc @@ -25,14 +25,11 @@ #include "types/raw_address.h" -// TODO(b/369381361) Enfore -Wmissing-prototypes -#pragma GCC diagnostic ignored "-Wmissing-prototypes" - namespace testing { using bluetooth::common::MetricIdAllocator; -RawAddress kthAddress(uint32_t k) { +static RawAddress 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; @@ -42,7 +39,7 @@ RawAddress kthAddress(uint32_t k) { return addr; } -std::unordered_map<RawAddress, int> generateAddresses(const uint32_t num) { +static std::unordered_map<RawAddress, 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<RawAddress, int> device_map; diff --git a/system/common/metrics_linux.cc b/system/common/metrics_linux.cc index bbd411b11e..009d16878e 100644 --- a/system/common/metrics_linux.cc +++ b/system/common/metrics_linux.cc @@ -21,9 +21,6 @@ #include "common/metrics.h" #include "types/raw_address.h" -// TODO(b/369381361) Enfore -Wmissing-prototypes -#pragma GCC diagnostic ignored "-Wmissing-prototypes" - namespace bluetooth { namespace common { @@ -134,10 +131,11 @@ void LogLinkLayerConnectionEvent(const RawAddress* /* address */, uint32_t /* co uint16_t /* cmd_status */, uint16_t /* reason_code */) {} void LogManufacturerInfo(const RawAddress& /* address */, + android::bluetooth::AddressTypeEnum /* address_type */, android::bluetooth::DeviceInfoSrcEnum /* source_type */, const std::string& /* source_name */, - /* const */ std::string& /* manufacturer */, - const std::string& /* model */, const std::string& /* hardware_version */, + const std::string& /* manufacturer */, const std::string& /* model */, + const std::string& /* hardware_version */, const std::string& /* software_version */) {} void LogSdpAttribute(const RawAddress& /* address */, uint16_t /* protocol_uuid */, diff --git a/system/common/metrics_unittest.cc b/system/common/metrics_unittest.cc index 86e2ec7a13..4bbabb242a 100644 --- a/system/common/metrics_unittest.cc +++ b/system/common/metrics_unittest.cc @@ -32,9 +32,6 @@ #define BTM_COD_MAJOR_AUDIO_TEST 0x04 -// TODO(b/369381361) Enfore -Wmissing-prototypes -#pragma GCC diagnostic ignored "-Wmissing-prototypes" - namespace testing { using bluetooth::common::A2dpSessionMetrics; @@ -63,14 +60,15 @@ const size_t kMaxEventGenerationLimit = 5000; static void sleep_ms(int64_t t) { std::this_thread::sleep_for(std::chrono::milliseconds(t)); } -DeviceInfo* MakeDeviceInfo(int32_t device_class, DeviceInfo_DeviceType device_type) { +static DeviceInfo* MakeDeviceInfo(int32_t device_class, DeviceInfo_DeviceType device_type) { DeviceInfo* info = new DeviceInfo(); info->set_device_class(device_class); info->set_device_type(device_type); return info; } -PairEvent* MakePairEvent(int32_t disconnect_reason, int64_t timestamp_ms, DeviceInfo* device_info) { +static PairEvent* MakePairEvent(int32_t disconnect_reason, int64_t timestamp_ms, + DeviceInfo* device_info) { PairEvent* event = new PairEvent(); event->set_disconnect_reason(disconnect_reason); event->set_event_time_millis(timestamp_ms); @@ -80,8 +78,8 @@ PairEvent* MakePairEvent(int32_t disconnect_reason, int64_t timestamp_ms, Device return event; } -WakeEvent* MakeWakeEvent(WakeEvent_WakeEventType event_type, const std::string& requestor, - const std::string& name, int64_t timestamp_ms) { +static WakeEvent* MakeWakeEvent(WakeEvent_WakeEventType event_type, const std::string& requestor, + const std::string& name, int64_t timestamp_ms) { WakeEvent* event = new WakeEvent(); event->set_wake_event_type(event_type); event->set_requestor(requestor); @@ -90,9 +88,9 @@ WakeEvent* MakeWakeEvent(WakeEvent_WakeEventType event_type, const std::string& return event; } -ScanEvent* MakeScanEvent(ScanEvent_ScanEventType event_type, const std::string& initiator, - ScanEvent_ScanTechnologyType tech_type, int32_t num_results, - int64_t timestamp_ms) { +static ScanEvent* MakeScanEvent(ScanEvent_ScanEventType event_type, const std::string& initiator, + ScanEvent_ScanTechnologyType tech_type, int32_t num_results, + int64_t timestamp_ms) { ScanEvent* event = new ScanEvent(); event->set_scan_event_type(event_type); event->set_initiator(initiator); @@ -102,7 +100,8 @@ ScanEvent* MakeScanEvent(ScanEvent_ScanEventType event_type, const std::string& return event; } -A2DPSession* MakeA2DPSession(const A2dpSessionMetrics& metrics, A2dpSourceCodec source_codec) { +static A2DPSession* MakeA2DPSession(const A2dpSessionMetrics& metrics, + A2dpSourceCodec source_codec) { A2DPSession* session = new A2DPSession(); session->set_media_timer_min_millis(metrics.media_timer_min_ms); session->set_media_timer_max_millis(metrics.media_timer_max_ms); @@ -117,11 +116,10 @@ A2DPSession* MakeA2DPSession(const A2dpSessionMetrics& metrics, A2dpSourceCodec return session; } -BluetoothSession* MakeBluetoothSession(int64_t session_duration_sec, - BluetoothSession_ConnectionTechnologyType conn_type, - BluetoothSession_DisconnectReasonType disconnect_reason, - DeviceInfo* device_info, RFCommSession* rfcomm_session, - A2DPSession* a2dp_session) { +static BluetoothSession* MakeBluetoothSession( + int64_t session_duration_sec, BluetoothSession_ConnectionTechnologyType conn_type, + BluetoothSession_DisconnectReasonType disconnect_reason, DeviceInfo* device_info, + RFCommSession* rfcomm_session, A2DPSession* a2dp_session) { BluetoothSession* session = new BluetoothSession(); if (a2dp_session) { session->set_allocated_a2dp_session(a2dp_session); @@ -138,31 +136,7 @@ BluetoothSession* MakeBluetoothSession(int64_t session_duration_sec, return session; } -BluetoothLog* MakeBluetoothLog(std::vector<BluetoothSession*> bt_sessions, - std::vector<PairEvent*> pair_events, - std::vector<WakeEvent*> wake_events, - std::vector<ScanEvent*> scan_events) { - BluetoothLog* bt_log = new BluetoothLog(); - for (BluetoothSession* session : bt_sessions) { - bt_log->mutable_session()->AddAllocated(session); - } - bt_sessions.clear(); - for (PairEvent* event : pair_events) { - bt_log->mutable_pair_event()->AddAllocated(event); - } - pair_events.clear(); - for (WakeEvent* event : wake_events) { - bt_log->mutable_wake_event()->AddAllocated(event); - } - wake_events.clear(); - for (ScanEvent* event : scan_events) { - bt_log->mutable_scan_event()->AddAllocated(event); - } - scan_events.clear(); - return bt_log; -} - -void GenerateWakeEvents(size_t start, size_t end, std::vector<WakeEvent*>* wake_events) { +static void GenerateWakeEvents(size_t start, size_t end, std::vector<WakeEvent*>* wake_events) { for (size_t i = start; i < end; ++i) { wake_events->push_back( MakeWakeEvent(i % 2 == 0 ? WakeEvent_WakeEventType::WakeEvent_WakeEventType_ACQUIRED diff --git a/system/common/os_utils.cc b/system/common/os_utils.cc index a4bf8ea314..cdd645bf6f 100644 --- a/system/common/os_utils.cc +++ b/system/common/os_utils.cc @@ -14,14 +14,13 @@ * limitations under the License. */ +#include "common/os_utils.h" + #ifdef __ANDROID__ #include <private/android_filesystem_config.h> #include <unistd.h> #endif -// TODO(b/369381361) Enfore -Wmissing-prototypes -#pragma GCC diagnostic ignored "-Wmissing-prototypes" - bool is_bluetooth_uid() { #ifdef __ANDROID__ return getuid() == AID_BLUETOOTH; diff --git a/system/common/test/thread_performance_test.cc b/system/common/test/thread_performance_test.cc index d6a0ea32ec..f875cd6aa6 100644 --- a/system/common/test/thread_performance_test.cc +++ b/system/common/test/thread_performance_test.cc @@ -31,9 +31,6 @@ #include "osi/include/fixed_queue.h" #include "osi/include/thread.h" -// TODO(b/369381361) Enfore -Wmissing-prototypes -#pragma GCC diagnostic ignored "-Wmissing-prototypes" - using bluetooth::common::MessageLoopThread; using namespace bluetooth; @@ -42,7 +39,7 @@ using namespace bluetooth; static int g_counter = 0; static std::unique_ptr<std::promise<void>> g_counter_promise = nullptr; -void callback_batch(fixed_queue_t* queue, void* /* data */) { +static void callback_batch(fixed_queue_t* queue, void* /* data */) { if (queue != nullptr) { fixed_queue_dequeue(queue); } |