Re: [PATCH net-next v3 04/13] tools: ynl-gen: refactor local vars for .attr_put() callers

Jakub Kicinski <[email protected]>
Newsgroups com.zx2c4.lists.wireguard,org.kernel.vger.linux-kernel,org.kernel.vger.netdev
Message-ID <[email protected]>
On Thu, 11 Sep 2025 20:04:57 +0000 Asbjørn Sloth Tønnesen wrote:
> +    def attr_put_local_vars(self):
> +        local_vars = []
> +        if self.presence_type() == 'count':
> +            local_vars.append('unsigned int i;')
> +        return local_vars
> +
>      def attr_put(self, ri, var):
>          raise Exception(f"Put not implemented for class type {self.type}")
>  
> @@ -840,6 +846,10 @@ class TypeArrayNest(Type):
>                       '}']
>          return get_lines, None, local_vars
>  
> +    def attr_put_local_vars(self):
> +        local_vars = ['struct nlattr *array;']
> +        return local_vars + super().attr_put_local_vars()

Doesn't feel right. The Type method is a helper which is compatible
with the specific types by checking presence, then you override it,
and on top of that combine the output with super(). I don't like.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.