[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <m2h5z39sk8.fsf@gmail.com>
Date: Wed, 23 Jul 2025 10:15:19 +0100
From: Donald Hunter <donald.hunter@...il.com>
To: Jakub Kicinski <kuba@...nel.org>
Cc: davem@...emloft.net, netdev@...r.kernel.org, edumazet@...gle.com,
pabeni@...hat.com, andrew+netdev@...n.ch, horms@...nel.org,
almasrymina@...gle.com, sdf@...ichev.me
Subject: Re: [PATCH net-next 4/5] tools: ynl-gen: print setters for
multi-val attrs
Jakub Kicinski <kuba@...nel.org> writes:
> 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;
> }
>
> Signed-off-by: Jakub Kicinski <kuba@...nel.org>
Reviewed-by: Donald Hunter <donald.hunter@...il.com>
Powered by blists - more mailing lists