From 717b2dab59a1a12cc57a4f2aacbaf825a5b0cdaf Mon Sep 17 00:00:00 2001 From: goldsimon Date: Tue, 7 Jun 2011 19:10:55 +0000 Subject: [PATCH] Moved static variable from inside the function to global scope --- src/core/dhcp.c | 7 +++++-- src/core/netif.c | 5 +++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/core/dhcp.c b/src/core/dhcp.c index ad2ad8fd..ecfe283b 100644 --- a/src/core/dhcp.c +++ b/src/core/dhcp.c @@ -126,6 +126,11 @@ u32_t dhcp_rx_options_val[DHCP_OPTION_IDX_MAX]; @todo: move this into struct dhcp? */ u8_t dhcp_rx_options_given[DHCP_OPTION_IDX_MAX]; +#ifdef DHCP_GLOBAL_XID +static u32_t xid; +static u8_t xid_initialised; +#endif /* DHCP_GLOBAL_XID */ + #define dhcp_option_given(dhcp, idx) (dhcp_rx_options_given[idx] != 0) #define dhcp_got_option(dhcp, idx) (dhcp_rx_options_given[idx] = 1) #define dhcp_clear_option(dhcp, idx) (dhcp_rx_options_given[idx] = 0) @@ -1628,8 +1633,6 @@ dhcp_create_msg(struct netif *netif, struct dhcp *dhcp, u8_t message_type) * at runtime, any supporting function prototypes can be defined in DHCP_GLOBAL_XID_HEADER */ static u32_t xid = 0xABCD0000; #else - static u32_t xid; - static u8_t xid_initialised = 0; if (!xid_initialised) { xid = DHCP_GLOBAL_XID; xid_initialised = !xid_initialised; diff --git a/src/core/netif.c b/src/core/netif.c index f190b1f2..2b1abf71 100644 --- a/src/core/netif.c +++ b/src/core/netif.c @@ -75,6 +75,8 @@ struct netif *netif_list; struct netif *netif_default; +static u8_t netif_num; + #if LWIP_HAVE_LOOPIF static struct netif loop_netif; @@ -137,7 +139,6 @@ struct netif * netif_add(struct netif *netif, ip_addr_t *ipaddr, ip_addr_t *netmask, ip_addr_t *gw, void *state, netif_init_fn init, netif_input_fn input) { - static u8_t netifnum = 0; LWIP_ASSERT("No init function given", init != NULL); @@ -170,7 +171,7 @@ netif_add(struct netif *netif, ip_addr_t *ipaddr, ip_addr_t *netmask, /* remember netif specific state information data */ netif->state = state; - netif->num = netifnum++; + netif->num = netif_num++; netif->input = input; #if LWIP_NETIF_HWADDRHINT netif->addr_hint = NULL;