From cb140a1e11895355f5dbf99309e21ec1785da0dd Mon Sep 17 00:00:00 2001 From: Matthias Ringwald Date: Mon, 16 Dec 2024 22:59:14 +0100 Subject: [PATCH] att_server: fix signed vs. unsigned warnings --- src/ble/att_server.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/ble/att_server.c b/src/ble/att_server.c index 099409f3b..1ad900887 100644 --- a/src/ble/att_server.c +++ b/src/ble/att_server.c @@ -77,7 +77,7 @@ #define NVN_NUM_GATT_SERVER_CCC 20 #endif -#define ATT_SERVICE_FLAGS_DELAYED_RESPONSE (1<<0u) +#define ATT_SERVICE_FLAGS_DELAYED_RESPONSE (1u<<0u) static void att_run_for_context(att_server_t * att_server, att_connection_t * att_connection); static att_write_callback_t att_server_write_callback_for_handle(uint16_t handle); @@ -365,7 +365,7 @@ static void att_server_event_packet_handler (uint8_t packet_type, uint16_t chann att_connection->encryption_key_size, att_connection->authenticated, att_connection->secure_connection); if (hci_event_packet_get_type(packet) == HCI_EVENT_ENCRYPTION_CHANGE){ // restore CCC values when encrypted for LE Connections - if (hci_event_encryption_change_get_encryption_enabled(packet) != 0){ + if (hci_event_encryption_change_get_encryption_enabled(packet) != 0u){ att_server_persistent_ccc_restore(att_server, att_connection); } } @@ -563,13 +563,13 @@ static void att_server_handle_response_pending(att_server_t *att_server, const a btstack_linked_list_iterator_init(&it, &service_handlers); while (btstack_linked_list_iterator_has_next(&it)) { att_service_handler_t *handler = (att_service_handler_t *) btstack_linked_list_iterator_next(&it); - if ((handler->flags & ATT_SERVICE_FLAGS_DELAYED_RESPONSE) != 0){ + if ((handler->flags & ATT_SERVICE_FLAGS_DELAYED_RESPONSE) != 0u){ handler->flags &= ~ATT_SERVICE_FLAGS_DELAYED_RESPONSE; handler->read_callback(att_connection->con_handle, ATT_READ_RESPONSE_PENDING, 0, NULL, 0); } } // notify main read callback if it returned response pending - if ((att_server_flags & ATT_SERVICE_FLAGS_DELAYED_RESPONSE) != 0){ + if ((att_server_flags & ATT_SERVICE_FLAGS_DELAYED_RESPONSE) != 0u){ // flag was set by read callback btstack_assert(att_server_client_read_callback != NULL); (*att_server_client_read_callback)(att_connection->con_handle, ATT_READ_RESPONSE_PENDING, 0, NULL, 0); @@ -797,7 +797,7 @@ static void att_server_handle_can_send_now(void){ bool can_send_now = true; uint8_t phase_index; - for (phase_index = ATT_SERVER_RUN_PHASE_1_REQUESTS; phase_index <= ATT_SERVER_RUN_PHASE_3_NOTIFICATIONS; phase_index++){ + for (phase_index = (uint8_t) ATT_SERVER_RUN_PHASE_1_REQUESTS; phase_index <= (uint8_t) ATT_SERVER_RUN_PHASE_3_NOTIFICATIONS; phase_index++){ att_server_run_phase_t phase = (att_server_run_phase_t) phase_index; hci_con_handle_t skip_connections_until = att_server_last_can_send_now; while (true){ @@ -1026,7 +1026,7 @@ static void att_server_dispatch_packet_handler(uint8_t packet_type, uint16_t cha // --------------------- // persistent CCC writes static uint32_t att_server_persistent_ccc_tag_for_index(uint8_t index){ - return ('B' << 24u) | ('T' << 16u) | ('C' << 8u) | index; + return (((uint8_t)'B') << 24u) | (((uint8_t)'T') << 16u) | (((uint8_t)'C') << 8u) | index; } static void att_server_persistent_ccc_write(hci_con_handle_t con_handle, uint16_t att_handle, uint16_t value){ @@ -1058,7 +1058,7 @@ static void att_server_persistent_ccc_write(hci_con_handle_t con_handle, uint16_ int len = tlv_impl->get_tag(tlv_context, tag, (uint8_t *) &entry, sizeof(persistent_ccc_entry_t)); // empty/invalid tag - if (len != sizeof(persistent_ccc_entry_t)){ + if (len != (int) sizeof(persistent_ccc_entry_t)){ tag_for_empty = tag; continue; } @@ -1072,11 +1072,11 @@ static void att_server_persistent_ccc_write(hci_con_handle_t con_handle, uint16_ lowest_seq_nr = entry.seq_nr; } - if (entry.device_index != le_device_index) continue; - if (entry.att_handle != att_handle) continue; + if ((int)entry.device_index != le_device_index) continue; + if ( entry.att_handle != att_handle) continue; // found matching entry - if (value != 0){ + if (value != 0u){ // update if (entry.value == value) { log_info("CCC Index %u: Up-to-date", index); @@ -1107,7 +1107,7 @@ static void att_server_persistent_ccc_write(hci_con_handle_t con_handle, uint16_ uint32_t tag_to_use = 0u; if (tag_for_empty != 0u){ tag_to_use = tag_for_empty; - } else if (tag_for_lowest_seq_nr != 0){ + } else if (tag_for_lowest_seq_nr != 0u){ tag_to_use = tag_for_lowest_seq_nr; } else { // should not happen @@ -1140,8 +1140,8 @@ static void att_server_persistent_ccc_clear(att_server_t * att_server){ for (index=0;indexget_tag(tlv_context, tag, (uint8_t *) &entry, sizeof(persistent_ccc_entry_t)); - if (len != sizeof(persistent_ccc_entry_t)) continue; - if (entry.device_index != le_device_index) continue; + if (len != (int) sizeof(persistent_ccc_entry_t)) continue; + if ((int)entry.device_index != le_device_index) continue; // delete entry log_info("CCC Index %u: Delete", index); tlv_impl->delete_tag(tlv_context, tag); @@ -1164,8 +1164,8 @@ static void att_server_persistent_ccc_restore(att_server_t * att_server, att_con for (index=0;indexget_tag(tlv_context, tag, (uint8_t *) &entry, sizeof(persistent_ccc_entry_t)); - if (len != sizeof(persistent_ccc_entry_t)) continue; - if (entry.device_index != le_device_index) continue; + if (len != (int) sizeof(persistent_ccc_entry_t)) continue; + if ((int) entry.device_index != le_device_index) continue; // simulate write callback uint16_t attribute_handle = entry.att_handle; uint8_t value[2];