netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com,
	Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH net-next 05/12] tools: ynl-gen: get attr type outside of if()
Date: Thu,  8 Jun 2023 14:11:53 -0700	[thread overview]
Message-ID: <20230608211200.1247213-6-kuba@kernel.org> (raw)
In-Reply-To: <20230608211200.1247213-1-kuba@kernel.org>

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>
---
 tools/net/ynl/ynl-gen-c.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

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 @@ from lib import SpecFamily, SpecAttrSet, SpecAttr, SpecOperation, SpecEnumSet, S
             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 @@ _C_KW = {
 
     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():
-- 
2.40.1


  parent reply	other threads:[~2023-06-08 21:12 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-08 21:11 [PATCH net-next 00/12] tools: ynl-gen: code gen improvements before ethtool Jakub Kicinski
2023-06-08 21:11 ` [PATCH net-next 01/12] tools: ynl-gen: cleanup user space header includes Jakub Kicinski
2023-06-08 21:11 ` [PATCH net-next 02/12] tools: ynl: regen: " Jakub Kicinski
2023-06-08 21:11 ` [PATCH net-next 03/12] tools: ynl-gen: complete the C keyword list Jakub Kicinski
2023-06-08 21:11 ` [PATCH net-next 04/12] tools: ynl-gen: combine else with closing bracket Jakub Kicinski
2023-06-08 21:11 ` Jakub Kicinski [this message]
2023-06-08 21:11 ` [PATCH net-next 06/12] tools: ynl: regen: regenerate the if ladders Jakub Kicinski
2023-06-08 21:11 ` [PATCH net-next 07/12] tools: ynl-gen: stop generating common notification handlers Jakub Kicinski
2023-06-08 21:11 ` [PATCH net-next 08/12] tools: ynl: regen: " Jakub Kicinski
2023-06-08 21:11 ` [PATCH net-next 09/12] tools: ynl-gen: sanitize notification tracking Jakub Kicinski
2023-06-08 21:11 ` [PATCH net-next 10/12] tools: ynl-gen: support code gen for events Jakub Kicinski
2023-06-08 21:11 ` [PATCH net-next 11/12] tools: ynl-gen: don't pass op_name to RenderInfo Jakub Kicinski
2023-06-08 21:12 ` [PATCH net-next 12/12] tools: ynl-gen: support / skip pads on the way to kernel Jakub Kicinski
2023-06-09 21:50 ` [PATCH net-next 00/12] tools: ynl-gen: code gen improvements before ethtool patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230608211200.1247213-6-kuba@kernel.org \
    --to=kuba@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).