From 1a3bc516d32cb662bb5a04bc18b6a1f78e2c6ef6 Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Wed, 6 Mar 2024 10:13:01 +0100 Subject: [PATCH] src: cast strlen() to uint16_t --- src/btstack_util.c | 2 +- src/classic/avrcp_cover_art_client.c | 4 ++-- src/classic/hfp_ag.c | 2 +- src/classic/hfp_hf.c | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/btstack_util.c b/src/btstack_util.c index 9958cb030..2270469aa 100644 --- a/src/btstack_util.c +++ b/src/btstack_util.c @@ -630,7 +630,7 @@ uint16_t btstack_next_cid_ignoring_zero(uint16_t current_cid){ } uint16_t btstack_strcpy(char * dst, uint16_t dst_size, const char * src){ - uint16_t bytes_to_copy = (uint16_t) btstack_min( dst_size - 1, strlen(src)); + uint16_t bytes_to_copy = (uint16_t) btstack_min( dst_size - 1, (uint16_t) strlen(src)); (void) memcpy(dst, src, bytes_to_copy); dst[bytes_to_copy] = 0; return bytes_to_copy + 1; diff --git a/src/classic/avrcp_cover_art_client.c b/src/classic/avrcp_cover_art_client.c index 56b83aafe..2764a1533 100644 --- a/src/classic/avrcp_cover_art_client.c +++ b/src/classic/avrcp_cover_art_client.c @@ -267,9 +267,9 @@ static void avrcp_cover_art_client_handle_can_send_now(avrcp_cover_art_client_t avrcp_cover_art_client_prepare_srm_header(cover_art_client); goep_client_header_add_type(cover_art_client->goep_cid, cover_art_client->object_type); if (cover_art_client->image_descriptor != NULL){ - goep_client_header_add_variable(cover_art_client->goep_cid, OBEX_HEADER_IMG_DESCRIPTOR, (const uint8_t *) cover_art_client->image_descriptor, strlen(cover_art_client->image_descriptor)); + goep_client_header_add_variable(cover_art_client->goep_cid, OBEX_HEADER_IMG_DESCRIPTOR, (const uint8_t *) cover_art_client->image_descriptor, (uint16_t) strlen(cover_art_client->image_descriptor)); } - uint8_t image_handle_len = btstack_max(7, strlen(cover_art_client->image_handle)); + uint8_t image_handle_len = btstack_max(7, (uint16_t) strlen(cover_art_client->image_handle)); goep_client_header_add_unicode_prefix(cover_art_client->goep_cid, OBEX_HEADER_IMG_HANDLE, cover_art_client->image_handle, image_handle_len); } // state diff --git a/src/classic/hfp_ag.c b/src/classic/hfp_ag.c index bcb15d27a..fd545dc52 100644 --- a/src/classic/hfp_ag.c +++ b/src/classic/hfp_ag.c @@ -896,7 +896,7 @@ static void hfp_ag_emit_general_simple_event(uint8_t event_subtype){ static void hfp_ag_emit_custom_command_event(hfp_connection_t * hfp_connection){ btstack_assert(sizeof(hfp_connection->line_buffer) < (255-5)); - uint16_t line_len = strlen((const char*)hfp_connection->line_buffer) + 1; + uint16_t line_len = (uint16_t) strlen((const char*)hfp_connection->line_buffer) + 1; uint8_t event[7 + sizeof(hfp_connection->line_buffer)]; event[0] = HCI_EVENT_HFP_META; event[1] = 5 + line_len; diff --git a/src/classic/hfp_hf.c b/src/classic/hfp_hf.c index 454928965..2434ab5af 100644 --- a/src/classic/hfp_hf.c +++ b/src/classic/hfp_hf.c @@ -278,7 +278,7 @@ static void hfp_hf_emit_enhanced_voice_recognition_text(hfp_connection_t * hfp_c static void hfp_hf_emit_custom_command_event(hfp_connection_t * hfp_connection){ btstack_assert(sizeof(hfp_connection->line_buffer) < (255-5)); - uint16_t line_len = strlen((const char*)hfp_connection->line_buffer) + 1; + uint16_t line_len = (uint16_t) strlen((const char*)hfp_connection->line_buffer) + 1; uint8_t event[7 + sizeof(hfp_connection->line_buffer)]; event[0] = HCI_EVENT_HFP_META; event[1] = 5 + line_len;