don't declare variables in switch cases

This commit is contained in:
matthias.ringwald 2011-07-22 10:14:38 +00:00
parent 7d3b3569b0
commit 2d00edd4aa
2 changed files with 7 additions and 5 deletions

View File

@ -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);

View File

@ -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;