Changed initialization: many init functions are not needed any more since we now rely on the compiler initializing global and static variables to zero!

This commit is contained in:
goldsimon 2007-10-09 19:59:56 +00:00
parent 536f2e42d2
commit 199648ff37
23 changed files with 35 additions and 117 deletions

View File

@ -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

View 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:

View 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);

View File

@ -54,18 +54,18 @@
#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.

View 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

View File

@ -55,17 +55,6 @@
#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

View 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 (!).

View 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;

View File

@ -61,15 +61,6 @@
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.
*

View File

@ -55,16 +55,7 @@
#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

View 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];
/**

View 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);

View File

@ -48,11 +48,6 @@
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)

View 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.
*

View File

@ -65,16 +65,7 @@
/* 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.

View 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,

View 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,

View 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
}

View 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

View 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). */

View 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);

View 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);

View 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
/**