From 732cac1c0eceabcade0004b41089e7542c14b8e0 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 f58ba1ab..754f1112 100644 --- a/src/core/netif.c +++ b/src/core/netif.c @@ -82,6 +82,8 @@ struct netif *netif_list; struct netif *netif_default; +static u8_t netif_num; + #if LWIP_HAVE_LOOPIF static struct netif loop_netif; @@ -144,7 +146,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; #if LWIP_IPV6 u32_t i; #endif @@ -200,7 +201,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; NETIF_SET_HWADDRHINT(netif, NULL); #if ENABLE_LOOPBACK && LWIP_LOOPBACK_MAX_PBUFS