summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJakub Kicinski <kuba@kernel.org>2023-06-05 22:01:05 +0300
committerJakub Kicinski <kuba@kernel.org>2023-06-06 22:31:31 +0300
commita99bfdf647953f8ac4ae71f373113e8ac194f1c0 (patch)
tree7a0b6b8d8e440f365dc4f66f9ba0371db39fd2e7 /tools
parentae91f7e436f8b631c47e244b892ecac62a4d9430 (diff)
downloadlinux-a99bfdf647953f8ac4ae71f373113e8ac194f1c0.tar.xz
tools: ynl-gen: clean up stray new lines at the end of reply-less requests
Do not print empty lines before closing brackets. Reviewed-by: Willem de Bruijn <willemb@google.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/net/ynl/ynl-gen-c.py7
1 files 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 @@ class CodeWriter:
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 @@ class CodeWriter:
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()