[ccan] [PATCH 0/4] Replace TCON() with TCON_WRAP()

David Gibson david at gibson.dropbear.id.au
Sun Jul 23 22:29:03 AEST 2017


ccan/tcon has two basic ways to be used.  With TCON() which adds a
type canary to a user's existing structure, or with TCON_WRAP(), which
wraps a user's structure creating a new structure with the canaries.

TCON() is older and has several modules already using it.
Unfortunately, it uses flexible-array members which aren't allowed in
the middle of structures, except as a gcc extension.  That means with
a "normal" compiler TCON() invocations can only appear at the end of a
structure.  More importantly it also means a structure including them
can never be embedded in another structure except at the end.

In short, using TCON() is either non-portable, or badly violates
principle of least surprise.  So, this series removes use of it from
all existing ccan modules.

David Gibson (4):
  tlist: Use TCON_WRAP instead of TCON
  jset: Use TCON_WRAP instead of TCON
  jmap: Use TCON_WRAP instead of TCON
  objset: Use TCON_WRAP instead of TCON

 ccan/jmap/jmap.h      | 59 +++++++++++++++++++++++++++++----------------------
 ccan/jmap/test/run.c  |  8 +++----
 ccan/jset/jset.h      | 45 ++++++++++++++++++++++++---------------
 ccan/jset/test/run.c  |  9 ++++----
 ccan/objset/objset.h  | 31 +++++++++++++++------------
 ccan/tlist/_info      |  6 +-----
 ccan/tlist/test/run.c | 24 ++++++++++-----------
 ccan/tlist/tlist.h    | 25 +++++++++++-----------
 8 files changed, 114 insertions(+), 93 deletions(-)

-- 
2.13.3



More information about the ccan mailing list