tlist: Use TCON_WRAP instead of TCON TCON() uses flexible-array members which aren't allowed in the middle of structures, except as a gcc extension. TCON_WRAP() avoids this and so is more portable. This doesn't change the tlist interface, only its internals. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
tlist: Place tlists last in structures TCON suggests placing _tcon members last in structs. Placing variable sized structs anywhere but last is apparently a gcc extension that gives warnings under clang. This applies to tlists because they use TCON internally. Update the docs and examples to place tlists last and so compile without clang warnings. There are other places where this occurs; they will be dealt with separately. Signed-off-by: Jon Griffiths <jon_p_griffiths@yahoo.com>
tlist: Add tlist_next() and tlist_prev() functions An odd omission from the tlist module is basic tlist_next() and tlist_prev() macros matching list_next() and list_prev() in the basic list module. This adds them. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ccan: Correct some poor conventions in _info includes There are a couple of small problems with the includes used in most of ccan's _info files. * _info routinely uses printf(), and so should include <stdio.h>, but only some of them do. We get away with it, because they do include <string.h>, which apparently includes <stdio.h> indirectly, but we should be explicit about it. * Most _info files were including config.h after the system headers. That _seems_ sensible, but actually causes problems. Because config.h defines _GNU_SOURCE it can change the behaviour of the system headers. More specifically it can make them behave differently to how the individual module headers (which have included config.h) expects them to behave. This patch adjusts all the existing _info files and, more importantly, the template constructed by ccanlint. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
tlist: remove unused var warning in example. Compiler: /home/rusty/devel/cvs/ccan/ccan/tlist/tlist.h: In function ‘main’: /home/rusty/devel/cvs/ccan/ccan/tlist/tlist.h:186:15: warning: variable ‘first’ set but not used [-Wunused-but-set-variable] Compiler: /home/rusty/devel/cvs/ccan/ccan/tlist/tlist.h: In function ‘main’: /home/rusty/devel/cvs/ccan/ccan/tlist/tlist.h:205:15: warning: variable ‘last’ set but not used [-Wunused-but-set-variable] Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
tlist: remove type arg from tlist_top(), tlist_tail() With the type canary, it's unnecessary. Though the implementation is a bit more awkward since they longer map directly through to list_top/tail.
tlist: typesafe variant of list module. I chose not to do the "macro creates set of routines" approach, as we can be almost as safe with a struct containing a pointer to the member type.