Markus Armbruster <arm...@redhat.com> writes: > marcandre.lur...@redhat.com writes: > >> From: Marc-André Lureau <marcandre.lur...@redhat.com> >> >> Instead of building prepocessor conditions from a list of string, use >> the result generated from QAPISchemaIfCond.cgen() and hide the >> implementation details. >> >> Signed-off-by: Marc-André Lureau <marcandre.lur...@redhat.com> > > Please mention that the patch changes generated code. See below for > details.
[...] > This patch does three things: > > (1) Change gen_if(), gen_endif() to always generate a single #if, > #endif. This enables: > > (2) Factor cgen_ifcond() out of gen_if() and gen_endif() > > (3) Lift the call of cgen_ifcond() into into gen_if()'s, gen_endif()'s > callers. > > I'd split the patch. This is *not* a demand. > > The motivation for (3) is unclear. Is it so gen_if() doesn't depend on > QAPISchemaIfCond? > > Step (1) affects the generated code. When @ifcond is [COND1, COND2, ...], > gen_if()'s value changes from > > #if COND1 > #if COND2 > ... > > to > > #if (COND1) && (COND2) [...] > The common case: when it's just [COND], the value changes from > > #if COND > > to > > #if (COND) > > which is a bit ugly. > > Example: in qapi-types-block-export.c [...] > Avoiding the redundant pair of parenthesis takes another special case. > Let's do it. Looks like PATCH 07 does it. Avoiding the temporary change would be nice, but isn't required.