[PATCH 3/7] docs: kdoc: remove the brcount floor in process_proto_type()

Jonathan Corbet posted 7 patches 3 months, 1 week ago
There is a newer version of this series
[PATCH 3/7] docs: kdoc: remove the brcount floor in process_proto_type()
Posted by Jonathan Corbet 3 months, 1 week ago
Putting the floor under brcount does not change the output in any way, just
remove it.

Change the termination test from ==0 to <=0 to prevent infinite loops in
case somebody does something truly wacko in the code.

Signed-off-by: Jonathan Corbet <corbet@lwn.net>
---
 scripts/lib/kdoc/kdoc_parser.py | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/scripts/lib/kdoc/kdoc_parser.py b/scripts/lib/kdoc/kdoc_parser.py
index d9ff2d066160..935f2a3c4b47 100644
--- a/scripts/lib/kdoc/kdoc_parser.py
+++ b/scripts/lib/kdoc/kdoc_parser.py
@@ -1609,9 +1609,7 @@ class KernelDoc:
                 self.entry.brcount += r.group(2).count('{')
                 self.entry.brcount -= r.group(2).count('}')
 
-                self.entry.brcount = max(self.entry.brcount, 0)
-
-                if r.group(2) == ';' and self.entry.brcount == 0:
+                if r.group(2) == ';' and self.entry.brcount <= 0:
                     self.dump_declaration(ln, self.entry.prototype)
                     self.reset_state(ln)
                     break
-- 
2.49.0
Re: [PATCH 3/7] docs: kdoc: remove the brcount floor in process_proto_type()
Posted by Mauro Carvalho Chehab 3 months ago
Em Tue,  1 Jul 2025 14:57:26 -0600
Jonathan Corbet <corbet@lwn.net> escreveu:

> Putting the floor under brcount does not change the output in any way, just
> remove it.
> 
> Change the termination test from ==0 to <=0 to prevent infinite loops in
> case somebody does something truly wacko in the code.
> 
> Signed-off-by: Jonathan Corbet <corbet@lwn.net>

Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

> ---
>  scripts/lib/kdoc/kdoc_parser.py | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/scripts/lib/kdoc/kdoc_parser.py b/scripts/lib/kdoc/kdoc_parser.py
> index d9ff2d066160..935f2a3c4b47 100644
> --- a/scripts/lib/kdoc/kdoc_parser.py
> +++ b/scripts/lib/kdoc/kdoc_parser.py
> @@ -1609,9 +1609,7 @@ class KernelDoc:
>                  self.entry.brcount += r.group(2).count('{')
>                  self.entry.brcount -= r.group(2).count('}')
>  
> -                self.entry.brcount = max(self.entry.brcount, 0)
> -
> -                if r.group(2) == ';' and self.entry.brcount == 0:
> +                if r.group(2) == ';' and self.entry.brcount <= 0:
>                      self.dump_declaration(ln, self.entry.prototype)
>                      self.reset_state(ln)
>                      break