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,
	simon.horman@corigine.com, sdf@google.com,
	willemdebruijn.kernel@gmail.com, Jakub Kicinski <kuba@kernel.org>
Subject: [PATCH net-next v3 1/4] tools: ynl-gen: clean up stray new lines at the end of reply-less requests
Date: Mon,  5 Jun 2023 12:01:05 -0700	[thread overview]
Message-ID: <20230605190108.809439-2-kuba@kernel.org> (raw)
In-Reply-To: <20230605190108.809439-1-kuba@kernel.org>

Do not print empty lines before closing brackets.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 tools/net/ynl/ynl-gen-c.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/tools/net/ynl/ynl-gen-c.py b/tools/net/ynl/ynl-gen-c.py
index 4c12c6f8968e..1e64c5c2a087 100755
--- a/tools/net/ynl/ynl-gen-c.py
+++ b/tools/net/ynl/ynl-gen-c.py
@@ -944,9 +944,10 @@ from lib import SpecFamily, SpecAttrSet, SpecAttr, SpecOperation, SpecEnumSet, S
     def _is_cond(cls, line):
         return line.startswith('if') or line.startswith('while') or line.startswith('for')
 
-    def p(self, line, add_ind=0):
+    def p(self, line, add_ind=0, eat_nl=False):
         if self._nl:
-            self._out.write('\n')
+            if not eat_nl:
+                self._out.write('\n')
             self._nl = False
         ind = self._ind
         if line[-1] == ':':
@@ -971,7 +972,7 @@ from lib import SpecFamily, SpecAttrSet, SpecAttr, SpecOperation, SpecEnumSet, S
         if line and line[0] not in {';', ','}:
             line = ' ' + line
         self._ind -= 1
-        self.p('}' + line)
+        self.p('}' + line, eat_nl=True)
 
     def write_doc_line(self, doc, indent=True):
         words = doc.split()
-- 
2.40.1


  reply	other threads:[~2023-06-05 19:01 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-05 19:01 [PATCH net-next v3 0/4] tools: ynl: user space C Jakub Kicinski
2023-06-05 19:01 ` Jakub Kicinski [this message]
2023-06-06 12:42   ` [PATCH net-next v3 1/4] tools: ynl-gen: clean up stray new lines at the end of reply-less requests Willem de Bruijn
2023-06-05 19:01 ` [PATCH net-next v3 2/4] tools: ynl: user space helpers Jakub Kicinski
2023-06-06 12:40   ` Willem de Bruijn
2023-06-05 19:01 ` [PATCH net-next v3 3/4] tools: ynl: support fou and netdev in C Jakub Kicinski
2023-06-06 12:39   ` Willem de Bruijn
2023-06-05 19:01 ` [PATCH net-next v3 4/4] tools: ynl: add sample for netdev Jakub Kicinski
2023-06-06 12:39   ` Willem de Bruijn
2023-06-06 19:40 ` [PATCH net-next v3 0/4] tools: ynl: user space C 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=20230605190108.809439-2-kuba@kernel.org \
    --to=kuba@kernel.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=sdf@google.com \
    --cc=simon.horman@corigine.com \
    --cc=willemdebruijn.kernel@gmail.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).