From 9cc52876c7f541c91d88049d977e678259d5b86a Mon Sep 17 00:00:00 2001
From: Bostjan Meglic <meglic.bostjan@gmail.com>
Date: Wed, 7 Mar 2012 10:30:24 +0100
Subject: [PATCH] Initialize all global variables to 0 or NULL.

Some compilers do not initialize global variables,
so at initialization they could be in a random state.

Signed-off-by: Bostjan Meglic <meglic.bostjan@gmail.com>
---
 src/api/netdb.c             |    2 +-
 src/api/sockets.c           |    6 +++---
 src/api/tcpip.c             |    8 ++++----
 src/core/dhcp.c             |    4 ++--
 src/core/dns.c              |   14 +++++++-------
 src/core/ipv4/igmp.c        |    6 +++---
 src/core/ipv4/ip.c          |   10 +++++-----
 src/core/ipv4/ip_frag.c     |    4 ++--
 src/core/memp.c             |    2 +-
 src/core/netif.c            |    6 +++---
 src/core/pbuf.c             |    2 +-
 src/core/raw.c              |    2 +-
 src/core/snmp/mib_structs.c |    4 ++--
 src/core/snmp/msg_in.c      |    4 ++--
 src/core/snmp/msg_out.c     |    4 ++--
 src/core/stats.c            |    2 +-
 src/core/tcp.c              |   14 +++++++-------
 src/core/tcp_in.c           |   18 +++++++++---------
 src/core/timers.c           |    6 +++---
 src/core/udp.c              |    2 +-
 src/netif/etharp.c          |    4 ++--
 src/netif/ppp/auth.c        |   24 ++++++++++++------------
 src/netif/ppp/chap.c        |    2 +-
 src/netif/ppp/fsm.c         |    2 +-
 src/netif/ppp/ipcp.c        |   14 +++++++-------
 src/netif/ppp/lcp.c         |   16 ++++++++--------
 src/netif/ppp/pap.c         |    2 +-
 src/netif/ppp/ppp.c         |    4 ++--
 src/netif/ppp/ppp_oe.c      |    4 ++--
 src/netif/ppp/randm.c       |    2 +-
 30 files changed, 97 insertions(+), 97 deletions(-)

diff --git a/src/api/netdb.c b/src/api/netdb.c
index a7e4e06..670a4cb 100644
--- a/src/api/netdb.c
+++ b/src/api/netdb.c
@@ -56,7 +56,7 @@ struct gethostbyname_r_helper {
 
 /** h_errno is exported in netdb.h for access by applications. */
 #if LWIP_DNS_API_DECLARE_H_ERRNO
-int h_errno;
+int h_errno = 0;
 #endif /* LWIP_DNS_API_DECLARE_H_ERRNO */
 
 /** define "hostent" variables storage: 0 if we use a static (but unprotected)
diff --git a/src/api/sockets.c b/src/api/sockets.c
index e36012c..942c7dd 100644
--- a/src/api/sockets.c
+++ b/src/api/sockets.c
@@ -123,12 +123,12 @@ struct lwip_setgetsockopt_data {
 };
 
 /** The global array of available sockets */
-static struct lwip_sock sockets[NUM_SOCKETS];
+static struct lwip_sock sockets[NUM_SOCKETS] = { 0 };
 /** The global list of tasks waiting for select */
-static struct lwip_select_cb *select_cb_list;
+static struct lwip_select_cb *select_cb_list = NULL;
 /** This counter is increased from lwip_select when the list is chagned
     and checked in event_callback to see if it has changed. */
-static volatile int select_cb_ctr;
+static volatile int select_cb_ctr = 0;
 
 /** Table to quickly map an lwIP error (err_t) to a socket error
   * by using -err as an index */
diff --git a/src/api/tcpip.c b/src/api/tcpip.c
index 857e7d9..c27e0f2 100644
--- a/src/api/tcpip.c
+++ b/src/api/tcpip.c
@@ -50,13 +50,13 @@
 #include "netif/ppp_oe.h"
 
 /* global variables */
-static tcpip_init_done_fn tcpip_init_done;
-static void *tcpip_init_done_arg;
-static sys_mbox_t mbox;
+static tcpip_init_done_fn tcpip_init_done = NULL;
+static void *tcpip_init_done_arg = NULL;
+static sys_mbox_t mbox = 0;
 
 #if LWIP_TCPIP_CORE_LOCKING
 /** The global semaphore to lock the stack. */
-sys_mutex_t lock_tcpip_core;
+sys_mutex_t lock_tcpip_core = 0;
 #endif /* LWIP_TCPIP_CORE_LOCKING */
 
 
diff --git a/src/core/dhcp.c b/src/core/dhcp.c
index 81b4be2..dcc4a45 100644
--- a/src/core/dhcp.c
+++ b/src/core/dhcp.c
@@ -120,11 +120,11 @@
 
 /** Holds the decoded option values, only valid while in dhcp_recv.
     @todo: move this into struct dhcp? */
-u32_t dhcp_rx_options_val[DHCP_OPTION_IDX_MAX];
+u32_t dhcp_rx_options_val[DHCP_OPTION_IDX_MAX] = { 0 };
 /** Holds a flag which option was received and is contained in dhcp_rx_options_val,
     only valid while in dhcp_recv.
     @todo: move this into struct dhcp? */
-u8_t  dhcp_rx_options_given[DHCP_OPTION_IDX_MAX];
+u8_t  dhcp_rx_options_given[DHCP_OPTION_IDX_MAX] = { 0 };
 
 #define dhcp_option_given(dhcp, idx)          (dhcp_rx_options_given[idx] != 0)
 #define dhcp_got_option(dhcp, idx)            (dhcp_rx_options_given[idx] = 1)
diff --git a/src/core/dns.c b/src/core/dns.c
index d633612..3453024 100644
--- a/src/core/dns.c
+++ b/src/core/dns.c
@@ -185,7 +185,7 @@ struct dns_table_entry {
 #if DNS_LOCAL_HOSTLIST_IS_DYNAMIC
 /** Local host-list. For hostnames in this list, no
  *  external name resolution is performed */
-static struct local_hostlist_entry *local_hostlist_dynamic;
+static struct local_hostlist_entry *local_hostlist_dynamic = NULL;
 #else /* DNS_LOCAL_HOSTLIST_IS_DYNAMIC */
 
 /** Defining this allows the local_hostlist_static to be placed in a different
@@ -216,13 +216,13 @@ static void dns_check_entries(void);
  *----------------------------------------------------------------------------*/
 
 /* DNS variables */
-static struct udp_pcb        *dns_pcb;
-static u8_t                   dns_seqno;
-static struct dns_table_entry dns_table[DNS_TABLE_SIZE];
-static ip_addr_t              dns_servers[DNS_MAX_SERVERS];
+static struct udp_pcb        *dns_pcb = NULL;
+static u8_t                   dns_seqno = 0;
+static struct dns_table_entry dns_table[DNS_TABLE_SIZE] = { 0 };
+static ip_addr_t              dns_servers[DNS_MAX_SERVERS] = { 0 };
 /** Contiguous buffer for processing responses */
-static u8_t                   dns_payload_buffer[LWIP_MEM_ALIGN_BUFFER(DNS_MSG_SIZE)];
-static u8_t*                  dns_payload;
+static u8_t                   dns_payload_buffer[LWIP_MEM_ALIGN_BUFFER(DNS_MSG_SIZE)] = { 0 };
+static u8_t*                  dns_payload = NULL;
 
 /**
  * Initialize the resolver: set up the UDP pcb and configure the default server
diff --git a/src/core/ipv4/igmp.c b/src/core/ipv4/igmp.c
index 4e4405e..b67a24b 100644
--- a/src/core/ipv4/igmp.c
+++ b/src/core/ipv4/igmp.c
@@ -145,9 +145,9 @@ static err_t  igmp_ip_output_if(struct pbuf *p, ip_addr_t *src, ip_addr_t *dest,
 static void   igmp_send(struct igmp_group *group, u8_t type);
 
 
-static struct igmp_group* igmp_group_list;
-static ip_addr_t     allsystems;
-static ip_addr_t     allrouters;
+static struct igmp_group* igmp_group_list = NULL;
+static ip_addr_t     allsystems = 0;
+static ip_addr_t     allrouters = 0;
 
 
 /**
diff --git a/src/core/ipv4/ip.c b/src/core/ipv4/ip.c
index 6f24871..2c0e3d4 100644
--- a/src/core/ipv4/ip.c
+++ b/src/core/ipv4/ip.c
@@ -97,19 +97,19 @@
  * The interface that provided the packet for the current callback
  * invocation.
  */
-struct netif *current_netif;
+struct netif *current_netif = NULL;
 
 /**
  * Header of the input packet currently being processed.
  */
-const struct ip_hdr *current_header;
+const struct ip_hdr *current_header = NULL;
 /** Source IP address of current_header */
-ip_addr_t current_iphdr_src;
+ip_addr_t current_iphdr_src = { 0 };
 /** Destination IP address of current_header */
-ip_addr_t current_iphdr_dest;
+ip_addr_t current_iphdr_dest = { 0 };
 
 /** The IP header ID of the next outgoing IP packet */
-static u16_t ip_id;
+static u16_t ip_id = 0;
 
 /**
  * Finds the appropriate network interface for a given IP address. It
diff --git a/src/core/ipv4/ip_frag.c b/src/core/ipv4/ip_frag.c
index 8d18434..e65324e 100644
--- a/src/core/ipv4/ip_frag.c
+++ b/src/core/ipv4/ip_frag.c
@@ -105,8 +105,8 @@ PACK_STRUCT_END
    IPH_ID(iphdrA) == IPH_ID(iphdrB)) ? 1 : 0
 
 /* global variables */
-static struct ip_reassdata *reassdatagrams;
-static u16_t ip_reass_pbufcount;
+static struct ip_reassdata *reassdatagrams = NULL;
+static u16_t ip_reass_pbufcount = 0;
 
 /* function prototypes */
 static void ip_reass_dequeue_datagram(struct ip_reassdata *ipr, struct ip_reassdata *prev);
diff --git a/src/core/memp.c b/src/core/memp.c
index 4da879a..a7ce080 100644
--- a/src/core/memp.c
+++ b/src/core/memp.c
@@ -114,7 +114,7 @@ struct memp {
 
 /** This array holds the first free element of each pool.
  *  Elements form a linked list. */
-static struct memp *memp_tab[MEMP_MAX];
+static struct memp *memp_tab[MEMP_MAX] = { 0 };
 
 #else /* MEMP_MEM_MALLOC */
 
diff --git a/src/core/netif.c b/src/core/netif.c
index f190b1f..7f24040 100644
--- a/src/core/netif.c
+++ b/src/core/netif.c
@@ -72,11 +72,11 @@
 #define NETIF_LINK_CALLBACK(n)
 #endif /* LWIP_NETIF_LINK_CALLBACK */ 
 
-struct netif *netif_list;
-struct netif *netif_default;
+struct netif *netif_list = NULL;
+struct netif *netif_default = NULL;
 
 #if LWIP_HAVE_LOOPIF
-static struct netif loop_netif;
+static struct netif loop_netif = { 0 };
 
 /**
  * Initialize a lwip network interface structure for a loopback interface
diff --git a/src/core/pbuf.c b/src/core/pbuf.c
index dd9ff64..681344b 100644
--- a/src/core/pbuf.c
+++ b/src/core/pbuf.c
@@ -95,7 +95,7 @@
 #if PBUF_POOL_FREE_OOSEQ
 #include "lwip/tcpip.h"
 #define PBUF_POOL_IS_EMPTY() pbuf_pool_is_empty()
-static u8_t pbuf_free_ooseq_queued;
+static u8_t pbuf_free_ooseq_queued = 0;
 /**
  * Attempt to reclaim some memory from queued out-of-sequence TCP segments
  * if we run out of pool pbufs. It's better to give priority to new packets
diff --git a/src/core/raw.c b/src/core/raw.c
index 9fcb100..7ae64d0 100644
--- a/src/core/raw.c
+++ b/src/core/raw.c
@@ -53,7 +53,7 @@
 #include <string.h>
 
 /** The list of RAW PCBs */
-static struct raw_pcb *raw_pcbs;
+static struct raw_pcb *raw_pcbs = NULL;
 
 /**
  * Determine if in incoming IP packet is covered by a RAW PCB
diff --git a/src/core/snmp/mib_structs.c b/src/core/snmp/mib_structs.c
index 2f185cb..d83a0b9 100644
--- a/src/core/snmp/mib_structs.c
+++ b/src/core/snmp/mib_structs.c
@@ -54,8 +54,8 @@ struct nse
   /** right child next level */
   u8_t r_nl;
 };
-static u8_t node_stack_cnt;
-static struct nse node_stack[NODE_STACK_SIZE];
+static u8_t node_stack_cnt = 0;
+static struct nse node_stack[NODE_STACK_SIZE] = { 0 };
 
 /**
  * Pushes nse struct onto stack.
diff --git a/src/core/snmp/msg_in.c b/src/core/snmp/msg_in.c
index 2dfb55b..a63624a 100644
--- a/src/core/snmp/msg_in.c
+++ b/src/core/snmp/msg_in.c
@@ -54,9 +54,9 @@ const s32_t snmp_version = 0;
 const char snmp_publiccommunity[7] = "public";
 
 /* statically allocated buffers for SNMP_CONCURRENT_REQUESTS */
-struct snmp_msg_pstat msg_input_list[SNMP_CONCURRENT_REQUESTS];
+struct snmp_msg_pstat msg_input_list[SNMP_CONCURRENT_REQUESTS] = { 0 };
 /* UDP Protocol Control Block */
-struct udp_pcb *snmp1_pcb;
+struct udp_pcb *snmp1_pcb = NULL;
 
 static void snmp_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, ip_addr_t *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);
diff --git a/src/core/snmp/msg_out.c b/src/core/snmp/msg_out.c
index 4778bee..92fc871 100644
--- a/src/core/snmp/msg_out.c
+++ b/src/core/snmp/msg_out.c
@@ -59,10 +59,10 @@ struct snmp_trap_dst
   /* set to 0 when disabled, >0 when enabled */
   u8_t enable;
 };
-struct snmp_trap_dst trap_dst[SNMP_TRAP_DESTINATIONS];
+struct snmp_trap_dst trap_dst[SNMP_TRAP_DESTINATIONS] = { 0 };
 
 /** TRAP message structure */
-struct snmp_msg_trap trap_msg;
+struct snmp_msg_trap trap_msg = { 0 };
 
 static u16_t snmp_resp_header_sum(struct snmp_msg_pstat *m_stat, u16_t vb_len);
 static u16_t snmp_trap_header_sum(struct snmp_msg_trap *m_trap, u16_t vb_len);
diff --git a/src/core/stats.c b/src/core/stats.c
index 69f97d4..5d86469 100644
--- a/src/core/stats.c
+++ b/src/core/stats.c
@@ -46,7 +46,7 @@
 
 #include <string.h>
 
-struct stats_ lwip_stats;
+struct stats_ lwip_stats = { 0 };
 
 void stats_init(void)
 {
diff --git a/src/core/tcp.c b/src/core/tcp.c
index c629bc4..048d632 100644
--- a/src/core/tcp.c
+++ b/src/core/tcp.c
@@ -70,7 +70,7 @@ const char * const tcp_state_str[] = {
 };
 
 /* Incremented every coarse grained timer shot (typically every 500 ms). */
-u32_t tcp_ticks;
+u32_t tcp_ticks = 0;
 const u8_t tcp_backoff[13] =
     { 1, 2, 3, 4, 5, 6, 7, 7, 7, 7, 7, 7, 7};
  /* Times per slowtmr hits */
@@ -79,14 +79,14 @@ const u8_t tcp_persist_backoff[7] = { 3, 6, 12, 24, 48, 96, 120 };
 /* The TCP PCB lists. */
 
 /** List of all TCP PCBs bound but not yet (connected || listening) */
-struct tcp_pcb *tcp_bound_pcbs;
+struct tcp_pcb *tcp_bound_pcbs = NULL;
 /** List of all TCP PCBs in LISTEN state */
-union tcp_listen_pcbs_t tcp_listen_pcbs;
+union tcp_listen_pcbs_t tcp_listen_pcbs = { 0 };
 /** List of all TCP PCBs that are in a state in which
  * they accept or send data. */
-struct tcp_pcb *tcp_active_pcbs;
+struct tcp_pcb *tcp_active_pcbs = NULL;
 /** List of all TCP PCBs in TIME-WAIT state */
-struct tcp_pcb *tcp_tw_pcbs;
+struct tcp_pcb *tcp_tw_pcbs = NULL;
 
 #define NUM_TCP_PCB_LISTS               4
 #define NUM_TCP_PCB_LISTS_NO_TIME_WAIT  3
@@ -95,10 +95,10 @@ struct tcp_pcb ** const tcp_pcb_lists[] = {&tcp_listen_pcbs.pcbs, &tcp_bound_pcb
   &tcp_active_pcbs, &tcp_tw_pcbs};
 
 /** Only used for temporary storage. */
-struct tcp_pcb *tcp_tmp_pcb;
+struct tcp_pcb *tcp_tmp_pcb = NULL;
 
 /** Timer counter to handle calling slow-timer from tcp_tmr() */ 
-static u8_t tcp_timer;
+static u8_t tcp_timer = 0;
 static u16_t tcp_new_port(void);
 
 /**
diff --git a/src/core/tcp_in.c b/src/core/tcp_in.c
index 9095264..5e78e12 100644
--- a/src/core/tcp_in.c
+++ b/src/core/tcp_in.c
@@ -59,17 +59,17 @@
 /* These variables are global to all functions involved in the input
    processing of TCP segments. They are set by the tcp_input()
    function. */
-static struct tcp_seg inseg;
-static struct tcp_hdr *tcphdr;
-static struct ip_hdr *iphdr;
-static u32_t seqno, ackno;
-static u8_t flags;
-static u16_t tcplen;
+static struct tcp_seg inseg = { 0 };
+static struct tcp_hdr *tcphdr = NULL;
+static struct ip_hdr *iphdr = NULL;
+static u32_t seqno = 0, ackno = 0;
+static u8_t flags = 0;
+static u16_t tcplen = 0;
 
-static u8_t recv_flags;
-static struct pbuf *recv_data;
+static u8_t recv_flags = 0;
+static struct pbuf *recv_data = NULL;
 
-struct tcp_pcb *tcp_input_pcb;
+struct tcp_pcb *tcp_input_pcb = NULL;
 
 /* Forward declarations. */
 static err_t tcp_process(struct tcp_pcb *pcb);
diff --git a/src/core/timers.c b/src/core/timers.c
index f0e92cc..1ba10c9 100644
--- a/src/core/timers.c
+++ b/src/core/timers.c
@@ -59,14 +59,14 @@
 
 
 /** The one and only timeout list */
-static struct sys_timeo *next_timeout;
+static struct sys_timeo *next_timeout = NULL;
 #if NO_SYS
-static u32_t timeouts_last_time;
+static u32_t timeouts_last_time = 0;
 #endif /* NO_SYS */
 
 #if LWIP_TCP
 /** global variable that shows if the tcp timer is currently scheduled or not */
-static int tcpip_tcp_timer_active;
+static int tcpip_tcp_timer_active = 0;
 
 /**
  * Timer callback function that calls tcp_tmr() and reschedules itself.
diff --git a/src/core/udp.c b/src/core/udp.c
index 4596ba2..f00abcb 100644
--- a/src/core/udp.c
+++ b/src/core/udp.c
@@ -66,7 +66,7 @@
 
 /* The list of UDP PCBs */
 /* exported in udp.h (was static) */
-struct udp_pcb *udp_pcbs;
+struct udp_pcb *udp_pcbs = NULL;
 
 /**
  * Process an incoming UDP datagram.
diff --git a/src/netif/etharp.c b/src/netif/etharp.c
index b60dadd..d68cc4a 100644
--- a/src/netif/etharp.c
+++ b/src/netif/etharp.c
@@ -109,10 +109,10 @@ struct etharp_entry {
 #endif /* ETHARP_SUPPORT_STATIC_ENTRIES */
 };
 
-static struct etharp_entry arp_table[ARP_TABLE_SIZE];
+static struct etharp_entry arp_table[ARP_TABLE_SIZE] = { 0 };
 
 #if !LWIP_NETIF_HWADDRHINT
-static u8_t etharp_cached_entry;
+static u8_t etharp_cached_entry = 0;
 #endif /* !LWIP_NETIF_HWADDRHINT */
 
 /** Try hard to create a new entry - we want the IP address to appear in
diff --git a/src/netif/ppp/auth.c b/src/netif/ppp/auth.c
index c3c49d2..857edf5 100644
--- a/src/netif/ppp/auth.c
+++ b/src/netif/ppp/auth.c
@@ -96,44 +96,44 @@
 
 #if PAP_SUPPORT || CHAP_SUPPORT
 /* The name by which the peer authenticated itself to us. */
-static char peer_authname[MAXNAMELEN];
+static char peer_authname[MAXNAMELEN] = { 0 };
 #endif /* PAP_SUPPORT || CHAP_SUPPORT */
 
 /* Records which authentication operations haven't completed yet. */
-static int auth_pending[NUM_PPP];
+static int auth_pending[NUM_PPP] = { 0 };
 
 /* Set if we have successfully called plogin() */
-static int logged_in;
+static int logged_in = 0;
 
 /* Set if we have run the /etc/ppp/auth-up script. */
-static int did_authup; /* @todo, we don't need this in lwip*/
+static int did_authup = 0; /* @todo, we don't need this in lwip*/
 
 /* List of addresses which the peer may use. */
-static struct wordlist *addresses[NUM_PPP];
+static struct wordlist *addresses[NUM_PPP] = { NULL };
 
 #if 0 /* UNUSED */
 /* Wordlist giving addresses which the peer may use
    without authenticating itself. */
-static struct wordlist *noauth_addrs;
+static struct wordlist *noauth_addrs = NULL;
 
 /* Extra options to apply, from the secrets file entry for the peer. */
-static struct wordlist *extra_options;
+static struct wordlist *extra_options = NULL;
 #endif /* UNUSED */
 
 /* Number of network protocols which we have opened. */
-static int num_np_open;
+static int num_np_open = 0;
 
 /* Number of network protocols which have come up. */
-static int num_np_up;
+static int num_np_up = 0;
 
 #if PAP_SUPPORT || CHAP_SUPPORT
 /* Set if we got the contents of passwd[] from the pap-secrets file. */
-static int passwd_from_file;
+static int passwd_from_file = 0;
 #endif /* PAP_SUPPORT || CHAP_SUPPORT */
 
 #if 0 /* UNUSED */
 /* Set if we require authentication only because we have a default route. */
-static bool default_auth;
+static bool default_auth = false;
 
 /* Hook to enable a plugin to control the idle time limit */
 int (*idle_time_hook) __P((struct ppp_idle *)) = NULL;
@@ -177,7 +177,7 @@ bool usehostname = 0;         /* Use hostname for our_name */
 bool auth_required = 0;       /* Always require authentication from peer */
 bool allow_any_ip = 0;        /* Allow peer to use any IP address */
 bool explicit_remote = 0;     /* User specified explicit remote name */
-char remote_name[MAXNAMELEN]; /* Peer's name for authentication */
+char remote_name[MAXNAMELEN] = { 0 }; /* Peer's name for authentication */
 
 #endif /* UNUSED */
 
diff --git a/src/netif/ppp/chap.c b/src/netif/ppp/chap.c
index 3a49ff8..b548380 100644
--- a/src/netif/ppp/chap.c
+++ b/src/netif/ppp/chap.c
@@ -137,7 +137,7 @@ struct protent chap_protent = {
 #endif /* PPP_ADDITIONAL_CALLBACKS */
 };
 
-chap_state chap[NUM_PPP]; /* CHAP state; one for each unit */
+chap_state chap[NUM_PPP] = { 0 }; /* CHAP state; one for each unit */
 
 static void ChapChallengeTimeout (void *);
 static void ChapResponseTimeout (void *);
diff --git a/src/netif/ppp/fsm.c b/src/netif/ppp/fsm.c
index 2e73c5a..8e4cc2c 100644
--- a/src/netif/ppp/fsm.c
+++ b/src/netif/ppp/fsm.c
@@ -92,7 +92,7 @@ static void fsm_sconfreq (fsm *, int);
 
 #define PROTO_NAME(f) ((f)->callbacks->proto_name)
 
-int peer_mru[NUM_PPP];
+int peer_mru[NUM_PPP] = { 0 };
 
 
 /*
diff --git a/src/netif/ppp/ipcp.c b/src/netif/ppp/ipcp.c
index 461a600..f237e29 100644
--- a/src/netif/ppp/ipcp.c
+++ b/src/netif/ppp/ipcp.c
@@ -70,14 +70,14 @@
 /* #define OLD_CI_ADDRS 1 */ /* Support deprecated address negotiation. */
 
 /* global vars */
-ipcp_options ipcp_wantoptions[NUM_PPP];  /* Options that we want to request */
-ipcp_options ipcp_gotoptions[NUM_PPP];   /* Options that peer ack'd */
-ipcp_options ipcp_allowoptions[NUM_PPP]; /* Options we allow peer to request */
-ipcp_options ipcp_hisoptions[NUM_PPP];   /* Options that we ack'd */
+ipcp_options ipcp_wantoptions[NUM_PPP] = { 0 };  /* Options that we want to request */
+ipcp_options ipcp_gotoptions[NUM_PPP] = { 0 };   /* Options that peer ack'd */
+ipcp_options ipcp_allowoptions[NUM_PPP] = { 0 }; /* Options we allow peer to request */
+ipcp_options ipcp_hisoptions[NUM_PPP] = { 0 };   /* Options that we ack'd */
 
 /* local vars */
-static int default_route_set[NUM_PPP]; /* Have set up a default route */
-static int cis_received[NUM_PPP];      /* # Conf-Reqs received */
+static int default_route_set[NUM_PPP] = { 0 }; /* Have set up a default route */
+static int cis_received[NUM_PPP] = { 0 };      /* # Conf-Reqs received */
 
 
 /*
@@ -98,7 +98,7 @@ static void ipcp_script (fsm *, char *); /* Run an up/down script */
 static void ipcp_finished (fsm *);                    /* Don't need lower layer */
 
 
-fsm ipcp_fsm[NUM_PPP]; /* IPCP fsm structure */
+fsm ipcp_fsm[NUM_PPP] = { 0 }; /* IPCP fsm structure */
 
 
 static fsm_callbacks ipcp_callbacks = { /* IPCP callback routines */
diff --git a/src/netif/ppp/lcp.c b/src/netif/ppp/lcp.c
index 21c83ac..0944353 100644
--- a/src/netif/ppp/lcp.c
+++ b/src/netif/ppp/lcp.c
@@ -90,24 +90,24 @@ static option_t lcp_option_list[] = {
 #endif /* UNUSED */
 
 /* options */
-LinkPhase lcp_phase[NUM_PPP];          /* Phase of link session (RFC 1661) */
+LinkPhase lcp_phase[NUM_PPP]        = { PHASE_DEAD };   /* Phase of link session (RFC 1661) */
 static u_int lcp_echo_interval      = LCP_ECHOINTERVAL; /* Interval between LCP echo-requests */
 static u_int lcp_echo_fails         = LCP_MAXECHOFAILS; /* Tolerance to unanswered echo-requests */
 
 /* global vars */
-static fsm lcp_fsm[NUM_PPP];                            /* LCP fsm structure (global)*/
-lcp_options lcp_wantoptions[NUM_PPP];  /* Options that we want to request */
-lcp_options lcp_gotoptions[NUM_PPP];   /* Options that peer ack'd */
-lcp_options lcp_allowoptions[NUM_PPP]; /* Options we allow peer to request */
-lcp_options lcp_hisoptions[NUM_PPP];   /* Options that we ack'd */
-ext_accm xmit_accm[NUM_PPP];           /* extended transmit ACCM */
+static fsm lcp_fsm[NUM_PPP]           = { 0 }; /* LCP fsm structure (global)*/
+lcp_options lcp_wantoptions[NUM_PPP]  = { 0 }; /* Options that we want to request */
+lcp_options lcp_gotoptions[NUM_PPP]   = { 0 }; /* Options that peer ack'd */
+lcp_options lcp_allowoptions[NUM_PPP] = { 0 }; /* Options we allow peer to request */
+lcp_options lcp_hisoptions[NUM_PPP]   = { 0 }; /* Options that we ack'd */
+ext_accm xmit_accm[NUM_PPP]           = { 0 }; /* extended transmit ACCM */
 
 static u32_t lcp_echos_pending      = 0;                /* Number of outstanding echo msgs */
 static u32_t lcp_echo_number        = 0;                /* ID number of next echo frame */
 static u32_t lcp_echo_timer_running = 0;                /* TRUE if a timer is running */
 
 /* @todo: do we really need such a large buffer? The typical 1500 bytes seem too much. */
-static u_char nak_buffer[PPP_MRU]; /* where we construct a nak packet */ 
+static u_char nak_buffer[PPP_MRU] = { 0 }; /* where we construct a nak packet */ 
 
 /*
  * Callbacks for fsm code.  (CI = Configuration Information)
diff --git a/src/netif/ppp/pap.c b/src/netif/ppp/pap.c
index ac44e64..f9fd6e7 100644
--- a/src/netif/ppp/pap.c
+++ b/src/netif/ppp/pap.c
@@ -118,7 +118,7 @@ struct protent pap_protent = {
 #endif /* PPP_ADDITIONAL_CALLBACKS */
 };
 
-upap_state upap[NUM_PPP]; /* UPAP state; one for each unit */
+upap_state upap[NUM_PPP] = { 0 }; /* UPAP state; one for each unit */
 
 static void upap_timeout   (void *);
 static void upap_reqtimeout(void *);
diff --git a/src/netif/ppp/ppp.c b/src/netif/ppp/ppp.c
index e9b433b..f9b1c36 100644
--- a/src/netif/ppp/ppp.c
+++ b/src/netif/ppp/ppp.c
@@ -247,9 +247,9 @@ static void pppInProc(PPPControlRx *pcrx, u_char *s, int l);
 /******************************/
 /*** PUBLIC DATA STRUCTURES ***/
 /******************************/
-u_long subnetMask;
+u_long subnetMask = 0;
+static PPPControl pppControl[NUM_PPP] = { 0 }; /* The PPP interface control blocks. */
 
-static PPPControl pppControl[NUM_PPP]; /* The PPP interface control blocks. */
 
 /*
  * PPP Data Link Layer "protocol" table.
diff --git a/src/netif/ppp/ppp_oe.c b/src/netif/ppp/ppp_oe.c
index 040a0bc..1b2360e 100644
--- a/src/netif/ppp/ppp_oe.c
+++ b/src/netif/ppp/ppp_oe.c
@@ -110,7 +110,7 @@
 #ifndef PPPOE_ERRORSTRING_LEN
 #define PPPOE_ERRORSTRING_LEN     64
 #endif
-static char pppoe_error_tmp[PPPOE_ERRORSTRING_LEN];
+static char pppoe_error_tmp[PPPOE_ERRORSTRING_LEN] = { 0 };
 
 
 /* input routines */
@@ -138,7 +138,7 @@ static struct pppoe_softc * pppoe_find_softc_by_session(u_int, struct netif *);
 static struct pppoe_softc * pppoe_find_softc_by_hunique(u8_t *, size_t, struct netif *);
 
 /** linked list of created pppoe interfaces */
-static struct pppoe_softc *pppoe_softc_list;
+static struct pppoe_softc *pppoe_softc_list = NULL;
 
 err_t
 pppoe_create(struct netif *ethif, int pd, void (*linkStatusCB)(int pd, int up), struct pppoe_softc **scptr)
diff --git a/src/netif/ppp/randm.c b/src/netif/ppp/randm.c
index 2f35caf..44f6ea7 100644
--- a/src/netif/ppp/randm.c
+++ b/src/netif/ppp/randm.c
@@ -49,7 +49,7 @@
 /*****************************/
 /*** LOCAL DATA STRUCTURES ***/
 /*****************************/
-static char randPool[RANDPOOLSZ];   /* Pool of randomness. */
+static char randPool[RANDPOOLSZ] = { 0 };   /* Pool of randomness. */
 static long randCount = 0;      /* Pseudo-random incrementer */
 
 
-- 
1.7.7.msysgit.1

