In pyynl's current render_uapi() implementation there exists a check that is intended to ensure that definitions of type "enum" or "flags" have a doc entry before calling write_doc_line(). However, this check still passes for anonymous enums since enum.has_doc() still evaluates as true, so they still take the kdoc code path. As a result, this path attempts to hang the entry docs off of enum.enum_name (which is of type None), raising a TypeError. Both the ovs_datapath.yaml and ovs_flow.yaml specs will fail to generate uapi headers in today's tree: $ ynl_gen_c.py --spec Documentation/netlink/specs/ovs_datapath.yaml \ --mode uapi --header Traceback (most recent call last): File "tools/net/ynl/pyynl/ynl_gen_c.py", line 3780, in main() ~~~~^^ File "tools/net/ynl/pyynl/ynl_gen_c.py", line 3511, in main render_uapi(parsed, cw) ~~~~~~~~~~~^^^^^^^^^^^^ File "tools/net/ynl/pyynl/ynl_gen_c.py", line 3255, in render_uapi cw.write_doc_line(enum.enum_name + doc) ~~~~~~~~~~~~~~~^~~~~ TypeError: unsupported operand type(s) for +: 'NoneType' and 'str' The fix implemented by this patch instead generates a plain comment in this scenario as there is no kdoc identifier to hang the documentation off of. Fixes: 690e50dd69ee ("tools: ynl-gen: de-kdocify enums with no doc for entries") Signed-off-by: Taylor Bates --- tools/net/ynl/pyynl/ynl_gen_c.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tools/net/ynl/pyynl/ynl_gen_c.py b/tools/net/ynl/pyynl/ynl_gen_c.py index 1c422141d2d7..66a6dbe07125 100755 --- a/tools/net/ynl/pyynl/ynl_gen_c.py +++ b/tools/net/ynl/pyynl/ynl_gen_c.py @@ -3247,15 +3247,17 @@ def render_uapi(family, cw): continue if enum.has_doc(): - if enum.has_entry_doc(): + if enum.has_entry_doc() and enum.enum_name: cw.p('/**') doc = '' if 'doc' in enum: doc = ' - ' + enum['doc'] cw.write_doc_line(enum.enum_name + doc) else: + # Render a plain comment, no kdoc identifier available cw.p('/*') - cw.write_doc_line(enum['doc'], indent=False) + if 'doc' in enum: + cw.write_doc_line(enum['doc'], indent=False) for entry in enum.entries.values(): if entry.has_doc(): doc = '@' + entry.c_name + ': ' + entry['doc'] -- 2.55.0