remove explicit memset call for buffers from btstack_memory

This commit is contained in:
Matthias Ringwald 2018-11-23 17:41:43 +01:00
parent a2673d8810
commit 6fff232482
10 changed files with 1 additions and 23 deletions

View File

@ -162,7 +162,6 @@ static gatt_client_t * provide_context_for_conn_handle(hci_con_handle_t con_hand
context = btstack_memory_gatt_client_get();
if (!context) return NULL;
// init state
memset(context, 0, sizeof(gatt_client_t));
context->con_handle = con_handle;
context->mtu = ATT_DEFAULT_MTU;
if (mtu_exchange_enabled){

View File

@ -316,7 +316,6 @@ avdtp_connection_t * avdtp_create_connection(bd_addr_t remote_addr, avdtp_contex
log_error("Not enough memory to create connection");
return NULL;
}
memset(connection, 0, sizeof(avdtp_connection_t));
connection->state = AVDTP_SIGNALING_CONNECTION_IDLE;
connection->initiator_transaction_label = avdtp_get_next_initiator_transaction_label(context);
connection->avdtp_cid = avdtp_get_next_avdtp_cid();
@ -332,7 +331,6 @@ avdtp_stream_endpoint_t * avdtp_create_stream_endpoint(avdtp_sep_type_t sep_type
log_error("Not enough memory to create stream endpoint");
return NULL;
}
memset(stream_endpoint, 0, sizeof(avdtp_stream_endpoint_t));
stream_endpoint->sep.seid = avdtp_get_next_local_seid(context);
stream_endpoint->sep.media_type = media_type;
stream_endpoint->sep.type = sep_type;

View File

@ -371,7 +371,6 @@ static avrcp_connection_t * avrcp_create_connection(bd_addr_t remote_addr, avrcp
log_error("avrcp: not enough memory to create connection");
return NULL;
}
memset(connection, 0, sizeof(avrcp_connection_t));
connection->state = AVCTP_CONNECTION_IDLE;
connection->transaction_label = 0xFF;
connection->max_num_fragments = 0xFF;

View File

@ -127,7 +127,6 @@ static void avrcp_emit_browsing_connection_closed(btstack_packet_handler_t callb
static avrcp_browsing_connection_t * avrcp_browsing_create_connection(avrcp_connection_t * avrcp_connection){
avrcp_browsing_connection_t * connection = btstack_memory_avrcp_browsing_connection_get();
memset(connection, 0, sizeof(avrcp_browsing_connection_t));
connection->state = AVCTP_CONNECTION_IDLE;
connection->transaction_label = 0xFF;
avrcp_connection->avrcp_browsing_cid = avrcp_get_next_cid();

View File

@ -198,7 +198,6 @@ static void avrcp_emit_browsing_connection_closed(btstack_packet_handler_t callb
static avrcp_browsing_connection_t * avrcp_browsing_create_connection(avrcp_connection_t * avrcp_connection){
avrcp_browsing_connection_t * connection = btstack_memory_avrcp_browsing_connection_get();
memset(connection, 0, sizeof(avrcp_browsing_connection_t));
connection->state = AVCTP_CONNECTION_IDLE;
connection->transaction_label = 0xFF;
avrcp_connection->avrcp_browsing_cid = avrcp_get_next_cid();

View File

@ -703,9 +703,6 @@ static bnep_channel_t * bnep_channel_create_for_addr(bd_addr_t addr)
return NULL;
}
/* Initialize the channel struct */
memset(channel, 0, sizeof(bnep_channel_t));
channel->state = BNEP_CHANNEL_STATE_CLOSED;
channel->max_frame_size = bnep_max_frame_size_for_l2cap_mtu(l2cap_max_mtu());
bd_addr_copy(channel->remote_addr, addr);
@ -1600,7 +1597,6 @@ uint8_t bnep_register_service(btstack_packet_handler_t packet_handler, uint16_t
if (!service) {
return BTSTACK_MEMORY_ALLOC_FAILED;
}
memset(service, 0, sizeof(bnep_service_t));
/* register with l2cap if not registered before, max MTU */
l2cap_register_service(bnep_packet_handler, BLUETOOTH_PROTOCOL_BNEP, 0xffff, bnep_security_level);

View File

@ -355,8 +355,6 @@ void hfp_reset_context_flags(hfp_connection_t * hfp_connection){
static hfp_connection_t * create_hfp_connection_context(void){
hfp_connection_t * hfp_connection = btstack_memory_hfp_connection_get();
if (!hfp_connection) return NULL;
// init state
memset(hfp_connection,0, sizeof(hfp_connection_t));
hfp_connection->state = HFP_IDLE;
hfp_connection->call_state = HFP_CALL_IDLE;

View File

@ -284,9 +284,6 @@ static uint16_t rfcomm_max_frame_size_for_l2cap_mtu(uint16_t l2cap_mtu){
}
static void rfcomm_multiplexer_initialize(rfcomm_multiplexer_t *multiplexer){
memset(multiplexer, 0, sizeof(rfcomm_multiplexer_t));
multiplexer->state = RFCOMM_MULTIPLEXER_CLOSED;
multiplexer->fcon = 1;
multiplexer->send_dm_for_dlci = 0;
@ -363,10 +360,7 @@ static void rfcomm_channel_initialize(rfcomm_channel_t *channel, rfcomm_multiple
// don't use 0 as channel id
if (rfcomm_client_cid_generator == 0) ++rfcomm_client_cid_generator;
// setup channel
memset(channel, 0, sizeof(rfcomm_channel_t));
// set defaults for port configuration (even for services)
rfcomm_rpn_data_set_defaults(&channel->rpn_data);

View File

@ -186,7 +186,6 @@ static hci_connection_t * create_connection_for_bd_addr_and_type(bd_addr_t addr,
log_info("create_connection_for_addr %s, type %x", bd_addr_to_str(addr), addr_type);
hci_connection_t * conn = btstack_memory_hci_connection_get();
if (!conn) return NULL;
memset(conn, 0, sizeof(hci_connection_t));
bd_addr_copy(conn->address, addr);
conn->address_type = addr_type;
conn->con_handle = 0xffff;

View File

@ -1799,9 +1799,6 @@ static l2cap_channel_t * l2cap_create_channel_entry(btstack_packet_handler_t pac
if (!channel) {
return NULL;
}
// Init memory (make valgrind happy)
memset(channel, 0, sizeof(l2cap_channel_t));
// fill in
channel->packet_handler = packet_handler;