diff options
author | 2024-11-07 20:12:12 -0800 | |
---|---|---|
committer | 2024-11-20 17:50:26 -0800 | |
commit | c4611d04b29b74a2d9316a0ae195fe496a4e6d01 (patch) | |
tree | 824fcb2dd6ecab2f88ef3fe9fb5cf39d8b8d093c | |
parent | b760df280c1b0313bf1c1360f4f7538a1568d2f4 (diff) |
cpplint: fix the majority of runtime/int
Bug: 364967694
Test: m .
Flag: Exempt refactor
Change-Id: Ib5032eb381e02bec011c756237069c22e64c609c
59 files changed, 140 insertions, 170 deletions
diff --git a/android/app/jni/com_android_bluetooth_gatt.cpp b/android/app/jni/com_android_bluetooth_gatt.cpp index 9bde897040..7f47be6e82 100644 --- a/android/app/jni/com_android_bluetooth_gatt.cpp +++ b/android/app/jni/com_android_bluetooth_gatt.cpp @@ -1244,7 +1244,7 @@ public: void OnDistanceMeasurementResult(RawAddress address, uint32_t centimeter, uint32_t error_centimeter, int azimuth_angle, int error_azimuth_angle, int altitude_angle, - int error_altitude_angle, long elapsedRealtimeNanos, + int error_altitude_angle, uint64_t elapsedRealtimeNanos, int8_t confidence_level, uint8_t method) { std::shared_lock<std::shared_mutex> lock(callbacks_mutex); CallbackEnv sCallbackEnv(__func__); diff --git a/system/bta/ag/bta_ag_cmd.cc b/system/bta/ag/bta_ag_cmd.cc index af1df17cea..cdea95029b 100644 --- a/system/bta/ag/bta_ag_cmd.cc +++ b/system/bta/ag/bta_ag_cmd.cc @@ -616,7 +616,7 @@ void bta_ag_at_hsp_cback(tBTA_AG_SCB* p_scb, uint16_t command_id, uint8_t arg_ty val.hdr.app_id = p_scb->app_id; val.num = (uint16_t)int_arg; - if ((p_end - p_arg + 1) >= (long)sizeof(val.str)) { + if ((p_end - p_arg + 1) >= (ptrdiff_t)sizeof(val.str)) { log::error("p_arg is too long, send error and return"); bta_ag_send_error(p_scb, BTA_AG_ERR_TEXT_TOO_LONG); return; @@ -894,7 +894,7 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB* p_scb, uint16_t cmd, uint8_t arg_type, cha val.num = static_cast<uint32_t>(int_arg); val.bd_addr = p_scb->peer_addr; - if ((p_end - p_arg + 1) >= (long)sizeof(val.str)) { + if ((p_end - p_arg + 1) >= (ptrdiff_t)sizeof(val.str)) { log::error("p_arg is too long for cmd 0x{:x}, send error and return", cmd); bta_ag_send_error(p_scb, BTA_AG_ERR_TEXT_TOO_LONG); return; diff --git a/system/bta/dm/bta_dm_act.cc b/system/bta/dm/bta_dm_act.cc index 792aa44b6e..ec3ca882bc 100644 --- a/system/bta/dm/bta_dm_act.cc +++ b/system/bta/dm/bta_dm_act.cc @@ -125,7 +125,7 @@ namespace { struct WaitForAllAclConnectionsToDrain { uint64_t time_to_wait_in_ms; - unsigned long TimeToWaitInMs() const { return static_cast<unsigned long>(time_to_wait_in_ms); } + uint64_t TimeToWaitInMs() const { return time_to_wait_in_ms; } void* AlarmCallbackData() const { return const_cast<void*>(static_cast<const void*>(this)); } static const WaitForAllAclConnectionsToDrain* FromAlarmCallbackData(void* data); @@ -339,8 +339,7 @@ void bta_dm_disable() { bta_dm_disable_conn_down_timer_cback(nullptr); break; default: - log::debug("Set timer to delay disable initiation:{} ms", - static_cast<unsigned long>(disable_delay_ms)); + log::debug("Set timer to delay disable initiation:{} ms", disable_delay_ms); alarm_set_on_mloop(bta_dm_cb.disable_timer, disable_delay_ms, bta_dm_disable_conn_down_timer_cback, nullptr); } diff --git a/system/bta/dm/bta_dm_cfg.cc b/system/bta/dm/bta_dm_cfg.cc index aa9dc6bea3..1b811ddebe 100644 --- a/system/bta/dm/bta_dm_cfg.cc +++ b/system/bta/dm/bta_dm_cfg.cc @@ -486,8 +486,7 @@ tBTA_DM_SSR_SPEC bta_dm_ssr_spec[] = { default max latency and min remote timeout as 0, and always read individual device preference from HH module */ {0, 0, 2, "hid_host"}, - {1200, 2, 2, "sniff_capable"}, /* BTA_DM_PM_SSR2 - others (as long as sniff - is allowed)*/ + {1200, 2, 2, "sniff_capable"}, /* BTA_DM_PM_SSR2 - others (only if sniff is allowed) */ {360, 160, 1600, "hid_device"}, /* BTA_DM_PM_SSR3 - HD */ {1200, 65534, 65534, "a2dp"} /* BTA_DM_PM_SSR4 - A2DP streaming */ }; diff --git a/system/bta/dm/bta_dm_device_search.cc b/system/bta/dm/bta_dm_device_search.cc index 7c2c30e3e6..6f5691d050 100644 --- a/system/bta/dm/bta_dm_device_search.cc +++ b/system/bta/dm/bta_dm_device_search.cc @@ -749,7 +749,7 @@ constexpr size_t kSearchStateHistorySize = 50; constexpr char kTimeFormatString[] = "%Y-%m-%d %H:%M:%S"; constexpr unsigned MillisPerSecond = 1000; -std::string EpochMillisToString(long long time_ms) { +std::string EpochMillisToString(uint64_t time_ms) { time_t time_sec = time_ms / MillisPerSecond; struct tm tm; localtime_r(&time_sec, &tm); diff --git a/system/bta/dm/bta_dm_disc.cc b/system/bta/dm/bta_dm_disc.cc index 455309e60a..f5d59d10de 100644 --- a/system/bta/dm/bta_dm_disc.cc +++ b/system/bta/dm/bta_dm_disc.cc @@ -730,7 +730,7 @@ namespace { constexpr char kTimeFormatString[] = "%Y-%m-%d %H:%M:%S"; constexpr unsigned MillisPerSecond = 1000; -std::string EpochMillisToString(long long time_ms) { +std::string EpochMillisToString(uint64_t time_ms) { time_t time_sec = time_ms / MillisPerSecond; struct tm tm; localtime_r(&time_sec, &tm); diff --git a/system/bta/dm/bta_dm_gatt_client.cc b/system/bta/dm/bta_dm_gatt_client.cc index 189b367e9c..3963f4b225 100644 --- a/system/bta/dm/bta_dm_gatt_client.cc +++ b/system/bta/dm/bta_dm_gatt_client.cc @@ -39,7 +39,7 @@ TimestampedStringCircularBuffer gatt_history_{50}; constexpr char kTimeFormatString[] = "%Y-%m-%d %H:%M:%S"; constexpr unsigned MillisPerSecond = 1000; -std::string EpochMillisToString(long long time_ms) { +std::string EpochMillisToString(uint64_t time_ms) { time_t time_sec = time_ms / MillisPerSecond; struct tm tm; localtime_r(&time_sec, &tm); diff --git a/system/bta/gatt/bta_gattc_db_storage.cc b/system/bta/gatt/bta_gattc_db_storage.cc index 34beb0852c..cc0af3ce87 100644 --- a/system/bta/gatt/bta_gattc_db_storage.cc +++ b/system/bta/gatt/bta_gattc_db_storage.cc @@ -414,8 +414,8 @@ static void bta_gattc_hash_remove_least_recently_used_if_possible() { struct stat buf; int result = lstat(tmp, &buf); - log::debug("name={}, result={}, linknum={}, mtime={}", dp->d_name, result, - (unsigned long)buf.st_nlink, (unsigned long)buf.st_mtime); + log::debug("name={}, result={}, linknum={}, mtime={}", dp->d_name, result, buf.st_nlink, + buf.st_mtime); // if hard link count of the file is 1, it means no trusted device links to // the inode. It is safe to be a candidate to be removed @@ -434,7 +434,7 @@ static void bta_gattc_hash_remove_least_recently_used_if_possible() { } log::debug("<-----------End Local Hash Cache------------>"); - // if the number of hash files exceeds the limit, remove the cadidate item. + // if the number of hash files exceeds the limit, remove the candidate item. if (count > GATT_HASH_MAX_SIZE && !candidate_item.empty()) { unlink(candidate_item.c_str()); log::debug("delete hash file (size), name={}", candidate_item); diff --git a/system/bta/hearing_aid/hearing_aid_audio_source.cc b/system/bta/hearing_aid/hearing_aid_audio_source.cc index d1d45d5407..65036b1c74 100644 --- a/system/bta/hearing_aid/hearing_aid_audio_source.cc +++ b/system/bta/hearing_aid/hearing_aid_audio_source.cc @@ -437,7 +437,7 @@ void HearingAidAudioSource::DebugDump(int fd) { << stats.media_read_total_underflow_bytes << "\n Last update time ago in ms (underflow) : " << (stats.media_read_last_underflow_us > 0 - ? (unsigned long long)(now_us - stats.media_read_last_underflow_us) / 1000 + ? (now_us - stats.media_read_last_underflow_us) / 1000 : 0) << std::endl; dprintf(fd, "%s", stream.str().c_str()); diff --git a/system/bta/include/bta_api.h b/system/bta/include/bta_api.h index a0b9e2c32f..90f1508c50 100644 --- a/system/bta/include/bta_api.h +++ b/system/bta/include/bta_api.h @@ -135,7 +135,7 @@ enum { another connection in central role */ BTA_DM_PARTIAL_SCATTERNET, /* Device supports partial scatternet. It can have simultaneous connection in Central and - Peripheral roles for short period of time */ + Peripheral roles for small period of time */ BTA_DM_FULL_SCATTERNET /* Device can have simultaneous connection in central and peripheral roles */ }; @@ -159,7 +159,7 @@ typedef uint8_t tBTA_DM_BLE_RSSI_ALERT_TYPE; typedef enum : uint8_t { BTA_DM_LINK_UP_EVT = 5, /* Connection UP event */ BTA_DM_LINK_DOWN_EVT = 6, /* Connection DOWN event */ - BTA_DM_LE_FEATURES_READ = 27, /* Cotroller specific LE features are read */ + BTA_DM_LE_FEATURES_READ = 27, /* Controller specific LE features are read */ BTA_DM_LINK_UP_FAILED_EVT = 34, /* Create connection failed event */ } tBTA_DM_ACL_EVT; diff --git a/system/bta/le_audio/audio_hal_client/audio_source_hal_client.cc b/system/bta/le_audio/audio_hal_client/audio_source_hal_client.cc index 475044af90..58e2bb08c1 100644 --- a/system/bta/le_audio/audio_hal_client/audio_source_hal_client.cc +++ b/system/bta/le_audio/audio_hal_client/audio_source_hal_client.cc @@ -520,7 +520,7 @@ std::unique_ptr<LeAudioSourceAudioHalClient> LeAudioSourceAudioHalClient::Acquir std::unique_ptr<LeAudioSourceAudioHalClient> LeAudioSourceAudioHalClient::AcquireBroadcast() { std::unique_ptr<SourceImpl> impl(new SourceImpl(true)); if (!impl->Acquire()) { - log::error("Could not acquire Broadcast Source on LE Audio HAL enpoint"); + log::error("Could not acquire Broadcast Source on LE Audio HAL endpoint"); impl.reset(); return nullptr; } @@ -539,7 +539,7 @@ void LeAudioSourceAudioHalClient::DebugDump(int fd) { << sStats.media_read_total_underflow_bytes << "\n Last update time ago in ms (underflow) : " << (sStats.media_read_last_underflow_us > 0 - ? (unsigned long long)(now_us - sStats.media_read_last_underflow_us) / 1000 + ? (now_us - sStats.media_read_last_underflow_us) / 1000 : 0) << std::endl; dprintf(fd, "%s", stream.str().c_str()); diff --git a/system/bta/le_audio/broadcaster/broadcaster_test.cc b/system/bta/le_audio/broadcaster/broadcaster_test.cc index 63b708039e..b7d3d3223a 100644 --- a/system/bta/le_audio/broadcaster/broadcaster_test.cc +++ b/system/bta/le_audio/broadcaster/broadcaster_test.cc @@ -1008,8 +1008,8 @@ TEST_F(BroadcasterTest, StreamParamsMedia) { ASSERT_EQ(config.config.subgroups.at(0).GetNumBis(), expected_channels); ASSERT_EQ(config.config.subgroups.at(0).GetNumChannelsTotal(), expected_channels); // Note there is one BIS configuration applied to both (stereo) BISes - ASSERT_EQ(config.config.subgroups.at(0).GetAllBisConfigCount(), (unsigned long)1); - ASSERT_EQ(config.config.subgroups.at(0).GetNumBis(0), (unsigned long)expected_channels); + ASSERT_EQ(config.config.subgroups.at(0).GetAllBisConfigCount(), 1u); + ASSERT_EQ(config.config.subgroups.at(0).GetNumBis(0), expected_channels); // Matches number of bises in the announcement ASSERT_EQ(config.announcement.subgroup_configs.size(), 1ul); diff --git a/system/bta/le_audio/client.cc b/system/bta/le_audio/client.cc index 8d5fbb1a24..320308077b 100644 --- a/system/bta/le_audio/client.cc +++ b/system/bta/le_audio/client.cc @@ -377,7 +377,7 @@ public: } static const uint64_t timeoutMs = 2000; - log::debug("Start VBC close timeout with {} ms", static_cast<unsigned long>(timeoutMs)); + log::debug("Start VBC close timeout with {} ms", timeoutMs); alarm_set_on_mloop( close_vbc_timeout_, timeoutMs, diff --git a/system/bta/le_audio/le_audio_client_test.cc b/system/bta/le_audio/le_audio_client_test.cc index 2c7ecbb7e9..74e91bfea9 100644 --- a/system/bta/le_audio/le_audio_client_test.cc +++ b/system/bta/le_audio/le_audio_client_test.cc @@ -12557,7 +12557,7 @@ TEST_F(UnicastTest, NoContextvalidateStreamingRequest) { Mock::VerifyAndClearExpectations(&mock_audio_hal_client_callbacks_); SyncOnMainLoop(); - // Stop streaming and expect Service to be informed about straming suspension + // Stop streaming and expect Service to be informed about streaming suspension EXPECT_CALL(mock_audio_hal_client_callbacks_, OnUnicastMonitorModeStatus( bluetooth::le_audio::types::kLeAudioDirectionSource, @@ -12581,10 +12581,10 @@ TEST_F(UnicastTest, CodecFrameBlocks2) { std::list<MockCodecInterface*> codec_mocks; MockCodecInterface::RegisterMockInstanceHook([&](MockCodecInterface* mock, bool is_destroyed) { if (is_destroyed) { - log::debug("Codec Interface Destroyed: {}", (long)mock); + log::debug("Codec Interface Destroyed: {}", std::format_ptr(mock)); codec_mocks.remove(mock); } else { - log::debug("Codec Interface Created: {}", (long)mock); + log::debug("Codec Interface Created: {}", std::format_ptr(mock)); ON_CALL(*mock, GetNumOfSamplesPerChannel()).WillByDefault(Return(960)); ON_CALL(*mock, GetNumOfBytesPerSample()).WillByDefault(Return(2)); // 16bits samples ON_CALL(*mock, Encode(_, _, _, _, _)) diff --git a/system/btif/include/btif_pan_internal.h b/system/btif/include/btif_pan_internal.h index a9aa42795d..f338102ad5 100644 --- a/system/btif/include/btif_pan_internal.h +++ b/system/btif/include/btif_pan_internal.h @@ -52,7 +52,7 @@ typedef struct eth_hdr { RawAddress h_dest; RawAddress h_src; - short h_proto; + int16_t h_proto; } tETH_HDR; typedef struct { diff --git a/system/btif/src/btif_a2dp_source.cc b/system/btif/src/btif_a2dp_source.cc index 7ebe304fec..aa512d1f16 100644 --- a/system/btif/src/btif_a2dp_source.cc +++ b/system/btif/src/btif_a2dp_source.cc @@ -1155,15 +1155,11 @@ void btif_a2dp_source_debug_dump(int fd) { dprintf(fd, "\nA2DP State:\n"); dprintf(fd, " TxQueue:\n"); - dprintf(fd, - " Counts (enqueue/dequeue/readbuf) : %zu / " - "%zu / %zu\n", + dprintf(fd, " Counts (enqueue/dequeue/readbuf) : %zu / %zu / %zu\n", enqueue_stats->total_updates, dequeue_stats->total_updates, accumulated_stats->tx_queue_total_readbuf_calls); - dprintf(fd, - " Last update time ago in ms (enqueue/dequeue/readbuf) : %llu / %llu " - "/ %llu\n", + dprintf(fd, " Last update time ago in ms (enqueue/dequeue/readbuf) : %llu / %llu / %llu\n", (enqueue_stats->last_update_us > 0) ? (unsigned long long)(now_us - enqueue_stats->last_update_us) / 1000 : 0, @@ -1179,24 +1175,18 @@ void btif_a2dp_source_debug_dump(int fd) { if (enqueue_stats->total_updates != 0) { ave_size = accumulated_stats->tx_queue_total_frames / enqueue_stats->total_updates; } - dprintf(fd, - " Frames per packet (total/max/ave) : %zu / " - "%zu / %zu\n", + dprintf(fd, " Frames per packet (total/max/ave) : %zu / %zu / %zu\n", accumulated_stats->tx_queue_total_frames, accumulated_stats->tx_queue_max_frames_per_packet, ave_size); - dprintf(fd, - " Counts (flushed/dropped/dropouts) : %zu / " - "%zu / %zu\n", + dprintf(fd, " Counts (flushed/dropped/dropouts) : %zu / %zu / %zu\n", accumulated_stats->tx_queue_total_flushed_messages, accumulated_stats->tx_queue_total_dropped_messages, accumulated_stats->tx_queue_dropouts); dprintf(fd, " Counts (max dropped) : %zu\n", accumulated_stats->tx_queue_max_dropped_messages); - dprintf(fd, - " Last update time ago in ms (flushed/dropped) : %llu / " - "%llu\n", + dprintf(fd, " Last update time ago in ms (flushed/dropped) : %llu / %llu\n", (accumulated_stats->tx_queue_last_flushed_us > 0) ? (unsigned long long)(now_us - accumulated_stats->tx_queue_last_flushed_us) / 1000 @@ -1229,9 +1219,7 @@ void btif_a2dp_source_debug_dump(int fd) { ave_time_us = enqueue_stats->total_overdue_scheduling_delta_us / enqueue_stats->overdue_scheduling_count; } - dprintf(fd, - " Enqueue overdue scheduling time in ms (total/max/ave) : %llu / %llu " - "/ %llu\n", + dprintf(fd, " Enqueue overdue scheduling time in ms (total/max/ave) : %llu / %llu / %llu\n", (unsigned long long)enqueue_stats->total_overdue_scheduling_delta_us / 1000, (unsigned long long)enqueue_stats->max_overdue_scheduling_delta_us / 1000, (unsigned long long)ave_time_us / 1000); @@ -1241,9 +1229,7 @@ void btif_a2dp_source_debug_dump(int fd) { ave_time_us = enqueue_stats->total_premature_scheduling_delta_us / enqueue_stats->premature_scheduling_count; } - dprintf(fd, - " Enqueue premature scheduling time in ms (total/max/ave) : %llu / %llu " - "/ %llu\n", + dprintf(fd, " Enqueue premature scheduling time in ms (total/max/ave) : %llu / %llu / %llu\n", (unsigned long long)enqueue_stats->total_premature_scheduling_delta_us / 1000, (unsigned long long)enqueue_stats->max_premature_scheduling_delta_us / 1000, (unsigned long long)ave_time_us / 1000); @@ -1259,9 +1245,7 @@ void btif_a2dp_source_debug_dump(int fd) { ave_time_us = dequeue_stats->total_overdue_scheduling_delta_us / dequeue_stats->overdue_scheduling_count; } - dprintf(fd, - " Dequeue overdue scheduling time in ms (total/max/ave) : %llu / %llu " - "/ %llu\n", + dprintf(fd, " Dequeue overdue scheduling time in ms (total/max/ave) : %llu / %llu / %llu\n", (unsigned long long)dequeue_stats->total_overdue_scheduling_delta_us / 1000, (unsigned long long)dequeue_stats->max_overdue_scheduling_delta_us / 1000, (unsigned long long)ave_time_us / 1000); @@ -1271,9 +1255,7 @@ void btif_a2dp_source_debug_dump(int fd) { ave_time_us = dequeue_stats->total_premature_scheduling_delta_us / dequeue_stats->premature_scheduling_count; } - dprintf(fd, - " Dequeue premature scheduling time in ms (total/max/ave) : %llu / %llu " - "/ %llu\n", + dprintf(fd, " Dequeue premature scheduling time in ms (total/max/ave) : %llu / %llu / %llu\n", (unsigned long long)dequeue_stats->total_premature_scheduling_delta_us / 1000, (unsigned long long)dequeue_stats->max_premature_scheduling_delta_us / 1000, (unsigned long long)ave_time_us / 1000); diff --git a/system/device/test/interop_test.cc b/system/device/test/interop_test.cc index 88ff853ca5..707a7b0972 100644 --- a/system/device/test/interop_test.cc +++ b/system/device/test/interop_test.cc @@ -75,7 +75,7 @@ CK87BT = Name_Based \n\ # Some HID devices have problematic behaviour where when hid link is in Sniff \n\ # and DUT is in Peripheral role for SCO link ( not eSCO) any solution cannot maintain \n\ -# the link as SCO scheduling over a short period will overlap with Sniff link due to \n\ +# the link as SCO scheduling over a small period will overlap with Sniff link due to \n\ # peripheral drift. \n\ # To avoid degrading the user experience with those devices, sniff is disabled from \n\ # link policy when sco is active, and enabled when sco is disabled. \n\ @@ -85,7 +85,7 @@ CK87BT = Name_Based \n\ # Devices requiring this workaround do not handle SSR max latency values as mentioned, \n\ # in their SDP HID Record properly and lead to connection timeout or lags. To prevent \n\ -# such scenarios, device requiring this workaorund need to use specific ssr max latency \n\ +# such scenarios, device requiring this workaround need to use specific ssr max latency \n\ # values. \n\ [INTEROP_UPDATE_HID_SSR_MAX_LAT] \n\ 00:1B:DC-0x0012 = SSR_Max_Lat_Based \n\ diff --git a/system/embdrv/encoder_for_aptx/include/aptXbtenc.h b/system/embdrv/encoder_for_aptx/include/aptXbtenc.h index d42bb4fc44..0e6ebbe502 100644 --- a/system/embdrv/encoder_for_aptx/include/aptXbtenc.h +++ b/system/embdrv/encoder_for_aptx/include/aptXbtenc.h @@ -50,7 +50,7 @@ APTXBTENCEXPORT const char* aptxbtenc_version(void); * (0=little endian. Big endian otherwise) * The function returns 1 if an error occurred during the initialisation. * The function returns 0 if no error occurred during the initialisation. */ -APTXBTENCEXPORT int aptxbtenc_init(void* _state, short endian); +APTXBTENCEXPORT int aptxbtenc_init(void* _state, int16_t endian); /* aptxbtenc_setsync_mode is used to initialise the sync mode in the encoder * state structure. _state should be a pointer to the encoder structure (stereo, diff --git a/system/embdrv/encoder_for_aptxhd/include/aptXHDbtenc.h b/system/embdrv/encoder_for_aptxhd/include/aptXHDbtenc.h index dc7a305ec4..3397461a11 100644 --- a/system/embdrv/encoder_for_aptxhd/include/aptXHDbtenc.h +++ b/system/embdrv/encoder_for_aptxhd/include/aptXHDbtenc.h @@ -24,6 +24,8 @@ #ifndef APTXHDBTENC_H #define APTXHDBTENC_H +#include <stdint.h> + #ifdef __cplusplus extern "C" { #endif @@ -48,7 +50,7 @@ APTXHDBTENCEXPORT const char* aptxhdbtenc_version(void); * (0=little endian. Big endian otherwise) * The function returns 1 if an error occurred during the initialisation. * The function returns 0 if no error occurred during the initialisation. */ -APTXHDBTENCEXPORT int aptxhdbtenc_init(void* _state, short endian); +APTXHDBTENCEXPORT int aptxhdbtenc_init(void* _state, int16_t endian); /* StereoEncode will take 8 audio samples (24-bit per sample) * and generate two 24-bit codeword with autosync inserted. diff --git a/system/embdrv/sbc/decoder/include/oi_status.h b/system/embdrv/sbc/decoder/include/oi_status.h index b91809f564..e3fa8ea700 100644 --- a/system/embdrv/sbc/decoder/include/oi_status.h +++ b/system/embdrv/sbc/decoder/include/oi_status.h @@ -408,7 +408,7 @@ typedef enum { OI_SECMGR_DISCONNECTED_FAIL = 1408, /**< SECMGR: l2cap access denied - disconnected */ OI_SECMGR_ACCESS_PENDING = 1409, /**< SECMGR: l2cap access request is still pending */ OI_SECMGR_PIN_CODE_TOO_SHORT = 1410, /**< SECMGR: Higher-layer process gave us - a pin code that is too short */ + a pin code that is too small */ OI_SECMGR_UNKNOWN_ENCRYPT_VALUE = 1411, /**< SECMGR: got EncryptionChange event, unknown encryption enable value */ diff --git a/system/gd/common/circular_buffer.h b/system/gd/common/circular_buffer.h index b008d5edda..6132f2e51c 100644 --- a/system/gd/common/circular_buffer.h +++ b/system/gd/common/circular_buffer.h @@ -46,13 +46,13 @@ private: class Timestamper { public: - virtual long long GetTimestamp() const = 0; + virtual uint64_t GetTimestamp() const = 0; virtual ~Timestamper() {} }; class TimestamperInMilliseconds : public Timestamper { public: - long long GetTimestamp() const override { + uint64_t GetTimestamp() const override { return std::chrono::duration_cast<std::chrono::milliseconds>( std::chrono::system_clock::now().time_since_epoch()) .count(); @@ -62,7 +62,7 @@ public: template <typename T> struct TimestampedEntry { - long long timestamp; + uint64_t timestamp; T entry; }; diff --git a/system/gd/common/circular_buffer_test.cc b/system/gd/common/circular_buffer_test.cc index e35a60c98e..618388858b 100644 --- a/system/gd/common/circular_buffer_test.cc +++ b/system/gd/common/circular_buffer_test.cc @@ -24,9 +24,9 @@ namespace testing { -long long timestamp_{0}; +uint64_t timestamp_{0}; struct TestTimestamper : public bluetooth::common::Timestamper { - virtual long long GetTimestamp() const override { return timestamp_++; } + virtual uint64_t GetTimestamp() const override { return timestamp_++; } }; TEST(CircularBufferTest, simple) { @@ -75,7 +75,7 @@ TEST(CircularBufferTest, test_timestamps) { buffer.Push(std::string("Three")); auto vec = buffer.Pull(); - long long timestamp = 0; + uint64_t timestamp = 0; for (auto v : vec) { ASSERT_EQ(timestamp, v.timestamp); timestamp++; diff --git a/system/gd/hci/distance_measurement_manager.cc b/system/gd/hci/distance_measurement_manager.cc index fd15f66b0d..dd1128868f 100644 --- a/system/gd/hci/distance_measurement_manager.cc +++ b/system/gd/hci/distance_measurement_manager.cc @@ -269,7 +269,7 @@ struct DistanceMeasurementManager::impl : bluetooth::hal::RangingHalCallback { log::debug("address {}, resultMeters {}", cs_requester_trackers_[connection_handle].address, ranging_result.result_meters_); using namespace std::chrono; - long elapsedRealtimeNanos = + uint64_t elapsedRealtimeNanos = duration_cast<nanoseconds>(steady_clock::now().time_since_epoch()).count(); distance_measurement_callbacks_->OnDistanceMeasurementResult( cs_requester_trackers_[connection_handle].address, ranging_result.result_meters_ * 100, @@ -2179,7 +2179,7 @@ struct DistanceMeasurementManager::impl : bluetooth::hal::RangingHalCallback { double distance = pow(10.0, pow_value); using namespace std::chrono; - long elapsedRealtimeNanos = + uint64_t elapsedRealtimeNanos = duration_cast<nanoseconds>(steady_clock::now().time_since_epoch()).count(); distance_measurement_callbacks_->OnDistanceMeasurementResult( address, distance * 100, distance * 100, -1, -1, -1, -1, elapsedRealtimeNanos, -1, diff --git a/system/gd/hci/distance_measurement_manager.h b/system/gd/hci/distance_measurement_manager.h index 93f0f5ab20..d5dc393b0c 100644 --- a/system/gd/hci/distance_measurement_manager.h +++ b/system/gd/hci/distance_measurement_manager.h @@ -58,7 +58,7 @@ public: virtual void OnDistanceMeasurementResult(Address address, uint32_t centimeter, uint32_t error_centimeter, int azimuth_angle, int error_azimuth_angle, int altitude_angle, - int error_altitude_angle, long elapsedRealtimeNanos, + int error_altitude_angle, uint64_t elapsedRealtimeNanos, int8_t confidence_level, DistanceMeasurementMethod method) = 0; virtual void OnRasFragmentReady(Address address, uint16_t procedure_counter, bool is_last, diff --git a/system/gd/hci/distance_measurement_manager_mock.h b/system/gd/hci/distance_measurement_manager_mock.h index 0f71c51c33..0aef34d2af 100644 --- a/system/gd/hci/distance_measurement_manager_mock.h +++ b/system/gd/hci/distance_measurement_manager_mock.h @@ -35,7 +35,7 @@ class MockDistanceMeasurementCallbacks : public DistanceMeasurementCallbacks { MOCK_METHOD(void, OnDistanceMeasurementStopped, (Address, DistanceMeasurementErrorCode, DistanceMeasurementMethod)); MOCK_METHOD(void, OnDistanceMeasurementResult, - (Address, uint32_t, uint32_t, int, int, int, int, long, int8_t, + (Address, uint32_t, uint32_t, int, int, int, int, uint64_t, int8_t, DistanceMeasurementMethod)); }; diff --git a/system/gd/hci/facade/acl_manager_facade.cc b/system/gd/hci/facade/acl_manager_facade.cc index a2c3e03926..c885f9d683 100644 --- a/system/gd/hci/facade/acl_manager_facade.cc +++ b/system/gd/hci/facade/acl_manager_facade.cc @@ -528,15 +528,14 @@ public: lmp_version, manufacturer_name, sub_version); } void OnReadRemoteSupportedFeaturesComplete(uint64_t features) override { - log::info("OnReadRemoteSupportedFeaturesComplete features:0x{:x}", - static_cast<unsigned long>(features)); + log::info("OnReadRemoteSupportedFeaturesComplete features:0x{:x}", features); } void OnReadRemoteExtendedFeaturesComplete(uint8_t page_number, uint8_t max_page_number, uint64_t features) override { log::info( "OnReadRemoteExtendedFeaturesComplete page_number:{} max_page_number:{} " "features:0x{:x}", - page_number, max_page_number, static_cast<unsigned long>(features)); + page_number, max_page_number, features); } uint16_t handle_; diff --git a/system/gd/os/chromeos/metrics.cc b/system/gd/os/chromeos/metrics.cc index b3795341f2..c5b33a4fce 100644 --- a/system/gd/os/chromeos/metrics.cc +++ b/system/gd/os/chromeos/metrics.cc @@ -54,9 +54,8 @@ void LogMetricA2dpAudioOverrunEvent(const Address& address, uint64_t encoding_in addr_string = address.ToString(); - log::debug("A2dpAudioOverrun: {}, {}, {}, {}, {}, {}", boot_id, address, - (long long unsigned)encoding_interval_millis, num_dropped_buffers, - num_dropped_encoded_bytes, num_dropped_encoded_bytes); + log::debug("A2dpAudioOverrun: {}, {}, {}, {}, {}, {}", boot_id, address, encoding_interval_millis, + num_dropped_buffers, num_dropped_encoded_bytes, num_dropped_encoded_bytes); ::metrics::structured::events::bluetooth::BluetoothA2dpAudioOverrun() .SetBootId(boot_id) @@ -162,10 +161,9 @@ void LogMetricA2dpSessionMetricsEvent(const hci::Address& address, int64_t audio addr_string = address.ToString(); log::debug("A2dpSessionMetrics: {}, {}, {}, {}, {}, {}, {}, {}, {}, {:f}, {}, {}, {}", boot_id, - address, (long long int)audio_duration_ms, media_timer_min_ms, media_timer_max_ms, - media_timer_avg_ms, total_scheduling_count, buffer_overruns_max_count, - buffer_overruns_total, buffer_underruns_average, buffer_underruns_count, codec_index, - is_a2dp_offload); + address, audio_duration_ms, media_timer_min_ms, media_timer_max_ms, media_timer_avg_ms, + total_scheduling_count, buffer_overruns_max_count, buffer_overruns_total, + buffer_underruns_average, buffer_underruns_count, codec_index, is_a2dp_offload); ::metrics::structured::events::bluetooth::BluetoothA2dpSession() .SetBootId(boot_id) diff --git a/system/gd/os/linux_generic/alarm.cc b/system/gd/os/linux_generic/alarm.cc index b4de2096c7..dde5e2198c 100644 --- a/system/gd/os/linux_generic/alarm.cc +++ b/system/gd/os/linux_generic/alarm.cc @@ -95,8 +95,7 @@ void Alarm::on_fire() { log::assert_that(bytes_read == static_cast<ssize_t>(sizeof(uint64_t)), "assert failed: bytes_read == static_cast<ssize_t>(sizeof(uint64_t))"); - log::assert_that(times_invoked == static_cast<uint64_t>(1), "Invoked number of times:{} fd:{}", - (unsigned long)times_invoked, fd_); + log::assert_that(times_invoked == 1u, "Invoked number of times:{} fd:{}", times_invoked, fd_); std::move(task).Run(); } diff --git a/system/gd/rust/topshim/hfp/hfp_shim.cc b/system/gd/rust/topshim/hfp/hfp_shim.cc index 549b54a479..02eba51274 100644 --- a/system/gd/rust/topshim/hfp/hfp_shim.cc +++ b/system/gd/rust/topshim/hfp/hfp_shim.cc @@ -271,8 +271,8 @@ public: double packet_loss_ratio, uint64_t begin_ts, uint64_t end_ts, const char* pkt_status_in_hex, const char* pkt_status_in_binary) override { log::warn("DebugDumpCallback {} {} {} {:f} {} {} {} {}", active, codec_id, - total_num_decoded_frames, packet_loss_ratio, (unsigned long long)begin_ts, - (unsigned long long)end_ts, pkt_status_in_hex, pkt_status_in_binary); + total_num_decoded_frames, packet_loss_ratio, begin_ts, end_ts, pkt_status_in_hex, + pkt_status_in_binary); topshim::rust::internal::debug_dump_cb(active, codec_id, total_num_decoded_frames, packet_loss_ratio, begin_ts, end_ts, pkt_status_in_hex, pkt_status_in_binary); diff --git a/system/include/hardware/bt_sock.h b/system/include/hardware/bt_sock.h index ad8cc459e2..c7fff44daf 100644 --- a/system/include/hardware/bt_sock.h +++ b/system/include/hardware/bt_sock.h @@ -40,18 +40,18 @@ typedef enum { /** Represents the standard BT SOCKET interface. */ typedef struct { - short size; + int16_t size; RawAddress bd_addr; int channel; int status; // The writer must make writes using a buffer of this maximum size // to avoid loosing data. (L2CAP only) - unsigned short max_tx_packet_size; + uint16_t max_tx_packet_size; // The reader must read using a buffer of at least this size to avoid // loosing data. (L2CAP only) - unsigned short max_rx_packet_size; + uint16_t max_rx_packet_size; // The connection uuid. (L2CAP only) uint64_t conn_uuid_lsb; diff --git a/system/include/hardware/distance_measurement_interface.h b/system/include/hardware/distance_measurement_interface.h index 8978fee082..e5de171c39 100644 --- a/system/include/hardware/distance_measurement_interface.h +++ b/system/include/hardware/distance_measurement_interface.h @@ -17,6 +17,8 @@ #ifndef ANDROID_INCLUDE_DISTANCE_MEASUREMENT_INTERFACE_H #define ANDROID_INCLUDE_DISTANCE_MEASUREMENT_INTERFACE_H +#include <stdint.h> + #include "types/raw_address.h" /** @@ -31,7 +33,7 @@ public: virtual void OnDistanceMeasurementResult(RawAddress address, uint32_t centimeter, uint32_t error_centimeter, int azimuth_angle, int error_azimuth_angle, int altitude_angle, - int error_altitude_angle, long elapsedRealtimeNanos, + int error_altitude_angle, uint64_t elapsedRealtimeNanos, int8_t confidence_level, uint8_t method) = 0; }; diff --git a/system/main/shim/acl.cc b/system/main/shim/acl.cc index da5afc6dc8..7ab98517cb 100644 --- a/system/main/shim/acl.cc +++ b/system/main/shim/acl.cc @@ -1324,7 +1324,7 @@ void DumpsysNeighbor(int fd) { (timestamper_in_milliseconds.GetTimestamp() - btm_cb.neighbor.classic_inquiry.start_time_ms) / 1000.0, - btm_cb.neighbor.classic_inquiry.results); + (unsigned long)btm_cb.neighbor.classic_inquiry.results); } if (btm_cb.neighbor.le_scan.start_time_ms == 0) { LOG_DUMPSYS(fd, "Le scan:disabled"); @@ -1333,7 +1333,7 @@ void DumpsysNeighbor(int fd) { fd, "Le scan:enabled duration_s:%.3f results:%lu", (timestamper_in_milliseconds.GetTimestamp() - btm_cb.neighbor.le_scan.start_time_ms) / 1000.0, - btm_cb.neighbor.le_scan.results); + (unsigned long)btm_cb.neighbor.le_scan.results); } const auto copy = btm_cb.neighbor.inquiry_history_->Pull(); LOG_DUMPSYS(fd, "Last %zu inquiry scans:", copy.size()); @@ -1342,8 +1342,9 @@ void DumpsysNeighbor(int fd) { " %s - %s duration_ms:%-5llu num_resp:%-2u" " std:%-2u rssi:%-2u ext:%-2u %12s", EpochMillisToString(it.entry.start_time_ms).c_str(), - EpochMillisToString(it.timestamp).c_str(), it.timestamp - it.entry.start_time_ms, - it.entry.num_resp, it.entry.resp_type[BTM_INQ_RESULT_STANDARD], + EpochMillisToString(it.timestamp).c_str(), + (unsigned long long)(it.timestamp - it.entry.start_time_ms), it.entry.num_resp, + it.entry.resp_type[BTM_INQ_RESULT_STANDARD], it.entry.resp_type[BTM_INQ_RESULT_WITH_RSSI], it.entry.resp_type[BTM_INQ_RESULT_EXTENDED], btm_inquiry_cmpl_status_text(it.entry.status).c_str()); diff --git a/system/main/shim/distance_measurement_manager.cc b/system/main/shim/distance_measurement_manager.cc index aa5373f7f7..832b0186bd 100644 --- a/system/main/shim/distance_measurement_manager.cc +++ b/system/main/shim/distance_measurement_manager.cc @@ -117,7 +117,7 @@ public: void OnDistanceMeasurementResult(bluetooth::hci::Address address, uint32_t centimeter, uint32_t error_centimeter, int azimuth_angle, int error_azimuth_angle, int altitude_angle, - int error_altitude_angle, long elapsedRealtimeNanos, + int error_altitude_angle, uint64_t elapsedRealtimeNanos, int8_t confidence_level, DistanceMeasurementMethod method) override { do_in_jni_thread(base::BindOnce(&::DistanceMeasurementCallbacks::OnDistanceMeasurementResult, diff --git a/system/main/shim/le_scanning_manager.cc b/system/main/shim/le_scanning_manager.cc index 3f5f4ad07a..6133da1797 100644 --- a/system/main/shim/le_scanning_manager.cc +++ b/system/main/shim/le_scanning_manager.cc @@ -162,12 +162,12 @@ void BleScannerInterfaceImpl::Scan(bool start) { btm_cb.ble_ctr_cb.set_ble_observe_active(); } else if (!start && btm_cb.ble_ctr_cb.is_ble_observe_active()) { // stopped - const unsigned long long duration_timestamp = + const uint64_t duration_timestamp = timestamper_in_milliseconds.GetTimestamp() - btm_cb.neighbor.le_scan.start_time_ms; BTM_LogHistory(kBtmLogTag, RawAddress::kEmpty, "Le scan stopped", base::StringPrintf("duration_s:%6.3f results:%-3lu", (double)duration_timestamp / 1000.0, - btm_cb.neighbor.le_scan.results)); + (unsigned long)btm_cb.neighbor.le_scan.results)); btm_cb.ble_ctr_cb.reset_ble_observe(); btm_cb.neighbor.le_scan = {}; } else { diff --git a/system/main/test/main_shim_test.cc b/system/main/test/main_shim_test.cc index 7dbbedd607..f5ca4026a2 100644 --- a/system/main/test/main_shim_test.cc +++ b/system/main/test/main_shim_test.cc @@ -726,7 +726,7 @@ TEST_F(MainShimTest, DumpsysNeighbor) { .hci_status = HCI_SUCCESS, .num_resp = 45, .resp_type = {20, 30, 40}, - .start_time_ms = 0, + .start_time_ms = 1, }); btm_cb.neighbor.inquiry_history_->Push({ @@ -734,7 +734,7 @@ TEST_F(MainShimTest, DumpsysNeighbor) { .hci_status = HCI_SUCCESS, .num_resp = 123, .resp_type = {50, 60, 70}, - .start_time_ms = -1, + .start_time_ms = 0, }); DumpsysNeighbor(STDOUT_FILENO); diff --git a/system/osi/test/fuzzers/alarm/fuzz_alarm.cc b/system/osi/test/fuzzers/alarm/fuzz_alarm.cc index bc69bf855c..d4f7c6a3a5 100644 --- a/system/osi/test/fuzzers/alarm/fuzz_alarm.cc +++ b/system/osi/test/fuzzers/alarm/fuzz_alarm.cc @@ -55,7 +55,7 @@ public: private: std::mutex mMutex; std::condition_variable mCondition; - unsigned long mCount = 0; + uint64_t mCount = 0; }; static btsemaphore semaphore; static int cb_counter; diff --git a/system/stack/btm/btm_ble_gap.cc b/system/stack/btm/btm_ble_gap.cc index 91ca0b6fe6..6f6e42b216 100644 --- a/system/stack/btm/btm_ble_gap.cc +++ b/system/stack/btm/btm_ble_gap.cc @@ -592,12 +592,12 @@ tBTM_STATUS BTM_BleObserve(bool start, uint8_t duration, tBTM_INQ_RESULTS_CB* p_ } } } else if (btm_cb.ble_ctr_cb.is_ble_observe_active()) { - const unsigned long long duration_timestamp = + const uint64_t duration_timestamp = timestamper_in_milliseconds.GetTimestamp() - btm_cb.neighbor.le_observe.start_time_ms; BTM_LogHistory(kBtmLogTag, RawAddress::kEmpty, "Le observe stopped", base::StringPrintf("duration_s:%6.3f results:%-3lu", (double)duration_timestamp / 1000.0, - btm_cb.neighbor.le_observe.results)); + (unsigned long)btm_cb.neighbor.le_observe.results)); status = tBTM_STATUS::BTM_CMD_STARTED; btm_ble_stop_observe(); } else { @@ -2421,12 +2421,12 @@ static void btm_ble_stop_scan(void) { btm_cb.ble_ctr_cb.inq_var.scan_type = BTM_BLE_SCAN_MODE_NONE; /* stop discovery now */ - const unsigned long long duration_timestamp = + const uint64_t duration_timestamp = timestamper_in_milliseconds.GetTimestamp() - btm_cb.neighbor.le_legacy_scan.start_time_ms; BTM_LogHistory( kBtmLogTag, RawAddress::kEmpty, "Le legacy scan stopped", base::StringPrintf("duration_s:%6.3f results:%-3lu", (double)duration_timestamp / 1000.0, - btm_cb.neighbor.le_legacy_scan.results)); + (unsigned long)btm_cb.neighbor.le_legacy_scan.results)); btm_send_hci_scan_enable(BTM_BLE_SCAN_DISABLE, BTM_BLE_DUPLICATE_ENABLE); btm_update_scanner_filter_policy(SP_ADV_ALL); @@ -2443,12 +2443,12 @@ static void btm_ble_stop_scan(void) { void btm_ble_stop_inquiry(void) { alarm_cancel(btm_cb.ble_ctr_cb.inq_var.inquiry_timer); - const unsigned long long duration_timestamp = + const uint64_t duration_timestamp = timestamper_in_milliseconds.GetTimestamp() - btm_cb.neighbor.le_inquiry.start_time_ms; BTM_LogHistory( kBtmLogTag, RawAddress::kEmpty, "Le inquiry stopped", base::StringPrintf("duration_s:%6.3f results:%-3lu", (double)duration_timestamp / 1000.0, - btm_cb.neighbor.le_inquiry.results)); + (unsigned long)btm_cb.neighbor.le_inquiry.results)); btm_cb.ble_ctr_cb.reset_ble_inquiry(); /* Cleanup anything remaining on index 0 */ diff --git a/system/stack/btm/btm_inq.cc b/system/stack/btm/btm_inq.cc index b5456963d4..32debc62e1 100644 --- a/system/stack/btm/btm_inq.cc +++ b/system/stack/btm/btm_inq.cc @@ -562,13 +562,13 @@ void BTM_CancelInquiry(void) { const auto duration_ms = timestamper_in_milliseconds.GetTimestamp() - btm_cb.neighbor.classic_inquiry.start_time_ms; - BTM_LogHistory( - kBtmLogTag, RawAddress::kEmpty, "Classic inquiry canceled", - base::StringPrintf("duration_s:%6.3f results:%lu std:%u rssi:%u ext:%u", - duration_ms / 1000.0, btm_cb.neighbor.classic_inquiry.results, - btm_cb.btm_inq_vars.inq_cmpl_info.resp_type[BTM_INQ_RESULT_STANDARD], - btm_cb.btm_inq_vars.inq_cmpl_info.resp_type[BTM_INQ_RESULT_WITH_RSSI], - btm_cb.btm_inq_vars.inq_cmpl_info.resp_type[BTM_INQ_RESULT_EXTENDED])); + BTM_LogHistory(kBtmLogTag, RawAddress::kEmpty, "Classic inquiry canceled", + base::StringPrintf( + "duration_s:%6.3f results:%lu std:%u rssi:%u ext:%u", duration_ms / 1000.0, + (unsigned long)btm_cb.neighbor.classic_inquiry.results, + btm_cb.btm_inq_vars.inq_cmpl_info.resp_type[BTM_INQ_RESULT_STANDARD], + btm_cb.btm_inq_vars.inq_cmpl_info.resp_type[BTM_INQ_RESULT_WITH_RSSI], + btm_cb.btm_inq_vars.inq_cmpl_info.resp_type[BTM_INQ_RESULT_EXTENDED])); btm_cb.neighbor.classic_inquiry = {}; /* Only cancel if not in periodic mode, otherwise the caller should call @@ -1695,7 +1695,7 @@ void btm_process_inq_complete(tHCI_STATUS status, uint8_t mode) { "duration_s:%6.3f results:%lu inq_active:0x%02x std:%u rssi:%u " "ext:%u status:%s", (end_time_ms - btm_cb.neighbor.classic_inquiry.start_time_ms) / 1000.0, - btm_cb.neighbor.classic_inquiry.results, inq_active, + (unsigned long)btm_cb.neighbor.classic_inquiry.results, inq_active, btm_cb.btm_inq_vars.inq_cmpl_info.resp_type[BTM_INQ_RESULT_STANDARD], btm_cb.btm_inq_vars.inq_cmpl_info.resp_type[BTM_INQ_RESULT_WITH_RSSI], btm_cb.btm_inq_vars.inq_cmpl_info.resp_type[BTM_INQ_RESULT_EXTENDED], diff --git a/system/stack/btm/btm_int_types.h b/system/stack/btm/btm_int_types.h index 3ce89433d5..24d0de1e6e 100644 --- a/system/stack/btm/btm_int_types.h +++ b/system/stack/btm/btm_int_types.h @@ -148,8 +148,8 @@ public: struct { struct { - long long start_time_ms; - unsigned long results; + uint64_t start_time_ms; + uint64_t results; } classic_inquiry, le_scan, le_inquiry, le_observe, le_legacy_scan; std::unique_ptr<bluetooth::common::TimestampedCircularBuffer<tBTM_INQUIRY_CMPL>> inquiry_history_ = std::make_unique< diff --git a/system/stack/btm/btm_sco.cc b/system/stack/btm/btm_sco.cc index e7a33541d9..1aba506513 100644 --- a/system/stack/btm/btm_sco.cc +++ b/system/stack/btm/btm_sco.cc @@ -448,8 +448,7 @@ static void btm_route_sco_data(bluetooth::hci::ScoView valid_packet) { log::info( "Requested to read {} bytes of {} data but got {} bytes of PCM " "data from audio server: WriteOffset:{} ReadOffset:{}", - (unsigned long)to_read, codec, (unsigned long)read, - (unsigned long)btm_pcm_buf_write_offset, (unsigned long)btm_pcm_buf_read_offset); + to_read, codec, read, btm_pcm_buf_write_offset, btm_pcm_buf_read_offset); if (read == 0) { break; } @@ -485,11 +484,8 @@ static void btm_route_sco_data(bluetooth::hci::ScoView valid_packet) { incr_btm_pcm_buf_offset(btm_pcm_buf_read_offset, btm_pcm_buf_read_mirror, rc); if (!rc) { - log::debug( - "Failed to encode {} data starting at ReadOffset:{} to " - "WriteOffset:{}", - codec, (unsigned long)btm_pcm_buf_read_offset, - (unsigned long)btm_pcm_buf_write_offset); + log::debug("Failed to encode {} data starting at ReadOffset:{} to WriteOffset:{}", codec, + btm_pcm_buf_read_offset, btm_pcm_buf_write_offset); } } @@ -512,9 +508,8 @@ static void btm_route_sco_data(bluetooth::hci::ScoView valid_packet) { read = bluetooth::audio::sco::read( btm_pcm_buf, written < BTM_SCO_DATA_SIZE_MAX ? written : BTM_SCO_DATA_SIZE_MAX); if (read == 0) { - log::info( - "Failed to read {} bytes of PCM data from audio server", - (unsigned long)(written < BTM_SCO_DATA_SIZE_MAX ? written : BTM_SCO_DATA_SIZE_MAX)); + log::info("Failed to read {} bytes of PCM data from audio server", + written < BTM_SCO_DATA_SIZE_MAX ? written : BTM_SCO_DATA_SIZE_MAX); break; } written -= read; @@ -534,8 +529,7 @@ void btm_send_sco_packet(std::vector<uint8_t> data) { if (active_sco == nullptr || data.empty()) { return; } - log::assert_that(data.size() <= BTM_SCO_DATA_SIZE_MAX, "Invalid SCO data size: {}", - (unsigned long)data.size()); + log::assert_that(data.size() <= BTM_SCO_DATA_SIZE_MAX, "Invalid SCO data size: {}", data.size()); uint16_t handle_with_flags = active_sco->hci_handle; uint16_t handle = HCID_GET_HANDLE(handle_with_flags); diff --git a/system/stack/btm/btm_sco_hci.cc b/system/stack/btm/btm_sco_hci.cc index d27d823cbd..aef34f6a46 100644 --- a/system/stack/btm/btm_sco_hci.cc +++ b/system/stack/btm/btm_sco_hci.cc @@ -457,7 +457,7 @@ struct tBTM_MSBC_INFO { /* In case of unsupported value, error log and fallback to * BTM_MSBC_PKT_LEN(60). */ if (btm_wbs_supported_pkt_size[i] == 0) { - log::warn("Unsupported packet size {}", (unsigned long)pkt_size); + log::warn("Unsupported packet size {}", pkt_size); i = 0; } @@ -625,7 +625,7 @@ public: } if (rp != 0) { - log::warn("Skipped {} bytes of mSBC data ahead of a valid mSBC frame", (unsigned long)rp); + log::warn("Skipped {} bytes of mSBC data ahead of a valid mSBC frame", rp); incr_buf_offset(decode_buf_ro, decode_buf_ro_mirror, buf_size, rp); } @@ -737,7 +737,7 @@ bool enqueue_packet(const std::vector<uint8_t>& data, bool corrupted) { log::warn( "Ignoring the coming packet with size {} that is inconsistent with the " "HAL reported packet size {}", - (unsigned long)data.size(), (unsigned long)msbc_info->packet_size); + data.size(), msbc_info->packet_size); return false; } @@ -816,7 +816,7 @@ size_t encode(int16_t* data, size_t len) { encoded_size = GetInterfaceToProfiles()->msbcCodec->encodePacket(data, pkt_body); if (encoded_size != BTM_MSBC_PKT_FRAME_LEN) { - log::warn("Encoding invalid packet size: {}", (unsigned long)encoded_size); + log::warn("Encoding invalid packet size: {}", encoded_size); std::copy(&btm_msbc_zero_packet[BTM_MSBC_H2_HEADER_LEN], std::end(btm_msbc_zero_packet), pkt_body); } @@ -920,7 +920,7 @@ struct tBTM_LC3_INFO { /* In case of unsupported value, error log and fallback to * BTM_LC3_PKT_LEN(60). */ if (btm_swb_supported_pkt_size[i] == 0) { - log::warn("Unsupported packet size {}", (unsigned long)pkt_size); + log::warn("Unsupported packet size {}", pkt_size); i = 0; } @@ -1091,7 +1091,7 @@ public: } if (rp != 0) { - log::warn("Skipped {} bytes of LC3 data ahead of a valid LC3 frame", (unsigned long)rp); + log::warn("Skipped {} bytes of LC3 data ahead of a valid LC3 frame", rp); incr_buf_offset(decode_buf_ro, decode_buf_ro_mirror, buf_size, rp); } @@ -1190,7 +1190,7 @@ bool enqueue_packet(const std::vector<uint8_t>& data, bool corrupted) { log::warn( "Ignoring the coming packet with size {} that is inconsistent with the " "HAL reported packet size {}", - (unsigned long)data.size(), (unsigned long)lc3_info->packet_size); + data.size(), lc3_info->packet_size); return false; } diff --git a/system/stack/btm/hfp_msbc_decoder.cc b/system/stack/btm/hfp_msbc_decoder.cc index ccfbeea49f..224c03d054 100644 --- a/system/stack/btm/hfp_msbc_decoder.cc +++ b/system/stack/btm/hfp_msbc_decoder.cc @@ -67,8 +67,8 @@ void hfp_msbc_decoder_cleanup(void) { memset(&hfp_msbc_decoder, 0, sizeof(hfp_ms // Get the HFP MSBC encoded maximum frame size bool hfp_msbc_decoder_decode_packet(const uint8_t* i_buf, int16_t* o_buf, size_t out_len) { if (out_len < HFP_MSBC_PCM_BYTES) { - log::error("Output buffer's size {} is less than one complete mSBC frame {}", - (unsigned long)out_len, HFP_MSBC_PCM_BYTES); + log::error("Output buffer's size {} is less than one complete mSBC frame {}", out_len, + HFP_MSBC_PCM_BYTES); return false; } @@ -82,8 +82,7 @@ bool hfp_msbc_decoder_decode_packet(const uint8_t* i_buf, int16_t* o_buf, size_t OI_STATUS status = OI_CODEC_SBC_DecodeFrame(&hfp_msbc_decoder.decoder_context, &oi_data, &oi_size, o_buf, &out_avail); if (!OI_SUCCESS(status) || out_avail != HFP_MSBC_PCM_BYTES || oi_size != 0) { - log::error("Decoding failure: {}, {}, {}", status, (unsigned long)out_avail, - (unsigned long)oi_size); + log::error("Decoding failure: {}, {}, {}", status, out_avail, oi_size); return false; } diff --git a/system/stack/btm/neighbor_inquiry.h b/system/stack/btm/neighbor_inquiry.h index d4a13e9b5c..1dc0b68de9 100644 --- a/system/stack/btm/neighbor_inquiry.h +++ b/system/stack/btm/neighbor_inquiry.h @@ -180,7 +180,7 @@ typedef struct { tHCI_STATUS hci_status; uint8_t num_resp; /* Number of results from the current inquiry */ unsigned resp_type[kMaxNumberInquiryResults]; - long long start_time_ms; + uint64_t start_time_ms; } tBTM_INQUIRY_CMPL; inline std::string btm_inquiry_cmpl_status_text(const tBTM_INQUIRY_CMPL::STATUS& status) { diff --git a/system/stack/gatt/gatt_int.h b/system/stack/gatt/gatt_int.h index 3ceaa21020..3999ec4638 100644 --- a/system/stack/gatt/gatt_int.h +++ b/system/stack/gatt/gatt_int.h @@ -468,7 +468,7 @@ namespace { constexpr char kTimeFormatString[] = "%Y-%m-%d %H:%M:%S"; constexpr unsigned MillisPerSecond = 1000; -inline std::string EpochMillisToString(long long time_ms) { +inline std::string EpochMillisToString(uint64_t time_ms) { time_t time_sec = time_ms / MillisPerSecond; struct tm tm; localtime_r(&time_sec, &tm); diff --git a/system/stack/include/a2dp_vendor_aptx_encoder.h b/system/stack/include/a2dp_vendor_aptx_encoder.h index c547926588..6aed173230 100644 --- a/system/stack/include/a2dp_vendor_aptx_encoder.h +++ b/system/stack/include/a2dp_vendor_aptx_encoder.h @@ -63,7 +63,7 @@ int a2dp_vendor_aptx_get_effective_frame_size(); // |timestamp_us| is the current timestamp (in microseconds). void a2dp_vendor_aptx_send_frames(uint64_t timestamp_us); -typedef int (*tAPTX_ENCODER_INIT)(void* state, short endian); +typedef int (*tAPTX_ENCODER_INIT)(void* state, int16_t endian); typedef int (*tAPTX_ENCODER_ENCODE_STEREO)(void* state, void* pcmL, void* pcmR, void* buffer); diff --git a/system/stack/include/a2dp_vendor_aptx_hd_encoder.h b/system/stack/include/a2dp_vendor_aptx_hd_encoder.h index 54b86ad581..36490f7212 100644 --- a/system/stack/include/a2dp_vendor_aptx_hd_encoder.h +++ b/system/stack/include/a2dp_vendor_aptx_hd_encoder.h @@ -60,7 +60,7 @@ int a2dp_vendor_aptx_hd_get_effective_frame_size(); // |timestamp_us| is the current timestamp (in microseconds). void a2dp_vendor_aptx_hd_send_frames(uint64_t timestamp_us); -typedef int (*tAPTX_HD_ENCODER_INIT)(void* state, short endian); +typedef int (*tAPTX_HD_ENCODER_INIT)(void* state, int16_t endian); typedef int (*tAPTX_HD_ENCODER_ENCODE_STEREO)(void* state, void* pcmL, void* pcmR, void* buffer); diff --git a/system/stack/l2cap/l2c_fcr.cc b/system/stack/l2cap/l2c_fcr.cc index b310b37443..5e7fc3712d 100644 --- a/system/stack/l2cap/l2c_fcr.cc +++ b/system/stack/l2cap/l2c_fcr.cc @@ -48,7 +48,7 @@ static const char* SAR_types[] = {"Unsegmented", "Start", "End", "Continuation"} static const char* SUP_types[] = {"RR", "REJ", "RNR", "SREJ"}; /* Look-up table for the CRC calculation */ -static const unsigned short crctab[256] = { +static const uint16_t crctab[256] = { 0x0000, 0xc0c1, 0xc181, 0x0140, 0xc301, 0x03c0, 0x0280, 0xc241, 0xc601, 0x06c0, 0x0780, 0xc741, 0x0500, 0xc5c1, 0xc481, 0x0440, 0xcc01, 0x0cc0, 0x0d80, 0xcd41, 0x0f00, 0xcfc1, 0xce81, 0x0e40, 0x0a00, 0xcac1, 0xcb81, 0x0b40, 0xc901, 0x09c0, 0x0880, 0xc841, 0xd801, @@ -94,8 +94,8 @@ static bool do_sar_reassembly(tL2C_CCB* p_ccb, BT_HDR* p_buf, uint16_t ctrl_word * Returns CRC * ******************************************************************************/ -static unsigned short l2c_fcr_updcrc(unsigned short icrc, unsigned char* icp, int icnt) { - unsigned short crc = icrc; +static uint16_t l2c_fcr_updcrc(uint16_t icrc, unsigned char* icp, int icnt) { + uint16_t crc = icrc; unsigned char* cp = icp; int cnt = icnt; diff --git a/system/stack/l2cap/l2c_utils.cc b/system/stack/l2cap/l2c_utils.cc index 3a057ec508..c04379bf89 100644 --- a/system/stack/l2cap/l2c_utils.cc +++ b/system/stack/l2cap/l2c_utils.cc @@ -1525,7 +1525,7 @@ bool l2cu_start_post_bond_timer(uint16_t handle) { timeout_ms = L2CAP_LINK_DISCONNECT_TIMEOUT_MS; } alarm_set_on_mloop(p_lcb->l2c_lcb_timer, timeout_ms, l2c_lcb_timer_timeout, p_lcb); - log::debug("Started link IDLE timeout_ms:{}", (unsigned long)timeout_ms); + log::debug("Started link IDLE timeout_ms:{}", timeout_ms); return true; } break; @@ -2827,7 +2827,7 @@ void l2cu_no_dynamic_ccbs(tL2C_LCB* p_lcb) { if (start_timeout) { alarm_set_on_mloop(p_lcb->l2c_lcb_timer, timeout_ms, l2c_lcb_timer_timeout, p_lcb); - log::debug("Started link IDLE timeout_ms:{}", (unsigned long)timeout_ms); + log::debug("Started link IDLE timeout_ms:{}", timeout_ms); } else { alarm_cancel(p_lcb->l2c_lcb_timer); } diff --git a/system/stack/test/fuzzers/sdp/sdpFuzzHelpers.h b/system/stack/test/fuzzers/sdp/sdpFuzzHelpers.h index 2647e3f844..dfea9f630f 100644 --- a/system/stack/test/fuzzers/sdp/sdpFuzzHelpers.h +++ b/system/stack/test/fuzzers/sdp/sdpFuzzHelpers.h @@ -154,8 +154,7 @@ tSDP_PROTOCOL_ELEM generateArbitrarySdpProtocolElements(FuzzedDataProvider* fdp) // Set our protocol element values p_elem.protocol_uuid = fdp->ConsumeIntegral<uint16_t>(); p_elem.num_params = fdp->ConsumeIntegralInRange<uint16_t>(0, SDP_MAX_PROTOCOL_PARAMS); - uint16_t num_loops = - std::min(p_elem.num_params, static_cast<unsigned short>(SDP_MAX_PROTOCOL_PARAMS)); + uint16_t num_loops = std::min(p_elem.num_params, static_cast<uint16_t>(SDP_MAX_PROTOCOL_PARAMS)); // Regardless of number set above, fill out the entire allocated array for (uint16_t i = 0; i < num_loops; i++) { p_elem.params[i] = fdp->ConsumeIntegral<uint16_t>(); @@ -171,8 +170,7 @@ std::shared_ptr<tSDP_PROTO_LIST_ELEM> generateArbitrarySdpProtocolElementList( // Populate our element list p_elem_list->num_elems = fdp->ConsumeIntegralInRange<uint16_t>(0, SDP_MAX_LIST_ELEMS); - uint16_t num_loops = - std::min(p_elem_list->num_elems, static_cast<unsigned short>(SDP_MAX_LIST_ELEMS)); + uint16_t num_loops = std::min(p_elem_list->num_elems, static_cast<uint16_t>(SDP_MAX_LIST_ELEMS)); for (uint16_t i = 0; i < num_loops; i++) { p_elem_list->list_elem[i] = generateArbitrarySdpProtocolElements(fdp); } diff --git a/system/stack/test/stack_avctp_test.cc b/system/stack/test/stack_avctp_test.cc index e617b6462a..c93787f613 100644 --- a/system/stack/test/stack_avctp_test.cc +++ b/system/stack/test/stack_avctp_test.cc @@ -52,9 +52,9 @@ protected: void SetUp() override { StackAvctpWithMocksTest::SetUp(); EXPECT_CALL(mock_stack_l2cap_interface_, L2CA_RegisterWithSecurity(_, _, _, _, _, _, _)) - .WillRepeatedly([this](unsigned short psm, const tL2CAP_APPL_INFO& cb, bool /* c */, - tL2CAP_ERTM_INFO* /*d*/, unsigned short /* e */, - unsigned short /* f */, unsigned short /* g */) { + .WillRepeatedly([this](uint16_t psm, const tL2CAP_APPL_INFO& cb, bool /* c */, + tL2CAP_ERTM_INFO* /*d*/, uint16_t /* e */, uint16_t /* f */, + uint16_t /* g */) { this->callback_map_.insert(std::make_tuple(psm, cb)); return psm; }); @@ -81,7 +81,7 @@ TEST_F(StackAvctpTest, AVCT_Dumpsys) { AVCT_Dumpsys(fd_); } TEST_F(StackAvctpTest, AVCT_CreateConn) { EXPECT_CALL(mock_stack_l2cap_interface_, L2CA_ConnectReqWithSecurity(_, _, _)) - .WillRepeatedly([](unsigned short /* psm */, const RawAddress /* bd_addr */, + .WillRepeatedly([](uint16_t /* psm */, const RawAddress /* bd_addr */, uint16_t /* sec_level */) { return 0x1234; }); uint8_t handle; @@ -100,7 +100,7 @@ TEST_F(StackAvctpTest, AVCT_CreateConn) { TEST_F(StackAvctpTest, AVCT_CreateBrowse) { EXPECT_CALL(mock_stack_l2cap_interface_, L2CA_ConnectReqWithSecurity(_, _, _)) - .WillRepeatedly([](unsigned short /* psm */, const RawAddress /* bd_addr */, + .WillRepeatedly([](uint16_t /* psm */, const RawAddress /* bd_addr */, uint16_t /* sec_level */) { return 0x1234; }); uint8_t handle; @@ -143,10 +143,9 @@ TEST_F(StackAvctpWithMocksTest, AVCT_Lifecycle) { // Register the AVCT profile and capture the l2cap callbacks std::map<uint16_t, tL2CAP_APPL_INFO> callback_map; EXPECT_CALL(mock_stack_l2cap_interface_, L2CA_RegisterWithSecurity(_, _, _, _, _, _, _)) - .WillRepeatedly([&callback_map](unsigned short psm, const tL2CAP_APPL_INFO& cb, - bool /* c */, tL2CAP_ERTM_INFO* /*d*/, - unsigned short /* e */, unsigned short /* f */, - unsigned short /* g */) { + .WillRepeatedly([&callback_map](uint16_t psm, const tL2CAP_APPL_INFO& cb, bool /* c */, + tL2CAP_ERTM_INFO* /*d*/, uint16_t /* e */, + uint16_t /* f */, uint16_t /* g */) { callback_map.insert(std::make_tuple(psm, cb)); return psm; }); @@ -155,7 +154,7 @@ TEST_F(StackAvctpWithMocksTest, AVCT_Lifecycle) { // Return well known l2cap channel IDs for each of the two PSMs EXPECT_CALL(mock_stack_l2cap_interface_, L2CA_ConnectReqWithSecurity(_, _, _)) .WillRepeatedly( - [](unsigned short psm, const RawAddress /* bd_addr */, uint16_t /* sec_level */) { + [](uint16_t psm, const RawAddress /* bd_addr */, uint16_t /* sec_level */) { return (psm == BT_PSM_AVCTP) ? kRemoteCid : kRemoteBrowseCid; }); diff --git a/system/test/fake/fake_thread.h b/system/test/fake/fake_thread.h index c05f66ecc9..42d591f769 100644 --- a/system/test/fake/fake_thread.h +++ b/system/test/fake/fake_thread.h @@ -34,7 +34,7 @@ using work_item = std::pair<thread_func, thread_data>; class semaphore_t { std::condition_variable condition_; - unsigned long count_ = 0; // Initialized as locked. + uint64_t count_ = 0; // Initialized as locked. public: std::mutex mutex_; diff --git a/system/test/headless/get_options.h b/system/test/headless/get_options.h index 14d68ebc6d..ee10b12063 100644 --- a/system/test/headless/get_options.h +++ b/system/test/headless/get_options.h @@ -43,8 +43,8 @@ public: std::list<RawAddress> device_; std::list<bluetooth::Uuid> uuid_; - unsigned long loop_{1}; - unsigned long msec_{0}; + uint64_t loop_{1}; + uint64_t msec_{0}; bool close_stderr_{true}; bool clear_logcat_{false}; diff --git a/system/test/headless/headless.h b/system/test/headless/headless.h index 40b2d0315a..11363c9add 100644 --- a/system/test/headless/headless.h +++ b/system/test/headless/headless.h @@ -59,7 +59,7 @@ private: class HeadlessRun : public HeadlessStack { protected: const bluetooth::test::headless::GetOpt& options_; - unsigned long loop_{0}; + uint64_t loop_{0}; HeadlessRun(const bluetooth::test::headless::GetOpt& options) : options_(options) {} diff --git a/system/test/headless/interface.h b/system/test/headless/interface.h index 47e5484fdf..e8e09beb22 100644 --- a/system/test/headless/interface.h +++ b/system/test/headless/interface.h @@ -65,7 +65,7 @@ protected: private: const char* name_; const Callback callback_type_; - const long long timestamp_ms_; + const uint64_t timestamp_ms_; }; struct callback_params_t : public callback_data_t { diff --git a/system/test/headless/log.cc b/system/test/headless/log.cc index 729db46475..a14368bb2a 100644 --- a/system/test/headless/log.cc +++ b/system/test/headless/log.cc @@ -30,4 +30,4 @@ std::chrono::system_clock::time_point _prev = std::chrono::system_clock::now(); extern tBTM_CB btm_cb; bluetooth::common::TimestamperInMilliseconds timestamper_in_ms; -long long GetTimestampMs() { return timestamper_in_ms.GetTimestamp(); } +uint64_t GetTimestampMs() { return timestamper_in_ms.GetTimestamp(); } diff --git a/system/test/headless/log.h b/system/test/headless/log.h index 3e4f461d2f..5cb784ea84 100644 --- a/system/test/headless/log.h +++ b/system/test/headless/log.h @@ -25,7 +25,7 @@ #include "build_timestamp.h" // generated -long long GetTimestampMs(); +uint64_t GetTimestampMs(); // Internal to headless below @@ -54,8 +54,7 @@ constexpr char _main[7 + 1] = " MAIN "; _prev = _now; \ auto _now_us = std::chrono::time_point_cast<std::chrono::microseconds>(_now); \ auto _now_t = std::chrono::system_clock::to_time_t(_now); \ - /* YYYY-MM-DD_HH:MM:SS.ssssss is 26 byte long, plus 1 for null terminator \ - */ \ + /* YYYY-MM-DD_HH:MM:SS.ssssss is 26 byte, plus 1 for null terminator */ \ char _buf[26 + 1]; \ auto l = std::strftime(_buf, sizeof(_buf), "%Y-%m-%d %H:%M:%S", std::localtime(&_now_t)); \ snprintf(_buf + l, sizeof(_buf) - l, ".%06u", \ diff --git a/system/test/headless/stopwatch.h b/system/test/headless/stopwatch.h index d7f5e3689b..e420f2be08 100644 --- a/system/test/headless/stopwatch.h +++ b/system/test/headless/stopwatch.h @@ -40,7 +40,7 @@ public: std::string ToString() { return ToString(""); } std::string ToString(const std::string& comment) { - return std::format("{}: {} ms {}", name_, static_cast<unsigned long>(LapMs()), comment); + return std::format("{}: {} ms {}", name_, LapMs(), comment); } private: diff --git a/system/test/mock/mock_bta_has.cc b/system/test/mock/mock_bta_has.cc index 744004f3b7..661bbe5a25 100644 --- a/system/test/mock/mock_bta_has.cc +++ b/system/test/mock/mock_bta_has.cc @@ -33,7 +33,7 @@ bool HasClient::IsHasClientRunning() { inc_func_call_count(__func__); return false; } -void HasClient::AddFromStorage(RawAddress const&, unsigned char, unsigned short) { +void HasClient::AddFromStorage(RawAddress const&, unsigned char, uint16_t) { inc_func_call_count(__func__); } HasClient* HasClient::Get() { diff --git a/system/test/suite/adapter/bluetooth_test.h b/system/test/suite/adapter/bluetooth_test.h index 27b831f066..d495231636 100644 --- a/system/test/suite/adapter/bluetooth_test.h +++ b/system/test/suite/adapter/bluetooth_test.h @@ -61,7 +61,7 @@ public: private: std::mutex mMutex; std::condition_variable mCondition; - unsigned long mCount = 0; + uint64_t mCount = 0; }; void semaphore_wait(btsemaphore& s); void semaphore_post(btsemaphore& s); |