|
From: | address@hidden |
Subject: | Re: [lwip-users] Initialization of global variables |
Date: | Fri, 05 Nov 2010 21:29:48 +0100 |
User-agent: | Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; de; rv:1.9.2.12) Gecko/20101027 Thunderbird/3.1.6 |
Rick Solotke wrote:
You could have had that problem with any other third-party library. Why not rely on a fact that is defined in the C standard? It makes the binary smaller. OK, there might be code where those global variables get initalized to zero/NULL again (lwIP did that, too, up to 1.2.0, I think), but it's really smaller (and standard conformant) the way it is now.I just wanted to pop in and say that I have observed and debugged the same problem, specifically for the UDP and TCP PCB lists. It would be great if the code could be changed to explicitly initialize these to NULL.
If startup time really does matter, it would of course be best to explicitly put those global variables into a different (non-zeroed) section where you know they don't need initialization. It's more portable that way than relying on all the code to not need the zero-initialization.
Simon
Cheers, Rick -----Original Message----- From: address@hidden [mailto:address@hidden On Behalf Of Piotr Piwko Sent: Friday, November 05, 2010 11:36 AM To: address@hidden Subject: [lwip-users] Initialization of global variables Hello, I currently implement the LwIP stack under u-boot environment and I have one notice regarding global variables initialization. I think that every global variable which are not static should be initialized by NULL or 0 value. I mean for example: file tcp.c: struct tcp_pcb *tcp_bound_pcbs; union tcp_listen_pcbs_t tcp_listen_pcbs; struct tcp_pcb *tcp_active_pcbs; struct tcp_pcb *tcp_tw_pcbs; file udp.c: struct udp_pcb *udp_pcbs; file netif.c: struct netif *netif_list; struct netif *netif_default; If I leave they uninitialized, after compilation and link operation they will contain random values which causes the system crash during LwIP initialized functions. Assumption that they will be automatically filled by 0 is wrong and non-portable. This modification can really save a lot of time during integration :) Anyway I am impressed with LwIP project. It is very useful part of software. Good job guys! Regards,
[Prev in Thread] | Current Thread | [Next in Thread] |