From 2d00edd4aa4b9295ae0c72ee712a568b115fb6a9 Mon Sep 17 00:00:00 2001 From: "matthias.ringwald" Date: Fri, 22 Jul 2011 10:14:38 +0000 Subject: [PATCH] don't declare variables in switch cases --- src/hci.c | 3 ++- src/l2cap.c | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/hci.c b/src/hci.c index 2ff3ef620..2ee8576ae 100644 --- a/src/hci.c +++ b/src/hci.c @@ -353,6 +353,7 @@ static void hci_shutdown_connection(hci_connection_t *conn){ static device_name_t device_name; static void event_handler(uint8_t *packet, int size){ bd_addr_t addr; + uint8_t link_type; hci_con_handle_t handle; hci_connection_t * conn; int i; @@ -404,7 +405,7 @@ static void event_handler(uint8_t *packet, int size){ case HCI_EVENT_CONNECTION_REQUEST: bt_flip_addr(addr, &packet[2]); // TODO: eval COD 8-10 - uint8_t link_type = packet[11]; + link_type = packet[11]; log_dbg("Connection_incoming: "); print_bd_addr(addr); log_dbg(", type %u\n", link_type); if (link_type == 1) { // ACL conn = connection_for_address(addr); diff --git a/src/l2cap.c b/src/l2cap.c index 7e27cdb5a..ab8ca9147 100644 --- a/src/l2cap.c +++ b/src/l2cap.c @@ -563,7 +563,8 @@ void l2cap_event_handler( uint8_t *packet, uint16_t size ){ hci_con_handle_t handle; l2cap_channel_t * channel; linked_item_t *it; - + int hci_con_used; + switch(packet[0]){ // handle connection complete events @@ -620,14 +621,14 @@ void l2cap_event_handler( uint8_t *packet, uint16_t size ){ case L2CAP_EVENT_TIMEOUT_CHECK: handle = READ_BT_16(packet, 2); if (hci_authentication_active_for_handle(handle)) break; - int used = 0; + hci_con_used = 0; for (it = (linked_item_t *) l2cap_channels; it ; it = it->next){ channel = (l2cap_channel_t *) it; if (channel->handle == handle) { - used = 1; + hci_con_used = 1; } } - if (used) break; + if (hci_con_used) break; if (!hci_can_send_packet_now(HCI_COMMAND_DATA_PACKET)) break; hci_send_cmd(&hci_disconnect, handle, 0x13); // remote closed connection break;