]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
tools: ynl-gen: auto-indent else
authorJakub Kicinski <kuba@kernel.org>
Fri, 9 May 2025 15:42:12 +0000 (08:42 -0700)
committerPaolo Abeni <pabeni@redhat.com>
Tue, 13 May 2025 11:22:32 +0000 (13:22 +0200)
We auto-indent if statements (increase the indent of the subsequent
line by 1), do the same thing for else branches without a block.
There hasn't been any else branches before but we're about to add one.

Reviewed-by: Donald Hunter <donald.hunter@gmail.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Link: https://patch.msgid.link/20250509154213.1747885-3-kuba@kernel.org
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
tools/net/ynl/pyynl/ynl_gen_c.py

index 4e2ae738c0aa111485977dcd15c55ebdfb3afc5d..9a5c65966e9d58b68aba1d7ee48e27b1c8a7e3aa 100755 (executable)
@@ -1458,6 +1458,7 @@ class CodeWriter:
         if self._silent_block:
             ind += 1
         self._silent_block = line.endswith(')') and CodeWriter._is_cond(line)
+        self._silent_block |= line.strip() == 'else'
         if line[0] == '#':
             ind = 0
         if add_ind: