lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-devel] [task #7054] Clarification needed for variable initializati


From: Simon Goldschmidt
Subject: [lwip-devel] [task #7054] Clarification needed for variable initialization
Date: Tue, 03 Jul 2007 21:55:10 +0000
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4

URL:
  <http://savannah.nongnu.org/task/?7054>

                 Summary: Clarification needed for variable initialization
                 Project: lwIP - A Lightweight TCP/IP stack
            Submitted by: goldsimon
            Submitted on: Dienstag 03.07.2007 um 19:43
                Category: None
         Should Start On: Dienstag 03.07.2007 um 00:00
   Should be Finished on: Dienstag 03.07.2007 um 00:00
                Priority: 5 - Normal
                  Status: None
                 Privacy: Public
        Percent Complete: 0%
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
                  Effort: 0.00

    _______________________________________________________

Details:

The current code mixes:
- initialization to zero for global (and global static) variables
- uninitialized static arrays (initialized to 0 by compiler/loader)
- initialization to other values for global variables
- initialization in _init() functions

I'd favour making it the same for all files:
- always initialize non-zero global variables at declaration (e.g.
tcp_backoff array)
- create define to initialize global variables to zero or not (decides which
section they are put into and if they take place in the binary before
execution) (e.g. 'struct tcp_pcb *tcp_tw_pcbs INIT_NULL;' and '#define
INIT_NULL = 0' or '#define INIT_NULL') (there is a downside for arrays, so
arrays that should be zeroed - like sockets[NUM_SOCKETS] - would have to be
memset to NULL in an init function)
- generally don't zero variables in init functions that are already zeroed on
declaration

Any comments or preferences?




    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/task/?7054>

_______________________________________________
  Nachricht geschickt von/durch Savannah
  http://savannah.nongnu.org/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]