| Summary: | queue(3) STAILQ_INSERT_TAIL is suprising when the queue is empty | ||
|---|---|---|---|
| Product: | Base System | Reporter: | hgoldste <hgoldste> |
| Component: | kern | Assignee: | GNATS administrator <gnats-admin> |
| Status: | Closed FIXED | ||
| Severity: | Affects Only Me | ||
| Priority: | Normal | ||
| Version: | 3.3-STABLE | ||
| Hardware: | Any | ||
| OS: | Any | ||
|
Description
Justin T. Gibbs
1999-11-17 15:18:37 UTC
Fix: Work around: if STAILQ_EMPTY Use STAILQ_INSERT_HEAD else Use STAILQ_INSERT_TAIL How-To-Repeat: Create an empty tail queue with STAILQ_INIT. Then use STAILQ_INSERT_TAIL to add an entry to the queue. Then test STAILQ_EMPTY which will report empty. Note that further use of _INSERT_TAIL on this queue will correctly link the new records together except that the head node continues to point to NULL Justin T. Gibbs writes: > >>Synopsis: queue(3) STAILQ_INSERT_TAIL is suprising when the queue is > empty ... > Of course if you fail to properly initialize an STAILQ, this assumption > will fail and the macro will not do the right thing. Do you have a > code example that displays a problem with the macros? From inspection, > the macros look correct. Thank you Justin. You're entirely correct on all counts. Since you took the trouble to verify queue.h you're at least entitled to a post mortem on the problem (if you're interested). If not interested, please accept my thanks again and do feel free to close the PR out... (prob: as you indicated, failure to initialize. Not only was _INSERT_TAIL called before it was _INITd but so was the state machine (implementing the protocol to talk to a GPS board) that called _INSERT_TAIL. It's quite likely the unit'd state machine clobbered other program data but in a way that wasn't apparent) State Changed From-To: open->closed Originator confirms that the bug was elsewhere in his code. |