diff --git a/net/bluetooth/bluetooth_conn.c b/net/bluetooth/bluetooth_conn.c index 9851710d9b3..c0b11a5f9d4 100644 --- a/net/bluetooth/bluetooth_conn.c +++ b/net/bluetooth/bluetooth_conn.c @@ -205,13 +205,10 @@ void bluetooth_conn_free(FAR struct bluetooth_conn_s *conn) bluetooth_container_free(container); } - /* Reset structure */ - - memset(conn, 0, sizeof(*conn)); - /* If this is a preallocated or a batch allocated connection store it in * the free connections list. Else free it. */ + #if CONFIG_NET_BLUETOOTH_ALLOC_CONNS == 1 if (conn < g_bluetooth_connections || conn >= (g_bluetooth_connections + CONFIG_NET_BLUETOOTH_PREALLOC_CONNS)) @@ -221,6 +218,7 @@ void bluetooth_conn_free(FAR struct bluetooth_conn_s *conn) else #endif { + memset(conn, 0, sizeof(*conn)); dq_addlast(&conn->bc_conn.node, &g_free_bluetooth_connections); } diff --git a/net/can/can_conn.c b/net/can/can_conn.c index 4310bc81bb7..28f1a46001a 100644 --- a/net/can/can_conn.c +++ b/net/can/can_conn.c @@ -182,10 +182,6 @@ void can_free(FAR struct can_conn_s *conn) dq_rem(&conn->sconn.node, &g_active_can_connections); - /* Reset structure */ - - memset(conn, 0, sizeof(*conn)); - /* If this is a preallocated or a batch allocated connection store it in * the free connections list. Else free it. */ @@ -199,6 +195,7 @@ void can_free(FAR struct can_conn_s *conn) else #endif { + memset(conn, 0, sizeof(*conn)); dq_addlast(&conn->sconn.node, &g_free_can_connections); } diff --git a/net/icmp/icmp_conn.c b/net/icmp/icmp_conn.c index 2ddcc6903dc..a727ce7e1e7 100644 --- a/net/icmp/icmp_conn.c +++ b/net/icmp/icmp_conn.c @@ -182,10 +182,6 @@ void icmp_free(FAR struct icmp_conn_s *conn) dq_rem(&conn->sconn.node, &g_active_icmp_connections); - /* Clear the connection structure */ - - memset(conn, 0, sizeof(*conn)); - /* If this is a preallocated or a batch allocated connection store it * in the free connections list. Else free it. */ @@ -199,6 +195,7 @@ void icmp_free(FAR struct icmp_conn_s *conn) else #endif { + memset(conn, 0, sizeof(*conn)); dq_addlast(&conn->sconn.node, &g_free_icmp_connections); } } diff --git a/net/icmpv6/icmpv6_conn.c b/net/icmpv6/icmpv6_conn.c index 4299fb62ac1..ae5007a2b30 100644 --- a/net/icmpv6/icmpv6_conn.c +++ b/net/icmpv6/icmpv6_conn.c @@ -172,13 +172,10 @@ void icmpv6_free(FAR struct icmpv6_conn_s *conn) dq_rem(&conn->sconn.node, &g_active_icmpv6_connections); - /* Clear the connection structure */ - - memset(conn, 0, sizeof(*conn)); - /* If this is a preallocated or a batch allocated connection store it in * the free connections list. Else free it. */ + #if CONFIG_NET_ICMPv6_ALLOC_CONNS == 1 if (conn < g_icmpv6_connections || conn >= (g_icmpv6_connections + CONFIG_NET_ICMPv6_PREALLOC_CONNS)) @@ -188,6 +185,7 @@ void icmpv6_free(FAR struct icmpv6_conn_s *conn) else #endif { + memset(conn, 0, sizeof(*conn)); dq_addlast(&conn->sconn.node, &g_free_icmpv6_connections); } diff --git a/net/ieee802154/ieee802154_conn.c b/net/ieee802154/ieee802154_conn.c index a6133a100f3..b7a5e25f814 100644 --- a/net/ieee802154/ieee802154_conn.c +++ b/net/ieee802154/ieee802154_conn.c @@ -194,10 +194,6 @@ void ieee802154_conn_free(FAR struct ieee802154_conn_s *conn) ieee802154_container_free(container); } - /* Enqueue the connection into the active list */ - - memset(conn, 0, sizeof(*conn)); - /* If this is a preallocated or a batch allocated connection store it in * the free connections list. Else free it. */ @@ -211,6 +207,7 @@ void ieee802154_conn_free(FAR struct ieee802154_conn_s *conn) else #endif { + memset(conn, 0, sizeof(*conn)); dq_addlast(&conn->sconn.node, &g_free_ieee802154_connections); } diff --git a/net/netlink/netlink_conn.c b/net/netlink/netlink_conn.c index 443e004b0bf..c31eeaccc9c 100644 --- a/net/netlink/netlink_conn.c +++ b/net/netlink/netlink_conn.c @@ -205,10 +205,6 @@ void netlink_free(FAR struct netlink_conn_s *conn) kmm_free(resp); } - /* Reset structure */ - - memset(conn, 0, sizeof(*conn)); - /* If this is a preallocated or a batch allocated connection store it in * the free connections list. Else free it. */ @@ -222,6 +218,7 @@ void netlink_free(FAR struct netlink_conn_s *conn) else #endif { + memset(conn, 0, sizeof(*conn)); dq_addlast(&conn->sconn.node, &g_free_netlink_connections); } diff --git a/net/pkt/pkt_conn.c b/net/pkt/pkt_conn.c index a7663a764eb..6693d61571b 100644 --- a/net/pkt/pkt_conn.c +++ b/net/pkt/pkt_conn.c @@ -169,10 +169,6 @@ void pkt_free(FAR struct pkt_conn_s *conn) dq_rem(&conn->sconn.node, &g_active_pkt_connections); - /* Make sure that the connection is marked as uninitialized */ - - memset(conn, 0, sizeof(*conn)); - /* If this is a preallocated or a batch allocated connection store it in * the free connections list. Else free it. */ @@ -186,6 +182,7 @@ void pkt_free(FAR struct pkt_conn_s *conn) else #endif { + memset(conn, 0, sizeof(*conn)); dq_addlast(&conn->sconn.node, &g_free_pkt_connections); } diff --git a/net/udp/udp_conn.c b/net/udp/udp_conn.c index 6b3cc628f74..48202cf622c 100644 --- a/net/udp/udp_conn.c +++ b/net/udp/udp_conn.c @@ -712,10 +712,6 @@ void udp_free(FAR struct udp_conn_s *conn) #endif - /* Clear the connection structure */ - - memset(conn, 0, sizeof(*conn)); - /* Free the connection. * If this is a preallocated or a batch allocated connection store it in * the free connections list. Else free it. @@ -730,6 +726,7 @@ void udp_free(FAR struct udp_conn_s *conn) else #endif { + memset(conn, 0, sizeof(*conn)); dq_addlast(&conn->sconn.node, &g_free_udp_connections); } diff --git a/net/usrsock/usrsock_conn.c b/net/usrsock/usrsock_conn.c index 675a3ca3f7b..c11cf8de952 100644 --- a/net/usrsock/usrsock_conn.c +++ b/net/usrsock/usrsock_conn.c @@ -151,7 +151,6 @@ void usrsock_free(FAR struct usrsock_conn_s *conn) /* Reset structure */ nxsem_destroy(&conn->resp.sem); - memset(conn, 0, sizeof(*conn)); /* If this is a preallocated or a batch allocated connection store it in * the free connections list. Else free it. @@ -166,6 +165,7 @@ void usrsock_free(FAR struct usrsock_conn_s *conn) else #endif { + memset(conn, 0, sizeof(*conn)); dq_addlast(&conn->sconn.node, &g_free_usrsock_connections); }