mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Taylor Bates <tmbates12@gmail.com>
To: Donald Hunter <donald.hunter@gmail.com>,
	 Jakub Kicinski <kuba@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	 Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>,  Simon Horman <horms@kernel.org>,
	Jiri Pirko <jiri@resnulli.us>,
	 Stanislav Fomichev <sdf@fomichev.me>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Taylor Bates <tmbates12@gmail.com>
Subject: [PATCH net-next 4/4] tools: ynl: fix uapi generation for anonymous enums with documented entries
Date: Tue, 08 Sep 2026 19:45:10 -0400	[thread overview]
Message-ID: <20260908-ynl-robustness-v1-4-f255214c0f30@gmail.com> (raw)
In-Reply-To: <20260908-ynl-robustness-v1-0-f255214c0f30@gmail.com>

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 <module>
      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 <tmbates12@gmail.com>
---
 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


  parent reply	other threads:[~2026-09-08 23:45 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-08 23:45 [PATCH net-next 0/4] netlink: fix ynl spec tooling robustness bugs Taylor Bates
2026-09-08 23:45 ` [PATCH net-next 1/4] netlink: specs: fix duplicate if/then keys in netlink-raw schema Taylor Bates
2026-09-08 23:45 ` [PATCH net-next 2/4] tools: ynl: reject zero-length attributes instead of looping forever Taylor Bates
2026-09-11  2:25   ` Jakub Kicinski
2026-09-08 23:45 ` [PATCH net-next 3/4] tools: ynl: stop find_kernel_root() spinning at the filesystem root Taylor Bates
2026-09-11  2:26   ` Jakub Kicinski
2026-09-08 23:45 ` Taylor Bates [this message]
2026-09-11  2:27   ` [PATCH net-next 4/4] tools: ynl: fix uapi generation for anonymous enums with documented entries Jakub Kicinski
2026-09-11  2:23 ` [PATCH net-next 0/4] netlink: fix ynl spec tooling robustness bugs Jakub Kicinski
2026-09-12 17:35   ` tmbates12
2026-09-14 23:12     ` Jakub Kicinski
2026-09-15  1:46       ` tmbates12
2026-09-15 15:54         ` Jakub Kicinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260908-ynl-robustness-v1-4-f255214c0f30@gmail.com \
    --to=tmbates12@gmail.com \
    --cc=davem@davemloft.net \
    --cc=donald.hunter@gmail.com \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sdf@fomichev.me \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®