diff --git a/src/ble/gatt_client.c b/src/ble/gatt_client.c index ddfcc7dda..a2f84625a 100644 --- a/src/ble/gatt_client.c +++ b/src/ble/gatt_client.c @@ -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){ diff --git a/src/classic/avdtp.c b/src/classic/avdtp.c index 78d0a24ba..5e8c46fdf 100644 --- a/src/classic/avdtp.c +++ b/src/classic/avdtp.c @@ -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; diff --git a/src/classic/avrcp.c b/src/classic/avrcp.c index f9956b0e4..2be681647 100644 --- a/src/classic/avrcp.c +++ b/src/classic/avrcp.c @@ -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; diff --git a/src/classic/avrcp_browsing_controller.c b/src/classic/avrcp_browsing_controller.c index d9c469daf..23e4cc465 100644 --- a/src/classic/avrcp_browsing_controller.c +++ b/src/classic/avrcp_browsing_controller.c @@ -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(); diff --git a/src/classic/avrcp_browsing_target.c b/src/classic/avrcp_browsing_target.c index 039e38875..be2d077f1 100644 --- a/src/classic/avrcp_browsing_target.c +++ b/src/classic/avrcp_browsing_target.c @@ -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(); diff --git a/src/classic/bnep.c b/src/classic/bnep.c index 44bcc347b..415302fff 100644 --- a/src/classic/bnep.c +++ b/src/classic/bnep.c @@ -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); diff --git a/src/classic/hfp.c b/src/classic/hfp.c index 77620b17f..f82b14538 100644 --- a/src/classic/hfp.c +++ b/src/classic/hfp.c @@ -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; diff --git a/src/classic/rfcomm.c b/src/classic/rfcomm.c index f6e9565d5..e7e552e7e 100644 --- a/src/classic/rfcomm.c +++ b/src/classic/rfcomm.c @@ -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); diff --git a/src/hci.c b/src/hci.c index e5751f17f..a8804f039 100644 --- a/src/hci.c +++ b/src/hci.c @@ -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; diff --git a/src/l2cap.c b/src/l2cap.c index 9bfd9a84d..25aebfc71 100644 --- a/src/l2cap.c +++ b/src/l2cap.c @@ -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;