This is an automated email from the ASF dual-hosted git repository.

pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 75980705087dd370a53e7bdffd13bf56036d3ac3
Author: Xiang Xiao <[email protected]>
AuthorDate: Sat Mar 12 14:13:40 2022 +0800

    net: Remove the unnecessary initialization code
    
    Signed-off-by: Xiang Xiao <[email protected]>
---
 net/bluetooth/bluetooth_conn.c   |  7 -------
 net/can/can_conn.c               | 10 +---------
 net/icmp/icmp_conn.c             | 10 +---------
 net/icmpv6/icmpv6_conn.c         | 10 +---------
 net/ieee802154/ieee802154_conn.c |  7 -------
 net/netlink/netlink_conn.c       | 10 +---------
 net/pkt/pkt_conn.c               | 10 +---------
 net/route/net_cacheroute.c       |  6 ++----
 net/tcp/tcp_conn.c               |  9 ---------
 net/tcp/tcp_wrbuffer.c           |  2 --
 net/udp/udp_conn.c               | 10 +---------
 net/usrsock/usrsock_conn.c       | 10 +---------
 12 files changed, 9 insertions(+), 92 deletions(-)

diff --git a/net/bluetooth/bluetooth_conn.c b/net/bluetooth/bluetooth_conn.c
index ad57aee..cc4f6f0 100644
--- a/net/bluetooth/bluetooth_conn.c
+++ b/net/bluetooth/bluetooth_conn.c
@@ -90,14 +90,7 @@ void bluetooth_conn_initialize(void)
 {
 #ifndef CONFIG_NET_ALLOC_CONNS
   int i;
-#endif
-
-  /* Initialize the queues */
 
-  dq_init(&g_free_bluetooth_connections);
-  dq_init(&g_active_bluetooth_connections);
-
-#ifndef CONFIG_NET_ALLOC_CONNS
   for (i = 0; i < CONFIG_NET_BLUETOOTH_NCONNS; i++)
     {
       /* Link each pre-allocated connection structure into the free list. */
diff --git a/net/can/can_conn.c b/net/can/can_conn.c
index dc1ee61..dead5e9 100644
--- a/net/can/can_conn.c
+++ b/net/can/can_conn.c
@@ -56,7 +56,7 @@ static struct can_conn_s g_can_connections[CONFIG_CAN_CONNS];
 /* A list of all free NetLink connections */
 
 static dq_queue_t g_free_can_connections;
-static sem_t g_free_sem;
+static sem_t g_free_sem = SEM_INITIALIZER(1);
 
 /* A list of all allocated NetLink connections */
 
@@ -101,15 +101,7 @@ void can_initialize(void)
 {
 #ifndef CONFIG_NET_ALLOC_CONNS
   int i;
-#endif
-
-  /* Initialize the queues */
 
-  dq_init(&g_free_can_connections);
-  dq_init(&g_active_can_connections);
-  nxsem_init(&g_free_sem, 0, 1);
-
-#ifndef CONFIG_NET_ALLOC_CONNS
   for (i = 0; i < CONFIG_CAN_CONNS; i++)
     {
       /* Mark the connection closed and move it to the free list */
diff --git a/net/icmp/icmp_conn.c b/net/icmp/icmp_conn.c
index 9fcc7b3..3ab0f27 100644
--- a/net/icmp/icmp_conn.c
+++ b/net/icmp/icmp_conn.c
@@ -55,7 +55,7 @@ static struct icmp_conn_s 
g_icmp_connections[CONFIG_NET_ICMP_NCONNS];
 /* A list of all free IPPROTO_ICMP socket connections */
 
 static dq_queue_t g_free_icmp_connections;
-static sem_t g_free_sem;
+static sem_t g_free_sem = SEM_INITIALIZER(1);
 
 /* A list of all allocated IPPROTO_ICMP socket connections */
 
@@ -78,15 +78,7 @@ void icmp_sock_initialize(void)
 {
 #ifndef CONFIG_NET_ALLOC_CONNS
   int i;
-#endif
-
-  /* Initialize the queues */
 
-  dq_init(&g_free_icmp_connections);
-  dq_init(&g_active_icmp_connections);
-  nxsem_init(&g_free_sem, 0, 1);
-
-#ifndef CONFIG_NET_ALLOC_CONNS
   for (i = 0; i < CONFIG_NET_ICMP_NCONNS; i++)
     {
       /* Move the connection structure to the free list */
diff --git a/net/icmpv6/icmpv6_conn.c b/net/icmpv6/icmpv6_conn.c
index 83c19dc..b026581 100644
--- a/net/icmpv6/icmpv6_conn.c
+++ b/net/icmpv6/icmpv6_conn.c
@@ -55,7 +55,7 @@ static struct icmpv6_conn_s 
g_icmpv6_connections[CONFIG_NET_ICMPv6_NCONNS];
 /* A list of all free IPPROTO_ICMP socket connections */
 
 static dq_queue_t g_free_icmpv6_connections;
-static sem_t g_free_sem;
+static sem_t g_free_sem = SEM_INITIALIZER(1);
 
 /* A list of all allocated IPPROTO_ICMP socket connections */
 
@@ -78,15 +78,7 @@ void icmpv6_sock_initialize(void)
 {
 #ifndef CONFIG_NET_ALLOC_CONNS
   int i;
-#endif
-
-  /* Initialize the queues */
 
-  dq_init(&g_free_icmpv6_connections);
-  dq_init(&g_active_icmpv6_connections);
-  nxsem_init(&g_free_sem, 0, 1);
-
-#ifndef CONFIG_NET_ALLOC_CONNS
   for (i = 0; i < CONFIG_NET_ICMPv6_NCONNS; i++)
     {
       /* Move the connection structure to the free list */
diff --git a/net/ieee802154/ieee802154_conn.c b/net/ieee802154/ieee802154_conn.c
index 2d47f3b..1a13bf2 100644
--- a/net/ieee802154/ieee802154_conn.c
+++ b/net/ieee802154/ieee802154_conn.c
@@ -84,14 +84,7 @@ void ieee802154_conn_initialize(void)
 {
 #ifndef CONFIG_NET_ALLOC_CONNS
   int i;
-#endif
-
-  /* Initialize the queues */
 
-  dq_init(&g_free_ieee802154_connections);
-  dq_init(&g_active_ieee802154_connections);
-
-#ifndef CONFIG_NET_ALLOC_CONNS
   for (i = 0; i < CONFIG_NET_IEEE802154_NCONNS; i++)
     {
       /* Link each pre-allocated connection structure into the free list. */
diff --git a/net/netlink/netlink_conn.c b/net/netlink/netlink_conn.c
index 328317e..168d2b9 100644
--- a/net/netlink/netlink_conn.c
+++ b/net/netlink/netlink_conn.c
@@ -57,7 +57,7 @@ static struct netlink_conn_s 
g_netlink_connections[CONFIG_NETLINK_CONNS];
 /* A list of all free NetLink connections */
 
 static dq_queue_t g_free_netlink_connections;
-static sem_t g_free_sem;
+static sem_t g_free_sem = SEM_INITIALIZER(1);
 
 /* A list of all allocated NetLink connections */
 
@@ -125,15 +125,7 @@ void netlink_initialize(void)
 {
 #ifndef CONFIG_NET_ALLOC_CONNS
   int i;
-#endif
-
-  /* Initialize the queues */
 
-  dq_init(&g_free_netlink_connections);
-  dq_init(&g_active_netlink_connections);
-  nxsem_init(&g_free_sem, 0, 1);
-
-#ifndef CONFIG_NET_ALLOC_CONNS
   for (i = 0; i < CONFIG_NETLINK_CONNS; i++)
     {
       /* Mark the connection closed and move it to the free list */
diff --git a/net/pkt/pkt_conn.c b/net/pkt/pkt_conn.c
index dfee569..d348fd0 100644
--- a/net/pkt/pkt_conn.c
+++ b/net/pkt/pkt_conn.c
@@ -63,7 +63,7 @@ static struct pkt_conn_s 
g_pkt_connections[CONFIG_NET_PKT_CONNS];
 /* A list of all free packet socket connections */
 
 static dq_queue_t g_free_pkt_connections;
-static sem_t g_free_sem;
+static sem_t g_free_sem = SEM_INITIALIZER(1);
 
 /* A list of all allocated packet socket connections */
 
@@ -105,15 +105,7 @@ void pkt_initialize(void)
 {
 #ifndef CONFIG_NET_ALLOC_CONNS
   int i;
-#endif
-
-  /* Initialize the queues */
 
-  dq_init(&g_free_pkt_connections);
-  dq_init(&g_active_pkt_connections);
-  nxsem_init(&g_free_sem, 0, 1);
-
-#ifndef CONFIG_NET_ALLOC_CONNS
   for (i = 0; i < CONFIG_NET_PKT_CONNS; i++)
     {
       dq_addlast(&g_pkt_connections[i].sconn.node, &g_free_pkt_connections);
diff --git a/net/route/net_cacheroute.c b/net/route/net_cacheroute.c
index 99fc307..c6629b7 100644
--- a/net/route/net_cacheroute.c
+++ b/net/route/net_cacheroute.c
@@ -122,7 +122,7 @@ static struct net_cache_ipv4_entry_s
 
 /* Serializes access to the routing table cache */
 
-static sem_t g_ipv4_cachelock;
+static sem_t g_ipv4_cachelock = SEM_INITIALIZER(1);
 #endif
 
 #if defined(CONFIG_ROUTE_IPv6_CACHEROUTE)
@@ -141,7 +141,7 @@ static struct net_cache_ipv6_entry_s
 
 /* Serializes access to the routing table cache */
 
-static sem_t g_ipv6_cachelock;
+static sem_t g_ipv6_cachelock = SEM_INITIALIZER(1);
 #endif
 
 /****************************************************************************
@@ -481,12 +481,10 @@ void net_init_cacheroute(void)
   /* Initialize the routing table cash and the free list */
 
 #ifdef CONFIG_ROUTE_IPv4_CACHEROUTE
-  nxsem_init(&g_ipv4_cachelock, 0, 1);
   net_reset_ipv4_cache();
 #endif
 
 #ifdef CONFIG_ROUTE_IPv6_CACHEROUTE
-  nxsem_init(&g_ipv6_cachelock, 0, 1);
   net_reset_ipv6_cache();
 #endif
 }
diff --git a/net/tcp/tcp_conn.c b/net/tcp/tcp_conn.c
index adf0a1e..b74f762 100644
--- a/net/tcp/tcp_conn.c
+++ b/net/tcp/tcp_conn.c
@@ -580,16 +580,7 @@ void tcp_initialize(void)
 {
 #ifndef CONFIG_NET_ALLOC_CONNS
   int i;
-#endif
-
-  /* Initialize the queues */
-
-  dq_init(&g_free_tcp_connections);
-  dq_init(&g_active_tcp_connections);
 
-  /* Now initialize each connection structure */
-
-#ifndef CONFIG_NET_ALLOC_CONNS
   for (i = 0; i < CONFIG_NET_TCP_CONNS; i++)
     {
       /* Mark the connection closed and move it to the free list */
diff --git a/net/tcp/tcp_wrbuffer.c b/net/tcp/tcp_wrbuffer.c
index 7fb1bec..bc2644f 100644
--- a/net/tcp/tcp_wrbuffer.c
+++ b/net/tcp/tcp_wrbuffer.c
@@ -94,8 +94,6 @@ void tcp_wrbuffer_initialize(void)
 {
   int i;
 
-  sq_init(&g_wrbuffer.freebuffers);
-
   for (i = 0; i < CONFIG_NET_TCP_NWRBCHAINS; i++)
     {
       sq_addfirst(&g_wrbuffer.buffers[i].wb_node, &g_wrbuffer.freebuffers);
diff --git a/net/udp/udp_conn.c b/net/udp/udp_conn.c
index 18f27a8..7ab5e8b 100644
--- a/net/udp/udp_conn.c
+++ b/net/udp/udp_conn.c
@@ -88,7 +88,7 @@ struct udp_conn_s g_udp_connections[CONFIG_NET_UDP_CONNS];
 /* A list of all free UDP connections */
 
 static dq_queue_t g_free_udp_connections;
-static sem_t g_free_sem;
+static sem_t g_free_sem = SEM_INITIALIZER(1);
 
 /* A list of all allocated UDP connections */
 
@@ -580,15 +580,7 @@ void udp_initialize(void)
 {
 #ifndef CONFIG_NET_ALLOC_CONNS
   int i;
-#endif
-
-  /* Initialize the queues */
 
-  dq_init(&g_free_udp_connections);
-  dq_init(&g_active_udp_connections);
-  nxsem_init(&g_free_sem, 0, 1);
-
-#ifndef CONFIG_NET_ALLOC_CONNS
   for (i = 0; i < CONFIG_NET_UDP_CONNS; i++)
     {
       /* Mark the connection closed and move it to the free list */
diff --git a/net/usrsock/usrsock_conn.c b/net/usrsock/usrsock_conn.c
index d6daac9..7bef3da 100644
--- a/net/usrsock/usrsock_conn.c
+++ b/net/usrsock/usrsock_conn.c
@@ -53,7 +53,7 @@ static struct usrsock_conn_s 
g_usrsock_connections[CONFIG_NET_USRSOCK_CONNS];
 /* A list of all free usrsock connections */
 
 static dq_queue_t g_free_usrsock_connections;
-static sem_t g_free_sem;
+static sem_t g_free_sem = SEM_INITIALIZER(1);
 
 /* A list of all allocated usrsock connections */
 
@@ -333,15 +333,7 @@ void usrsock_initialize(void)
 #ifndef CONFIG_NET_ALLOC_CONNS
   FAR struct usrsock_conn_s *conn;
   int i;
-#endif
-
-  /* Initialize the queues */
 
-  dq_init(&g_free_usrsock_connections);
-  dq_init(&g_active_usrsock_connections);
-  nxsem_init(&g_free_sem, 0, 1);
-
-#ifndef CONFIG_NET_ALLOC_CONNS
   for (i = 0; i < CONFIG_NET_USRSOCK_CONNS; i++)
     {
       conn = &g_usrsock_connections[i];

Reply via email to