example: fix warnings

This commit is contained in:
Matthias Ringwald 2022-04-30 21:07:48 +02:00
parent 2395380485
commit 0801ef928e
12 changed files with 18 additions and 18 deletions

View File

@ -202,7 +202,7 @@ static uint16_t att_read_callback(hci_con_handle_t connection_handle, uint16_t a
// useless code when ENABLE_ATT_DELAYED_RESPONSE is not defined - but avoids built errors
if (att_handle == ATT_CHARACTERISTIC_0000FF11_0000_1000_8000_00805F9B34FB_01_VALUE_HANDLE){
printf("ENABLE_ATT_DELAYED_RESPONSE not defined in btstack_config.h, responding right away");
return att_read_callback_handle_blob((const uint8_t *)test_string, strlen(test_string), offset, buffer, buffer_size);
return att_read_callback_handle_blob((const uint8_t *)test_string, (uint16_t) strlen(test_string), offset, buffer, buffer_size);
}
#endif

View File

@ -172,7 +172,7 @@ static int counter_string_len;
static void beat(void){
counter++;
counter_string_len = sprintf(counter_string, "BTstack counter %04u", counter);
counter_string_len = snprintf(counter_string, sizeof(counter_string), "BTstack counter %04u", counter);
puts(counter_string);
}

View File

@ -101,7 +101,7 @@ static btstack_packet_callback_registration_t hci_event_callback_registration;
static int advertisement_report_contains_uuid16(uint16_t uuid16, uint8_t * advertisement_report){
// get advertisement from report event
const uint8_t * adv_data = gap_event_advertising_report_get_data(advertisement_report);
uint16_t adv_len = gap_event_advertising_report_get_data_length(advertisement_report);
uint8_t adv_len = gap_event_advertising_report_get_data_length(advertisement_report);
// iterate over advertisement data
ad_context_t context;

View File

@ -176,7 +176,7 @@ static void handle_boot_keyboard_event(uint8_t packet_type, uint16_t channel, ui
uint8_t key_index;
for (key_index = 0; key_index < NUM_KEYS; key_index++){
uint16_t usage = data[2 + key_index];
uint8_t usage = data[2 + key_index];
if (usage == 0) continue;
if (usage >= sizeof(keytable_us_none)) continue;
@ -244,7 +244,7 @@ static void handle_boot_mouse_event(uint8_t packet_type, uint16_t channel, uint8
*/
static bool adv_event_contains_hid_service(const uint8_t * packet){
const uint8_t * ad_data = gap_event_advertising_report_get_data(packet);
uint16_t ad_len = gap_event_advertising_report_get_data_length(packet);
uint8_t ad_len = gap_event_advertising_report_get_data_length(packet);
return ad_data_contains_uuid16(ad_len, ad_data, ORG_BLUETOOTH_SERVICE_HUMAN_INTERFACE_DEVICE);
}
@ -611,7 +611,7 @@ int btstack_main(int argc, const char * argv[]){
/* LISTING_END */
// Disable stdout buffering
setbuf(stdout, NULL);
setvbuf(stdin, NULL, _IONBF, 0);
app_state = W4_WORKING;

View File

@ -195,7 +195,7 @@ static void hid_handle_input_report(uint8_t service_index, const uint8_t * repor
if (usage >= sizeof(keytable_us_none)) continue;
// store new keys
new_keys[new_keys_count++] = usage;
new_keys[new_keys_count++] = (uint8_t) usage;
// check if usage was used last time (and ignore in that case)
int i;
@ -230,7 +230,7 @@ static void hid_handle_input_report(uint8_t service_index, const uint8_t * repor
*/
static bool adv_event_contains_hid_service(const uint8_t * packet){
const uint8_t * ad_data = gap_event_advertising_report_get_data(packet);
uint16_t ad_len = gap_event_advertising_report_get_data_length(packet);
uint8_t ad_len = gap_event_advertising_report_get_data_length(packet);
return ad_data_contains_uuid16(ad_len, ad_data, ORG_BLUETOOTH_SERVICE_HUMAN_INTERFACE_DEVICE);
}
@ -530,7 +530,7 @@ int btstack_main(int argc, const char * argv[]){
/* LISTING_END */
// Disable stdout buffering
setbuf(stdout, NULL);
setvbuf(stdin, NULL, _IONBF, 0);
app_state = W4_WORKING;

View File

@ -131,8 +131,8 @@ static void test_track_data(le_cbm_connection_t * context, int bytes_transferred
static int advertisement_report_contains_name(const char * name, uint8_t * advertisement_report){
// get advertisement from report event
const uint8_t * adv_data = gap_event_advertising_report_get_data(advertisement_report);
uint16_t adv_len = gap_event_advertising_report_get_data_length(advertisement_report);
int name_len = strlen(name);
uint8_t adv_len = gap_event_advertising_report_get_data_length(advertisement_report);
uint16_t name_len = (uint16_t) strlen(name);
// iterate over advertisement data
ad_context_t context;

View File

@ -485,7 +485,7 @@ static void att_packet_handler(uint8_t packet_type, uint16_t handle, uint8_t *pa
} else {
btstack_assert(size <= MAX_ATT_MTU);
pdu->handle = mitm_opposite_handle(handle);
pdu->len = size;
pdu->len = (uint8_t) size;
memcpy(pdu->data, packet, size);
}
btstack_linked_list_add_tail(&outgoing_att_pdus, (btstack_linked_item_t *) pdu);

View File

@ -176,8 +176,8 @@ static void streamer(le_streamer_connection_t * context){
static int advertisement_report_contains_name(const char * name, uint8_t * advertisement_report){
// get advertisement from report event
const uint8_t * adv_data = gap_event_advertising_report_get_data(advertisement_report);
uint16_t adv_len = gap_event_advertising_report_get_data_length(advertisement_report);
int name_len = strlen(name);
uint8_t adv_len = gap_event_advertising_report_get_data_length(advertisement_report);
uint16_t name_len = (uint8_t) strlen(name);
// iterate over advertisement data
ad_context_t context;

View File

@ -73,7 +73,7 @@ static void heartbeat_handler(btstack_timer_source_t *ts){
// increment counter
char lineBuffer[30];
sprintf(lineBuffer, "BTstack counter %04u\n\r", ++counter);
snprintf(lineBuffer, sizeof(lineBuffer), "BTstack counter %04u\n\r", ++counter);
puts(lineBuffer);
// toggle LED

View File

@ -85,7 +85,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
static uint16_t att_read_callback(hci_con_handle_t connection_handle, uint16_t att_handle, uint16_t offset, uint8_t * buffer, uint16_t buffer_size){
UNUSED(connection_handle);
if (att_handle == ATT_CHARACTERISTIC_GAP_DEVICE_NAME_01_VALUE_HANDLE){
return att_read_callback_handle_blob((const uint8_t *)gap_name_buffer, strlen(gap_name_buffer), offset, buffer, buffer_size);
return att_read_callback_handle_blob((const uint8_t *)gap_name_buffer, (uint16_t) strlen(gap_name_buffer), offset, buffer, buffer_size);
}
return 0;
}

View File

@ -104,7 +104,7 @@ static int counter_string_len;
static void beat(void){
counter++;
counter_string_len = sprintf(counter_string, "BTstack counter %03u", counter);
counter_string_len = snprintf(counter_string, sizeof(counter_string), "BTstack counter %03u", counter);
}
static void nordic_can_send(void * context){

View File

@ -106,7 +106,7 @@ static int counter_string_len;
static void beat(void){
counter++;
counter_string_len = sprintf(counter_string, "BTstack counter %03u", counter);
counter_string_len = snprintf(counter_string, sizeof(counter_string), "BTstack counter %03u", counter);
}
static void ublox_can_send(void * context){