diff options
author | Jakub Kicinski | 2023-06-08 14:11:53 -0700 |
---|---|---|
committer | Jakub Kicinski | 2023-06-09 14:40:31 -0700 |
commit | e4ea3cc68472b1cc0b68a1adf145ee39fb90a506 (patch) | |
tree | 71413c6e7b6bf461655ee500ef5d56487a5361a9 /tools/net | |
parent | 2c0f1466867c8405224b97d978b67f35d76b1dc1 (diff) |
tools: ynl-gen: get attr type outside of if()
Reading attr type with mnl_attr_get_type() for each condition
leads to most conditions being longer than 80 chars.
Avoid this by reading the type to a variable on the stack.
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'tools/net')
-rwxr-xr-x | tools/net/ynl/ynl-gen-c.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py index d2edded5f747..ecd8beba7e0d 100755 --- a/tools/net/ynl/ynl-gen-c.py +++ b/tools/net/ynl/ynl-gen-c.py @@ -153,7 +153,7 @@ class Type(SpecAttr): init_lines = [init_lines] kw = 'if' if first else 'else if' - ri.cw.block_start(line=f"{kw} (mnl_attr_get_type(attr) == {self.enum_name})") + ri.cw.block_start(line=f"{kw} (type == {self.enum_name})") if local_vars: for local in local_vars: ri.cw.p(local) @@ -1418,6 +1418,8 @@ def _multi_parse(ri, struct, init_lines, local_vars): ri.cw.nl() ri.cw.block_start(line=iter_line) + ri.cw.p('unsigned int type = mnl_attr_get_type(attr);') + ri.cw.nl() first = True for _, arg in struct.member_list(): |