From eac8ce42799ecb17271a70aa52185b54173de399 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Wed, 22 Jul 2015 14:00:06 -0600 Subject: [PATCH 2/4] qapi: update typedef usage Change from: typedef struct fooList { ... struct fooList *next; } fooList; to: typedef struct fooList fooList; struct fooList { ... struct fooList *next; }; If desired, we could further eliminate the now-spurious 'struct' from the 'next' member of the list. Note that qemu does not have any standard on which of the two forms is preferred, and that more uses tend to go with the typedef and declaration smashed into one. --- scripts/qapi-types.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/scripts/qapi-types.py b/scripts/qapi-types.py index b7028f6..d21381c 100644 --- a/scripts/qapi-types.py +++ b/scripts/qapi-types.py @@ -15,13 +15,15 @@ from qapi import * def generate_fwd_builtin(name): return mcgen(''' -typedef struct %(name)sList { +typedef struct %(name)sList %(name)sList; + +struct %(name)sList { union { %(type)s value; uint64_t padding; }; struct %(name)sList *next; -} %(name)sList; +}; ''', type=c_type(name), name=name) @@ -31,26 +33,30 @@ def generate_fwd_struct(name): typedef struct %(name)s %(name)s; -typedef struct %(name)sList { +typedef struct %(name)sList %(name)sList; + +struct %(name)sList { union { %(name)s *value; uint64_t padding; }; struct %(name)sList *next; -} %(name)sList; +}; ''', name=c_name(name)) def generate_fwd_enum_struct(name): return mcgen(''' -typedef struct %(name)sList { +typedef struct %(name)sList %(name)sList; + +struct %(name)sList { union { %(name)s value; uint64_t padding; }; struct %(name)sList *next; -} %(name)sList; +}; ''', name=c_name(name)) -- 2.4.3