Subject: [PATCH net-next 03/12] tools: ynl-gen: fill in missing empty attr lists

From: Jakub Kicinski <[email-masked]>
Date: Wed, 23 Apr 2025 19:11:58 -0700

The C codegen refers to op attribute lists all over the place,
without checking if they are present, even tho attribute list
is technically an optional property. Add them automatically
at init if missing so that we don't have to make specs longer.

Signed-off-by: Jakub Kicinski <[email-masked]>
---
 tools/net/ynl/pyynl/ynl_gen_c.py | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/tools/net/ynl/pyynl/ynl_gen_c.py b/tools/net/ynl/pyynl/ynl_gen_c.py
index 90f7fe6b623b..569768bcf155 100755
--- a/tools/net/ynl/pyynl/ynl_gen_c.py
+++ b/tools/net/ynl/pyynl/ynl_gen_c.py
@@ -938,6 +938,16 @@ from lib import SpecFamily, SpecAttrSet, SpecAttr, SpecOperation, SpecEnumSet, S
 
 class Operation(SpecOperation):
     def __init__(self, family, yaml, req_value, rsp_value):
+        # Fill in missing operation properties (for fixed hdr-only msgs)
+        for mode in ['do', 'dump', 'event']:
+            if mode not in yaml.keys():
+                continue
+            for direction in ['request', 'reply']:
+                if direction not in yaml[mode]:
+                    continue
+                if 'attributes' not in yaml[mode][direction]:
+                    yaml[mode][direction]['attributes'] = []
+
         super().__init__(family, yaml, req_value, rsp_value)
 
         self.render_name = c_lower(family.ident_name + '_' + self.name)
-- 
2.49.0