mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-21 21:41:13 +00:00
fix -Wshadow warnings for libusb target
This commit is contained in:
parent
ebffa4a83a
commit
204e94f19f
@ -61,7 +61,7 @@
|
||||
|
||||
static linked_list_t gatt_client_connections = NULL;
|
||||
static linked_list_t gatt_subclients = NULL;
|
||||
static uint16_t gatt_client_id = 0;
|
||||
static uint16_t next_gatt_client_id = 0;
|
||||
static uint8_t pts_suppress_mtu_exchange;
|
||||
|
||||
static void gatt_client_att_packet_handler(uint8_t packet_type, uint16_t handle, uint8_t *packet, uint16_t size);
|
||||
@ -77,12 +77,12 @@ static uint16_t peripheral_mtu(gatt_client_t *peripheral){
|
||||
}
|
||||
|
||||
static uint16_t gatt_client_next_id(void){
|
||||
if (gatt_client_id < 0xFFFF) {
|
||||
gatt_client_id++;
|
||||
if (next_gatt_client_id < 0xFFFF) {
|
||||
next_gatt_client_id++;
|
||||
} else {
|
||||
gatt_client_id = 1;
|
||||
next_gatt_client_id = 1;
|
||||
}
|
||||
return gatt_client_id;
|
||||
return next_gatt_client_id;
|
||||
}
|
||||
|
||||
static gatt_client_callback_t gatt_client_callback_for_id(uint16_t id){
|
||||
|
@ -9,7 +9,7 @@ COMMON += hci_transport_h2_libusb.c run_loop_posix.c remote_device_db_fs.c
|
||||
include ${BTSTACK_ROOT}/example/embedded/Makefile.inc
|
||||
|
||||
# CC = gcc-fsf-4.9
|
||||
CFLAGS += -g -Wall -Wmissing-prototypes -Werror
|
||||
CFLAGS += -g -Wall -Wmissing-prototypes -Wstrict-prototypes -Wshadow -Werror
|
||||
# CFLAGS += -Werror
|
||||
|
||||
CFLAGS += -I${POSIX_ROOT}/src
|
||||
|
@ -466,25 +466,25 @@ static int scan_for_bt_device(libusb_device **devs, int start_index) {
|
||||
}
|
||||
#endif
|
||||
|
||||
static int prepare_device(libusb_device_handle * handle){
|
||||
static int prepare_device(libusb_device_handle * aHandle){
|
||||
|
||||
int r;
|
||||
int kernel_driver_detached = 0;
|
||||
|
||||
// Detach OS driver (not possible for OS X and WIN32)
|
||||
#if !defined(__APPLE__) && !defined(_WIN32)
|
||||
r = libusb_kernel_driver_active(handle, 0);
|
||||
r = libusb_kernel_driver_active(aHandle, 0);
|
||||
if (r < 0) {
|
||||
log_error("libusb_kernel_driver_active error %d", r);
|
||||
libusb_close(handle);
|
||||
libusb_close(aHandle);
|
||||
return r;
|
||||
}
|
||||
|
||||
if (r == 1) {
|
||||
r = libusb_detach_kernel_driver(handle, 0);
|
||||
r = libusb_detach_kernel_driver(aHandle, 0);
|
||||
if (r < 0) {
|
||||
log_error("libusb_detach_kernel_driver error %d", r);
|
||||
libusb_close(handle);
|
||||
libusb_close(aHandle);
|
||||
return r;
|
||||
}
|
||||
kernel_driver_detached = 1;
|
||||
@ -494,43 +494,43 @@ static int prepare_device(libusb_device_handle * handle){
|
||||
|
||||
const int configuration = 1;
|
||||
log_info("setting configuration %d...", configuration);
|
||||
r = libusb_set_configuration(handle, configuration);
|
||||
r = libusb_set_configuration(aHandle, configuration);
|
||||
if (r < 0) {
|
||||
log_error("Error libusb_set_configuration: %d", r);
|
||||
if (kernel_driver_detached){
|
||||
libusb_attach_kernel_driver(handle, 0);
|
||||
libusb_attach_kernel_driver(aHandle, 0);
|
||||
}
|
||||
libusb_close(handle);
|
||||
libusb_close(aHandle);
|
||||
return r;
|
||||
}
|
||||
|
||||
// reserve access to device
|
||||
log_info("claiming interface 0...");
|
||||
r = libusb_claim_interface(handle, 0);
|
||||
r = libusb_claim_interface(aHandle, 0);
|
||||
if (r < 0) {
|
||||
log_error("Error claiming interface %d", r);
|
||||
if (kernel_driver_detached){
|
||||
libusb_attach_kernel_driver(handle, 0);
|
||||
libusb_attach_kernel_driver(aHandle, 0);
|
||||
}
|
||||
libusb_close(handle);
|
||||
libusb_close(aHandle);
|
||||
return r;
|
||||
}
|
||||
|
||||
#ifdef HAVE_SCO
|
||||
log_info("claiming interface 1...");
|
||||
r = libusb_claim_interface(handle, 1);
|
||||
r = libusb_claim_interface(aHandle, 1);
|
||||
if (r < 0) {
|
||||
log_error("Error claiming interface %d", r);
|
||||
if (kernel_driver_detached){
|
||||
libusb_attach_kernel_driver(handle, 0);
|
||||
libusb_attach_kernel_driver(aHandle, 0);
|
||||
}
|
||||
libusb_close(handle);
|
||||
libusb_close(aHandle);
|
||||
return r;
|
||||
}
|
||||
r = libusb_set_interface_alt_setting(handle, 1, 5); // 3 x 8 kHz voice channels
|
||||
r = libusb_set_interface_alt_setting(aHandle, 1, 5); // 3 x 8 kHz voice channels
|
||||
if (r < 0) {
|
||||
fprintf(stderr, "Error setting alternative setting 5 for interface 1: %s\n", libusb_error_name(r));
|
||||
libusb_close(handle);
|
||||
libusb_close(aHandle);
|
||||
return r;
|
||||
}
|
||||
#endif
|
||||
|
18
src/hci.c
18
src/hci.c
@ -1663,13 +1663,13 @@ static void event_handler(uint8_t *packet, int size){
|
||||
if (packet[0] == HCI_EVENT_DISCONNECTION_COMPLETE){
|
||||
if (!packet[2]){
|
||||
handle = READ_BT_16(packet, 3);
|
||||
hci_connection_t * conn = hci_connection_for_handle(handle);
|
||||
if (conn) {
|
||||
uint8_t status = conn->bonding_status;
|
||||
uint16_t flags = conn->bonding_flags;
|
||||
hci_connection_t * aConn = hci_connection_for_handle(handle);
|
||||
if (aConn) {
|
||||
uint8_t status = aConn->bonding_status;
|
||||
uint16_t flags = aConn->bonding_flags;
|
||||
bd_addr_t bd_address;
|
||||
memcpy(&bd_address, conn->address, 6);
|
||||
hci_shutdown_connection(conn);
|
||||
memcpy(&bd_address, aConn->address, 6);
|
||||
hci_shutdown_connection(aConn);
|
||||
// connection struct is gone, don't access anymore
|
||||
if (flags & BONDING_EMIT_COMPLETE_ON_DISCONNECT){
|
||||
hci_emit_dedicated_bonding_result(bd_address, status);
|
||||
@ -2098,7 +2098,6 @@ void hci_local_bd_addr(bd_addr_t address_buffer){
|
||||
void hci_run(void){
|
||||
|
||||
// log_info("hci_run: entered");
|
||||
hci_connection_t * connection;
|
||||
linked_item_t * it;
|
||||
|
||||
// send continuation fragments first, as they block the prepared packet buffer
|
||||
@ -2263,7 +2262,7 @@ void hci_run(void){
|
||||
|
||||
// send pending HCI commands
|
||||
for (it = (linked_item_t *) hci_stack->connections; it ; it = it->next){
|
||||
connection = (hci_connection_t *) it;
|
||||
hci_connection_t * connection = (hci_connection_t *) it;
|
||||
|
||||
switch(connection->state){
|
||||
case SEND_CREATE_CONNECTION:
|
||||
@ -2417,7 +2416,8 @@ void hci_run(void){
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
hci_connection_t * connection;
|
||||
switch (hci_stack->state){
|
||||
case HCI_STATE_INITIALIZING:
|
||||
hci_initializing_run();
|
||||
|
16
src/l2cap.c
16
src/l2cap.c
@ -769,7 +769,7 @@ static void l2cap_handle_remote_supported_features_received(l2cap_channel_t * ch
|
||||
}
|
||||
|
||||
// open outgoing L2CAP channel
|
||||
void l2cap_create_channel_internal(void * connection, btstack_packet_handler_t packet_handler,
|
||||
void l2cap_create_channel_internal(void * connection, btstack_packet_handler_t channel_packet_handler,
|
||||
bd_addr_t address, uint16_t psm, uint16_t mtu){
|
||||
|
||||
log_info("L2CAP_CREATE_CHANNEL_MTU addr %s psm 0x%x mtu %u", bd_addr_to_str(address), psm, mtu);
|
||||
@ -796,7 +796,7 @@ void l2cap_create_channel_internal(void * connection, btstack_packet_handler_t p
|
||||
chan->psm = psm;
|
||||
chan->handle = 0;
|
||||
chan->connection = connection;
|
||||
chan->packet_handler = packet_handler;
|
||||
chan->packet_handler = channel_packet_handler;
|
||||
chan->remote_mtu = L2CAP_MINIMAL_MTU;
|
||||
chan->local_mtu = mtu;
|
||||
chan->packets_granted = 0;
|
||||
@ -1526,7 +1526,7 @@ static inline l2cap_service_t * l2cap_get_service(uint16_t psm){
|
||||
return l2cap_get_service_internal(&l2cap_services, psm);
|
||||
}
|
||||
|
||||
void l2cap_register_service_internal(void *connection, btstack_packet_handler_t packet_handler, uint16_t psm, uint16_t mtu, gap_security_level_t security_level){
|
||||
void l2cap_register_service_internal(void *connection, btstack_packet_handler_t service_packet_handler, uint16_t psm, uint16_t mtu, gap_security_level_t security_level){
|
||||
|
||||
log_info("L2CAP_REGISTER_SERVICE psm 0x%x mtu %u connection %p", psm, mtu, connection);
|
||||
|
||||
@ -1552,7 +1552,7 @@ void l2cap_register_service_internal(void *connection, btstack_packet_handler_t
|
||||
service->psm = psm;
|
||||
service->mtu = mtu;
|
||||
service->connection = connection;
|
||||
service->packet_handler = packet_handler;
|
||||
service->packet_handler = service_packet_handler;
|
||||
service->required_security_level = security_level;
|
||||
|
||||
// add to services list
|
||||
@ -1580,16 +1580,16 @@ void l2cap_unregister_service_internal(void *connection, uint16_t psm){
|
||||
}
|
||||
|
||||
// Bluetooth 4.0 - allows to register handler for Attribute Protocol and Security Manager Protocol
|
||||
void l2cap_register_fixed_channel(btstack_packet_handler_t packet_handler, uint16_t channel_id) {
|
||||
void l2cap_register_fixed_channel(btstack_packet_handler_t the_packet_handler, uint16_t channel_id) {
|
||||
switch(channel_id){
|
||||
case L2CAP_CID_ATTRIBUTE_PROTOCOL:
|
||||
attribute_protocol_packet_handler = packet_handler;
|
||||
attribute_protocol_packet_handler = the_packet_handler;
|
||||
break;
|
||||
case L2CAP_CID_SECURITY_MANAGER_PROTOCOL:
|
||||
security_protocol_packet_handler = packet_handler;
|
||||
security_protocol_packet_handler = the_packet_handler;
|
||||
break;
|
||||
case L2CAP_CID_CONNECTIONLESS_CHANNEL:
|
||||
connectionless_channel_packet_handler = packet_handler;
|
||||
connectionless_channel_packet_handler = the_packet_handler;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
18
src/rfcomm.c
18
src/rfcomm.c
@ -1146,12 +1146,12 @@ static void rfcomm_multiplexer_state_machine(rfcomm_multiplexer_t * multiplexer,
|
||||
rfcomm_send_uih_fc_rsp(multiplexer, multiplexer->fcon);
|
||||
if (multiplexer->fcon == 0) return;
|
||||
// trigger client to send again after sending FCon Response
|
||||
uint8_t event[] = { DAEMON_EVENT_HCI_PACKET_SENT, 0};
|
||||
uint8_t packet_sent_event[] = { DAEMON_EVENT_HCI_PACKET_SENT, 0};
|
||||
linked_item_t *it;
|
||||
for (it = (linked_item_t *) rfcomm_channels; it ; it = it->next){
|
||||
rfcomm_channel_t * channel = ((rfcomm_channel_t *) it);
|
||||
if (channel->multiplexer != multiplexer) continue;
|
||||
(*app_packet_handler)(channel->connection, HCI_EVENT_PACKET, 0, (uint8_t *) event, sizeof(event));
|
||||
(*app_packet_handler)(channel->connection, HCI_EVENT_PACKET, 0, (uint8_t *) packet_sent_event, sizeof(packet_sent_event));
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -1714,11 +1714,11 @@ static void rfcomm_channel_state_machine(rfcomm_channel_t *channel, rfcomm_chann
|
||||
if (event->type == CH_EVT_RCVD_MSC_CMD){
|
||||
// notify client about new settings
|
||||
rfcomm_channel_event_msc_t *event_msc = (rfcomm_channel_event_msc_t*) event;
|
||||
uint8_t event[2+1];
|
||||
event[0] = RFCOMM_EVENT_REMOTE_MODEM_STATUS;
|
||||
event[1] = 1;
|
||||
event[2] = event_msc->modem_status;
|
||||
(*app_packet_handler)(channel->connection, HCI_EVENT_PACKET, channel->rfcomm_cid, (uint8_t*)&event, sizeof(event));
|
||||
uint8_t modem_status_event[2+1];
|
||||
modem_status_event[0] = RFCOMM_EVENT_REMOTE_MODEM_STATUS;
|
||||
modem_status_event[1] = 1;
|
||||
modem_status_event[2] = event_msc->modem_status;
|
||||
(*app_packet_handler)(channel->connection, HCI_EVENT_PACKET, channel->rfcomm_cid, (uint8_t*)&modem_status_event, sizeof(modem_status_event));
|
||||
// no return, MSC_CMD will be handled by state machine below
|
||||
}
|
||||
|
||||
@ -1903,8 +1903,8 @@ static void rfcomm_channel_state_machine(rfcomm_channel_t *channel, rfcomm_chann
|
||||
break;
|
||||
case CH_EVT_RCVD_CREDITS: {
|
||||
// notify daemon -> might trigger re-try of parked connections
|
||||
uint8_t event[2] = { DAEMON_EVENT_NEW_RFCOMM_CREDITS, 0 };
|
||||
(*app_packet_handler)(channel->connection, DAEMON_EVENT_PACKET, channel->rfcomm_cid, event, sizeof(event));
|
||||
uint8_t credits_event[2] = { DAEMON_EVENT_NEW_RFCOMM_CREDITS, 0 };
|
||||
(*app_packet_handler)(channel->connection, DAEMON_EVENT_PACKET, channel->rfcomm_cid, credits_event, sizeof(credits_event));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -72,11 +72,11 @@ static void (*sdp_query_callback)(sdp_query_event_t * event);
|
||||
static de_state_t de_header_state;
|
||||
|
||||
|
||||
void de_state_init(de_state_t * state){
|
||||
state->in_state_GET_DE_HEADER_LENGTH = 1;
|
||||
state->addon_header_bytes = 0;
|
||||
state->de_size = 0;
|
||||
state->de_offset = 0;
|
||||
void de_state_init(de_state_t * de_state){
|
||||
de_state->in_state_GET_DE_HEADER_LENGTH = 1;
|
||||
de_state->addon_header_bytes = 0;
|
||||
de_state->de_size = 0;
|
||||
de_state->de_offset = 0;
|
||||
}
|
||||
|
||||
int de_state_size(uint8_t eventByte, de_state_t *de_state){
|
||||
|
Loading…
x
Reference in New Issue
Block a user