Hey Piotr, I hate to turn you down on that, but the variables are deliberately not being initialized: when not initialized (and thus implicitly zeroed at startup), they are put into the uninitialized section and no space on disk/in flash is needed. However when they are initialized to NULL, they are put NGO the initialized data section, which is present on disk/in flash, too.
As to the portability: the C standard requires non initialized data to be initialized to zero at startup. It is a common error in self-made ports to leave out the zeroing of the uninitialized data section (.bss for gnu bcc). Simon Piotr Piwko <[email protected]> wrote: > 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, > > -- > Piotr Piwko > http://www.embedded-engineering.pl/ > > _______________________________________________ > lwip-users mailing list > [email protected] > http://lists.nongnu.org/mailman/listinfo/lwip-users _______________________________________________ lwip-users mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/lwip-users
