]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lwip.git/commitdiff
Changed initialization: many init functions are not needed any more since we now...
authorgoldsimon <goldsimon>
Tue, 9 Oct 2007 19:59:56 +0000 (19:59 +0000)
committergoldsimon <goldsimon>
Tue, 9 Oct 2007 19:59:56 +0000 (19:59 +0000)
23 files changed:
CHANGELOG
doc/contrib.txt
src/api/sockets.c
src/api/tcpip.c
src/core/ipv4/igmp.c
src/core/ipv4/ip.c
src/core/ipv4/ip_frag.c
src/core/mem.c
src/core/netif.c
src/core/raw.c
src/core/snmp/mib_structs.c
src/core/snmp/msg_in.c
src/core/stats.c
src/core/tcp.c
src/core/udp.c
src/include/ipv4/lwip/ip.h
src/include/lwip/netif.h
src/include/lwip/raw.h
src/include/lwip/stats.h
src/include/lwip/tcp.h
src/include/lwip/udp.h
src/include/netif/etharp.h
src/netif/etharp.c

index 36c55d5afe16a45de7b4e426117aecbb87768301..005ccbe84e3d11cbeda7d5a484667c80a5bf8a74 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -19,6 +19,11 @@ HISTORY
 
   ++ New features:
 
+  2007-10-08 Simon Goldschmidt
+  * many files: Changed initialization: many init functions are not needed any
+    more since we now rely on the compiler initializing global and static
+    variables to zero!
+
   2007-10-06 Simon Goldschmidt
   * ip_frag.c, memp.c, mib2.c, ip_frag.h, memp_std.h, opt.h: Changed IP_REASSEMBLY
     to enqueue the received pbufs so that multiple packets can be reassembled
index 7c99b9be2786d6090257a28897e6a283fca334d8..39596fca335f3c74f91e10971fdd5d2405460450 100644 (file)
@@ -21,7 +21,8 @@ features of Savannah help us not lose users' input.
 6. one space and no newline before opening curly braces of a block.
 7. closing curly brace on a single line.
 8. spaces surrounding assignment and comparisons.
-9. use current source code style as further reference.
+9. don't initialize static and/or global variables to zero, the compiler takes care of that.
+10. use current source code style as further reference.
 
 2.2 Source code documentation style:
 
index 6091943522951b3af4c23e29bdd901238c67c3a9..b9eebd4437d317e703301f8f6e841a2d0c52239b 100644 (file)
@@ -86,10 +86,10 @@ struct lwip_setgetsockopt_data {
 };
 
 static struct lwip_socket sockets[NUM_SOCKETS];
-static struct lwip_select_cb *select_cb_list = 0;
+static struct lwip_select_cb *select_cb_list;
 
-static sys_sem_t socksem = 0;
-static sys_sem_t selectsem = 0;
+static sys_sem_t socksem;
+static sys_sem_t selectsem;
 
 static void event_callback(struct netconn *conn, enum netconn_evt evt, u16_t len);
 static void lwip_getsockopt_internal(void *arg);
index e79fabe174dd0ef1470048531a07d006389d35c9..939402f703d0a4bf21a86eb049b0d103f847b421 100644 (file)
 #include "netif/ppp_oe.h"
 
 /* global variables */
-static void (* tcpip_init_done)(void *arg) = NULL;
-static void *tcpip_init_done_arg           = NULL;
-static sys_mbox_t mbox                     = SYS_MBOX_NULL;
+static void (* tcpip_init_done)(void *arg);
+static void *tcpip_init_done_arg;
+static sys_mbox_t mbox = SYS_MBOX_NULL;
 
 #if LWIP_TCPIP_CORE_LOCKING
 /** The global semaphore to lock the stack. */
-sys_sem_t lock_tcpip_core = 0;
+sys_sem_t lock_tcpip_core;
 #endif /* LWIP_TCPIP_CORE_LOCKING */
 
 #if LWIP_TCP
 /* global variable that shows if the tcp timer is currently scheduled or not */
-static int tcpip_tcp_timer_active = 0;
+static int tcpip_tcp_timer_active;
 
 /**
  * Timer callback function that calls tcp_tmr() and reschedules itself.
index c8370b7b69cfd6fae5c4ffe9d82c68ee87d1a7c1..7040a3af8a8bf3ba3018c697248270a63d35b6ba 100644 (file)
@@ -113,8 +113,6 @@ igmp_init(void)
 
   IP4_ADDR(&allsystems, 224, 0, 0, 1);
   IP4_ADDR(&allrouters, 224, 0, 0, 2);
-
-  igmp_group_list = NULL;
 }
 
 #ifdef LWIP_DEBUG
index 9980cbc8766c44b42469ac8d8c76462dad5b6833..2b0ccdece75c5350db7ceccc9f9cacd40bf0dc16 100644 (file)
 #include "lwip/stats.h"
 #include "arch/perf.h"
 
-/**
- * Initializes the IP layer.
- */
-void
-ip_init(void)
-{
-#if IP_REASSEMBLY
-  ip_reass_init();
-#endif
-}
-
 /**
  * Finds the appropriate network interface for a given IP address. It
  * searches the list of network interfaces linearly. A match is found
index 3adb3de276a750aa078f2c20f1e55bb502f61ded..ffec6b8018f92c8036f7c49f5c01b74ab2aadbdb 100644 (file)
@@ -85,14 +85,6 @@ static u16_t ip_reass_pbufcount;
 /* function prototypes */
 static void dequeue_packet(struct ip_reassdata *ipr, struct ip_reassdata *prev);
 
-/**
- * Initializes IP reassembly states.
- */
-void
-ip_reass_init(void)
-{
-}
-
 /**
  * Reassembly timer base function
  * for both NO_SYS == 0 and 1 (!).
index afb4a52febb08ddb44da31ff1cf54f4f9fd0a24d..01f78eda0e2073a219bd01c438d866aff1e1592f 100644 (file)
@@ -206,7 +206,6 @@ mem_init(void)
     (SIZEOF_STRUCT_MEM & (MEM_ALIGNMENT-1)) == 0);
 
   /* align the heap */
-  memset(ram_heap, 0, sizeof(ram_heap));
   ram = LWIP_MEM_ALIGN(ram_heap);
   /* initialize the start of the heap */
   mem = (struct mem *)ram;
index 9c9da2b1ac74415edb0a6a95b2fe94c9ef820b76..a31992d2aa5caedad512a271f912b40d0015c8ee 100644 (file)
 struct netif *netif_list = NULL;
 struct netif *netif_default = NULL;
 
-/**
- * Initialize this module
- */
-void
-netif_init(void)
-{
-  netif_list = netif_default = NULL;
-}
-
 /**
  * Add a network interface to the list of lwIP netifs.
  *
index 421c49333bdeaf7f5ae04d7a69f02fdaf2221cac..4ee3fc0eb6f94f3cab81ab3f51d76b9cd630d5b5 100644 (file)
 #include <string.h>
 
 /** The list of RAW PCBs */
-static struct raw_pcb *raw_pcbs = NULL;
-
-/**
- * Initialize this module
- */
-void
-raw_init(void)
-{
-  raw_pcbs = NULL;
-}
+static struct raw_pcb *raw_pcbs;
 
 /**
  * Determine if in incoming IP packet is covered by a RAW PCB
index ba78f85730bdf58635d5dc1753d2fe8f3b275e99..af8994ed22cf4bdba0103dbafafe01b3b5de558a 100644 (file)
@@ -53,7 +53,7 @@ struct nse
   /** right child next level */
   u8_t r_nl;
 };
-static u8_t node_stack_cnt = 0;
+static u8_t node_stack_cnt;
 static struct nse node_stack[NODE_STACK_SIZE];
 
 /**
index ab8b521636c3cbafb7514f6afd386cba7423e15c..e09bac18b23d373a2814f633301f9863c8414546 100644 (file)
@@ -56,7 +56,7 @@ const char snmp_publiccommunity[7] = "public";
 /* statically allocated buffers for SNMP_CONCURRENT_REQUESTS */
 struct snmp_msg_pstat msg_input_list[SNMP_CONCURRENT_REQUESTS];
 /* UDP Protocol Control Block */
-struct udp_pcb *snmp1_pcb = NULL;
+struct udp_pcb *snmp1_pcb;
 
 static void snmp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, struct ip_addr *addr, u16_t port);
 static err_t snmp_pdu_header_check(struct pbuf *p, u16_t ofs, u16_t pdu_len, u16_t *ofs_ret, struct snmp_msg_pstat *m_stat);
index 640baab51d89cb0f23b3ed2f2ff752004b9fd56b..e693d869300d5b59fb83fa041cc1366709a1fab0 100644 (file)
 
 struct stats_ lwip_stats;
 
-void
-stats_init(void)
-{
-  memset(&lwip_stats, 0, sizeof(struct stats_));
-}
 #if LWIP_STATS_DISPLAY
 void
 stats_display_proto(struct stats_proto *proto, char *name)
index a7ce7394a647e25e5f8f593fe8eea7e7ec8521dd..a28b2890ca635d1d17e6fb5de70a64e067bc690a 100644 (file)
@@ -74,25 +74,6 @@ struct tcp_pcb *tcp_tmp_pcb;
 static u8_t tcp_timer;
 static u16_t tcp_new_port(void);
 
-/**
- * Initializes the TCP layer.
- */
-void
-tcp_init(void)
-{
-  /* Clear globals. */
-  tcp_bound_pcbs = NULL;
-  tcp_listen_pcbs.listen_pcbs = NULL;
-  tcp_active_pcbs = NULL;
-  tcp_tw_pcbs = NULL;
-  tcp_tmp_pcb = NULL;
-  
-  /* initialize timer */
-  tcp_ticks = 0;
-  tcp_timer = 0;
-  
-}
-
 /**
  * Called periodically to dispatch TCP timers.
  *
index 437cdb1fd748da3f020d5f233d332ca64c9a3ff0..f78d55b07ef3ac034861bf2b4da5bd0af8781d99 100644 (file)
 
 /* The list of UDP PCBs */
 /* exported in udp.h (was static) */
-struct udp_pcb *udp_pcbs = NULL;
-
-/**
- * Initialize the UDP module
- */
-void
-udp_init(void)
-{
-  udp_pcbs = NULL;
-}
+struct udp_pcb *udp_pcbs;
 
 /**
  * Process an incoming UDP datagram.
index e61ac319ca3e8735e3abe6cd21088c8e40e24f57..3b760f0066bbe695d4e4ac5452be240a1d229475 100644 (file)
@@ -43,7 +43,7 @@
 extern "C" {
 #endif
 
-void ip_init(void);
+#define ip_init() /* Compatibility define, not init needed. */
 struct netif *ip_route(struct ip_addr *dest);
 err_t ip_input(struct pbuf *p, struct netif *inp);
 err_t ip_output(struct pbuf *p, struct ip_addr *src, struct ip_addr *dest,
index 81dd338bc21b725cf2e66bf5c1fc1a1627097aa6..19c38087bc8f709a89ab1c12c1602ded6e230316 100644 (file)
@@ -192,8 +192,7 @@ extern struct netif *netif_list;
 /** The default network interface. */
 extern struct netif *netif_default;
 
-/* netif_init() must be called first. */
-void netif_init(void);
+#define netif_init() /* Compatibility define, not init needed. */
 
 struct netif *netif_add(struct netif *netif, struct ip_addr *ipaddr, struct ip_addr *netmask,
       struct ip_addr *gw,
index 56d21b187c850c0507794222bbaf415603f933ec..5834fc95f11f222f9410b021faa6a7bee8326630 100644 (file)
@@ -85,7 +85,7 @@ err_t            raw_send       (struct raw_pcb *pcb, struct pbuf *p);
 
 /* The following functions are the lower layer interface to RAW. */
 u8_t             raw_input      (struct pbuf *p, struct netif *inp);
-void             raw_init       (void);
+#define raw_init() /* Compatibility define, not init needed. */
 
 #ifdef __cplusplus
 }
index 1dbc0df9ed37f161741af5ab5bf3705effba0b29..ee319b24baf00890a5b2baabea0310696cd4f5ec 100644 (file)
@@ -136,7 +136,7 @@ struct stats_ {
 
 extern struct stats_ lwip_stats;
 
-void stats_init(void);
+#define stats_init() /* Compatibility define, not init needed. */
 
 #define STATS_INC(x) ++lwip_stats.x
 #else
index ab87ca5b637da47ea53890407fa83c6f14d30eac..8e2fc68ace4c6795c925b02f94c26db4510fe8e7 100644 (file)
@@ -52,8 +52,7 @@ struct tcp_pcb;
 /* Functions for interfacing with TCP: */
 
 /* Lower layer interface to TCP: */
-void             tcp_init    (void);  /* Must be called first to
-                                         initialize TCP. */
+#define tcp_init() /* Compatibility define, not init needed. */
 void             tcp_tmr     (void);  /* Must be called every
                                          TCP_TMR_INTERVAL
                                          ms. (Typically 250 ms). */
index cd0f33cdc4ba6ede7cefd0b0b64f0a769291b004..89d1f5e7247a5970b5ff247322bd422307c0ad6b 100644 (file)
@@ -130,7 +130,8 @@ err_t            udp_send       (struct udp_pcb *pcb, struct pbuf *p);
 
 /* The following functions are the lower layer interface to UDP. */
 void             udp_input      (struct pbuf *p, struct netif *inp);
-void             udp_init       (void);
+
+#define udp_init() /* Compatibility define, not init needed. */
 
 #if UDP_DEBUG
 void udp_debug_print(struct udp_hdr *udphdr);
index e5d9e15db133d2147dd1c2684c411c65e77a6909..2b76823bb1fc67eddd431aa12add22d940f22217 100644 (file)
@@ -141,7 +141,7 @@ struct etharp_q_entry {
 };
 #endif /* ARP_QUEUEING */
 
-void etharp_init(void);
+#define etharp_init() /* Compatibility define, not init needed. */
 void etharp_tmr(void);
 s8_t etharp_find_addr(struct netif *netif, struct ip_addr *ipaddr,
          struct eth_addr **eth_ret, struct ip_addr **ip_ret);
index 77fd2eeb388dc1a8895cfd07ca7398d1cd498a8a..63b458ccb1a04bad0a43c2cd858bb55764ac2558 100644 (file)
@@ -103,7 +103,7 @@ const struct eth_addr ethbroadcast = {{0xff,0xff,0xff,0xff,0xff,0xff}};
 const struct eth_addr ethzero = {{0,0,0,0,0,0}};
 static struct etharp_entry arp_table[ARP_TABLE_SIZE];
 #if !LWIP_NETIF_HWADDRHINT
-static u8_t etharp_cached_entry = 0;
+static u8_t etharp_cached_entry;
 #endif
 
 /**
@@ -122,29 +122,15 @@ static s8_t find_entry(struct ip_addr *ipaddr, u8_t flags);
 
 static err_t update_arp_entry(struct netif *netif, struct ip_addr *ipaddr, struct eth_addr *ethaddr, u8_t flags);
 
-/**
- * Initializes ARP module.
- */
-void
-etharp_init(void)
-{
-  u8_t i;
-
-  LWIP_ASSERT("ARP_TABLE_SIZE < 0x80 (due to s8_t limitation)",
-              (ARP_TABLE_SIZE < 0x80));
 
-  /* clear ARP entries */
-  for (i = 0; i < ARP_TABLE_SIZE; ++i) {
-    /* use memset to be safe (intialize all future variables to 0) */
-    memset(&arp_table[i], 0, sizeof(struct etharp_entry));
-    arp_table[i].state = ETHARP_STATE_EMPTY;
-#if ARP_QUEUEING
-    arp_table[i].q = NULL;
+/* Some checks, instead of etharp_init(): */
+#if ETHARP_STATE_EMPTY != 0
+#error ETHARP_STATE_EMPTY must be 0 to ensure correct initialization value!
 #endif
-    arp_table[i].ctime = 0;
-    arp_table[i].netif = NULL;
-  }
-}
+#if (LWIP_ARP && (ARP_TABLE_SIZE > 0x7f))
+  #error "If you want to use ARP, ARP_TABLE_SIZE must fit in an s8_t, so, you have to reduce it in your lwipopts.h"
+#endif
+
 
 #if ARP_QUEUEING
 /**