]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
tools: ynl-gen: print setters for multi-val attrs
authorJakub Kicinski <kuba@kernel.org>
Wed, 23 Jul 2025 17:10:45 +0000 (10:10 -0700)
committerJakub Kicinski <kuba@kernel.org>
Fri, 25 Jul 2025 00:28:49 +0000 (17:28 -0700)
commit8553fb7c555c15f32ebbc5d032f35589e970e206
tree837e487da5f11f176118225cf601d689941e5917
parent2c222dde61c4fcb8693d31acf5ef8e342fda4c26
tools: ynl-gen: print setters for multi-val attrs

For basic types we "flatten" setters. If a request "a" has a simple
nest "b" with value "val" we print helpers like:

 req_set_a_b(struct a *req, int val)
 {
   req->_present.a = 1;
   req->b._present.val = 1;
   req->b.val = ...
 }

This is not possible for multi-attr because they have to be allocated
dynamically by the user. Print "object level" setters so that user
preparing the object doesn't have to futz with the presence bits
and other YNL internals.

Add the ability to pass in the variable name to generated setters.
Using "req" here doesn't feel right, while the attr is part of a request
it's not the request itself, so it seems cleaner to call it "obj".

Example:

 static inline void
 netdev_queue_id_set_id(struct netdev_queue_id *obj, __u32 id)
 {
obj->_present.id = 1;
obj->id = id;
 }

Reviewed-by: Donald Hunter <donald.hunter@gmail.com>
Acked-by: Stanislav Fomichev <sdf@fomichev.me>
Link: https://patch.msgid.link/20250723171046.4027470-5-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
tools/net/ynl/pyynl/ynl_gen_c.py