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

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


The following commit(s) were added to refs/heads/master by this push:
     new aba8cd4d863 net/net_initialize: remove the empty functions that are 
not needed
aba8cd4d863 is described below

commit aba8cd4d8639aa18c9160015342df36405667cdb
Author: zhanghongyu <[email protected]>
AuthorDate: Tue May 13 11:32:07 2025 +0800

    net/net_initialize: remove the empty functions that are not needed
    
    streamline the code structure
    
    Signed-off-by: zhanghongyu <[email protected]>
---
 net/can/can.h                | 13 -------
 net/can/can_conn.c           | 13 -------
 net/devif/CMakeLists.txt     |  2 +-
 net/devif/Make.defs          |  2 +-
 net/devif/devif.h            | 16 --------
 net/devif/devif_callback.c   | 11 ++++++
 net/devif/devif_initialize.c | 92 --------------------------------------------
 net/ipforward/ipforward.h    | 13 -------
 net/ipforward/ipfwd_alloc.c  | 22 +----------
 net/net_initialize.c         | 40 -------------------
 net/netlink/netlink.h        | 11 ------
 net/netlink/netlink_conn.c   | 13 -------
 net/pkt/pkt.h                | 11 ------
 net/pkt/pkt_conn.c           | 13 -------
 net/tcp/tcp.h                | 11 ------
 net/tcp/tcp_conn.c           | 13 -------
 net/udp/udp.h                | 11 ------
 net/udp/udp_conn.c           | 13 -------
 18 files changed, 15 insertions(+), 305 deletions(-)

diff --git a/net/can/can.h b/net/can/can.h
index feaec373a03..a6a24860d9c 100644
--- a/net/can/can.h
+++ b/net/can/can.h
@@ -149,19 +149,6 @@ EXTERN const struct sock_intf_s g_can_sockif;
  * Public Function Prototypes
  ****************************************************************************/
 
-struct sockaddr_can;  /* Forward reference */
-
-/****************************************************************************
- * Name: can_initialize()
- *
- * Description:
- *   Initialize the NetLink connection structures.  Called once and only
- *   from the networking layer.
- *
- ****************************************************************************/
-
-void can_initialize(void);
-
 /****************************************************************************
  * Name: can_alloc()
  *
diff --git a/net/can/can_conn.c b/net/can/can_conn.c
index 3d0fe2f1fe5..bdd04d3b455 100644
--- a/net/can/can_conn.c
+++ b/net/can/can_conn.c
@@ -71,19 +71,6 @@ static dq_queue_t g_active_can_connections;
  * Public Functions
  ****************************************************************************/
 
-/****************************************************************************
- * Name: can_initialize()
- *
- * Description:
- *   Initialize the User Socket connection structures.  Called once and only
- *   from the networking layer.
- *
- ****************************************************************************/
-
-void can_initialize(void)
-{
-}
-
 /****************************************************************************
  * Name: can_alloc()
  *
diff --git a/net/devif/CMakeLists.txt b/net/devif/CMakeLists.txt
index 158da45c13c..6fed6dec131 100644
--- a/net/devif/CMakeLists.txt
+++ b/net/devif/CMakeLists.txt
@@ -20,7 +20,7 @@
 #
 # 
##############################################################################
 
-set(SRCS devif_initialize.c devif_callback.c)
+set(SRCS devif_callback.c)
 
 # Device driver IP packet receipt interfaces
 
diff --git a/net/devif/Make.defs b/net/devif/Make.defs
index 1871c297517..5eb38130f76 100644
--- a/net/devif/Make.defs
+++ b/net/devif/Make.defs
@@ -22,7 +22,7 @@
 
 # Network device interface source files
 
-NET_CSRCS += devif_initialize.c devif_callback.c
+NET_CSRCS += devif_callback.c
 
 # Device driver IP packet receipt interfaces
 
diff --git a/net/devif/devif.h b/net/devif/devif.h
index 875e21f1508..e63abcf9b8f 100644
--- a/net/devif/devif.h
+++ b/net/devif/devif.h
@@ -294,22 +294,6 @@ extern "C"
  * Public Function Prototypes
  ****************************************************************************/
 
-/****************************************************************************
- * Name: devif_initialize
- *
- * Description:
- *   Perform initialization of the network device interface layer
- *
- * Input Parameters:
- *   None
- *
- * Returned Value:
- *   None
- *
- ****************************************************************************/
-
-void devif_initialize(void);
-
 /****************************************************************************
  * Name: devif_callback_alloc
  *
diff --git a/net/devif/devif_callback.c b/net/devif/devif_callback.c
index ce633c3229c..0f3a1142c32 100644
--- a/net/devif/devif_callback.c
+++ b/net/devif/devif_callback.c
@@ -37,6 +37,7 @@
 #include <nuttx/net/netconfig.h>
 #include <nuttx/net/net.h>
 #include <nuttx/net/netdev.h>
+#include <nuttx/net/netstats.h>
 
 #include "netdev/netdev.h"
 #include "utils/utils.h"
@@ -49,6 +50,16 @@
 #define DEVIF_CB_DONT_FREE  (1 << 0)
 #define DEVIF_CB_PEND_FREE  (1 << 1)
 
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+/* IP/TCP/UDP/ICMP statistics for all network interfaces */
+
+#ifdef CONFIG_NET_STATISTICS
+struct net_stats_s g_netstats;
+#endif
+
 /****************************************************************************
  * Private Data
  ****************************************************************************/
diff --git a/net/devif/devif_initialize.c b/net/devif/devif_initialize.c
deleted file mode 100644
index e53c1cf8a1d..00000000000
--- a/net/devif/devif_initialize.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/****************************************************************************
- * net/devif/devif_initialize.c
- *
- * SPDX-License-Identifier: BSD-3-Clause
- *
- *   Copyright (C) 2007-2011, 2014, 2017 Gregory Nutt. All rights reserved.
- *   Author: Gregory Nutt <[email protected]>
- *
- * Adapted for NuttX from logic in uIP which also has a BSD-like license:
- *
- *   Original author Adam Dunkels <[email protected]>
- *   Copyright () 2001-2003, Adam Dunkels.
- *   All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. The name of the author may not be used to endorse or promote
- *    products derived from this software without specific prior
- *    written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
- * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
- * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ****************************************************************************/
-
-/****************************************************************************
- * Included Files
- ****************************************************************************/
-
-#include <nuttx/config.h>
-#ifdef CONFIG_NET
-
-#include <nuttx/net/netstats.h>
-
-#include "devif/devif.h"
-
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-/****************************************************************************
- * Public Data
- ****************************************************************************/
-
-/* IP/TCP/UDP/ICMP/CAN statistics for all network interfaces */
-
-#ifdef CONFIG_NET_STATISTICS
-struct net_stats_s g_netstats;
-#endif
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: devif_initialize
- *
- * Description:
- *   Perform initialization of the network device interface layer
- *
- * Input Parameters:
- *   None
- *
- * Returned Value:
- *   None
- *
- * Assumptions:
- *   Called early in the initialization sequence so that no special
- *   protection is required.
- *
- ****************************************************************************/
-
-void devif_initialize(void)
-{
-}
-#endif /* CONFIG_NET */
diff --git a/net/ipforward/ipforward.h b/net/ipforward/ipforward.h
index 894c96b26ef..bb6b10b4a3d 100644
--- a/net/ipforward/ipforward.h
+++ b/net/ipforward/ipforward.h
@@ -83,19 +83,6 @@ struct forward_s
 struct ipv4_hdr_s; /* Forward reference */
 struct ipv6_hdr_s; /* Forward reference */
 
-/****************************************************************************
- * Name: ipfwd_initialize
- *
- * Description:
- *   Initialize the struct forward_s allocator.
- *
- * Assumptions:
- *   Called early in system initialization.
- *
- ****************************************************************************/
-
-void ipfwd_initialize(void);
-
 /****************************************************************************
  * Name: ipfwd_alloc
  *
diff --git a/net/ipforward/ipfwd_alloc.c b/net/ipforward/ipfwd_alloc.c
index 2d993ce452c..b9d35ed9781 100644
--- a/net/ipforward/ipfwd_alloc.c
+++ b/net/ipforward/ipfwd_alloc.c
@@ -63,6 +63,8 @@
 
 #define MAX_HDRLEN (L2_MAXHDRLEN + L3_MAXHDRLEN)
 
+static_assert(MAX_HDRLEN <= CONFIG_IOB_BUFSIZE, "IOB buffer size too small");
+
 /****************************************************************************
  * Private Data
  ****************************************************************************/
@@ -78,26 +80,6 @@ NET_BUFPOOL_DECLARE(g_fwdpool, sizeof(struct forward_s),
  * Public Functions
  ****************************************************************************/
 
-/****************************************************************************
- * Name: ipfwd_initialize
- *
- * Description:
- *   Initialize the struct forward_s allocator.
- *
- * Assumptions:
- *   Called early in system initialization.
- *
- ****************************************************************************/
-
-void ipfwd_initialize(void)
-{
-  /* The IOB size must be such that the maximum L2 and L3 headers fit into
-   * the contiguous memory of the first IOB in the IOB chain.
-   */
-
-  DEBUGASSERT(MAX_HDRLEN <= CONFIG_IOB_BUFSIZE);
-}
-
 /****************************************************************************
  * Name: ipfwd_alloc
  *
diff --git a/net/net_initialize.c b/net/net_initialize.c
index 25d69c5a1ee..b1bd32cb3c8 100644
--- a/net/net_initialize.c
+++ b/net/net_initialize.c
@@ -77,40 +77,18 @@
 
 void net_initialize(void)
 {
-  /* Initialize the device interface layer */
-
-  devif_initialize();
-
 #ifdef CONFIG_NET_BLUETOOTH
   /* Initialize Bluetooth  socket support */
 
   bluetooth_initialize();
 #endif
 
-#ifdef CONFIG_NET_CAN
-  /* Initialize SocketCAN support */
-
-  can_initialize();
-#endif
-
 #ifdef CONFIG_NET_IEEE802154
   /* Initialize IEEE 802.15.4  socket support */
 
   ieee802154_initialize();
 #endif
 
-#ifdef CONFIG_NET_NETLINK
-  /* Initialize the Netlink IPC support */
-
-  netlink_initialize();
-#endif
-
-#ifdef CONFIG_NET_PKT
-  /* Initialize packet socket support */
-
-  pkt_initialize();
-#endif
-
 #ifdef CONFIG_NET_ROUTE
   /* Initialize the routing table */
 
@@ -125,24 +103,6 @@ void net_initialize(void)
 #endif
 #endif /* CONFIG_NET_IPv6 */
 
-#ifdef HAVE_FWDALLOC
-  /* Initialize IP forwarding support */
-
-  ipfwd_initialize();
-#endif
-
-#ifdef NET_TCP_HAVE_STACK
-  /* Initialize the TCP/IP connection structures */
-
-  tcp_initialize();
-#endif /* CONFIG_NET_TCP */
-
-#ifdef NET_UDP_HAVE_STACK
-  /* Initialize the UDP connection structures */
-
-  udp_initialize();
-#endif
-
 #ifdef CONFIG_NET_USRSOCK
   /* Initialize the user-space socket API */
 
diff --git a/net/netlink/netlink.h b/net/netlink/netlink.h
index b1ebf8e0b7d..cd7c5a68f30 100644
--- a/net/netlink/netlink.h
+++ b/net/netlink/netlink.h
@@ -300,17 +300,6 @@ extern "C"
 
 EXTERN const struct sock_intf_s g_netlink_sockif;
 
-/****************************************************************************
- * Name: netlink_initialize()
- *
- * Description:
- *   Initialize the NetLink connection structures.  Called once and only
- *   from the networking layer.
- *
- ****************************************************************************/
-
-void netlink_initialize(void);
-
 /****************************************************************************
  * Name: netlink_alloc()
  *
diff --git a/net/netlink/netlink_conn.c b/net/netlink/netlink_conn.c
index dca52b37232..fc067defde3 100644
--- a/net/netlink/netlink_conn.c
+++ b/net/netlink/netlink_conn.c
@@ -138,19 +138,6 @@ netlink_get_terminator(FAR const struct nlmsghdr *req)
  * Public Functions
  ****************************************************************************/
 
-/****************************************************************************
- * Name: netlink_initialize()
- *
- * Description:
- *   Initialize the NetLink connection structures.  Called once and only
- *   from the networking layer.
- *
- ****************************************************************************/
-
-void netlink_initialize(void)
-{
-}
-
 /****************************************************************************
  * Name: netlink_alloc()
  *
diff --git a/net/pkt/pkt.h b/net/pkt/pkt.h
index 16f1c5f6199..767776b7f7c 100644
--- a/net/pkt/pkt.h
+++ b/net/pkt/pkt.h
@@ -136,17 +136,6 @@ EXTERN const struct sock_intf_s g_pkt_sockif;
 struct net_driver_s; /* Forward reference */
 struct socket;       /* Forward reference */
 
-/****************************************************************************
- * Name: pkt_initialize()
- *
- * Description:
- *   Initialize the packet socket connection structures.  Called once and
- *   only from the network initialization logic.
- *
- ****************************************************************************/
-
-void pkt_initialize(void);
-
 /****************************************************************************
  * Name: pkt_alloc()
  *
diff --git a/net/pkt/pkt_conn.c b/net/pkt/pkt_conn.c
index bd81a10f1b1..c1c0d01c527 100644
--- a/net/pkt/pkt_conn.c
+++ b/net/pkt/pkt_conn.c
@@ -78,19 +78,6 @@ static dq_queue_t g_active_pkt_connections;
  * Public Functions
  ****************************************************************************/
 
-/****************************************************************************
- * Name: pkt_initialize()
- *
- * Description:
- *   Initialize the packet socket connection structures.  Called once and
- *   only from the network initialization layer.
- *
- ****************************************************************************/
-
-void pkt_initialize(void)
-{
-}
-
 /****************************************************************************
  * Name: pkt_alloc()
  *
diff --git a/net/tcp/tcp.h b/net/tcp/tcp.h
index 4207d3085cf..50829c514ed 100644
--- a/net/tcp/tcp.h
+++ b/net/tcp/tcp.h
@@ -459,17 +459,6 @@ extern "C"
  * Public Function Prototypes
  ****************************************************************************/
 
-/****************************************************************************
- * Name: tcp_initialize
- *
- * Description:
- *   Initialize the TCP/IP connection structures.  Called only once and only
- *   from the network layer at start-up.
- *
- ****************************************************************************/
-
-void tcp_initialize(void);
-
 /****************************************************************************
  * Name: tcp_alloc
  *
diff --git a/net/tcp/tcp_conn.c b/net/tcp/tcp_conn.c
index 540715097d0..07676313d08 100644
--- a/net/tcp/tcp_conn.c
+++ b/net/tcp/tcp_conn.c
@@ -607,19 +607,6 @@ int tcp_selectport(uint8_t domain,
   return portno;
 }
 
-/****************************************************************************
- * Name: tcp_initialize
- *
- * Description:
- *   Initialize the TCP/IP connection structures.  Called only once and only
- *   from the network layer at start-up.
- *
- ****************************************************************************/
-
-void tcp_initialize(void)
-{
-}
-
 /****************************************************************************
  * Name: tcp_alloc
  *
diff --git a/net/udp/udp.h b/net/udp/udp.h
index 369d6200596..e0268604584 100644
--- a/net/udp/udp.h
+++ b/net/udp/udp.h
@@ -201,17 +201,6 @@ extern "C"
  * Public Function Prototypes
  ****************************************************************************/
 
-/****************************************************************************
- * Name: udp_initialize
- *
- * Description:
- *   Initialize the UDP connection structures.  Called once and only from
- *   the UIP layer.
- *
- ****************************************************************************/
-
-void udp_initialize(void);
-
 /****************************************************************************
  * Name: udp_alloc
  *
diff --git a/net/udp/udp_conn.c b/net/udp/udp_conn.c
index 2b1d8fc51ae..19e5f033179 100644
--- a/net/udp/udp_conn.c
+++ b/net/udp/udp_conn.c
@@ -537,19 +537,6 @@ errout:
   return portno;
 }
 
-/****************************************************************************
- * Name: udp_initialize
- *
- * Description:
- *   Initialize the UDP connection structures.  Called once and only from
- *   the UIP layer.
- *
- ****************************************************************************/
-
-void udp_initialize(void)
-{
-}
-
 /****************************************************************************
  * Name: udp_alloc
  *

Reply via email to