From nobody Sun Feb 8 05:27:50 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D905B22F169; Fri, 25 Apr 2025 07:13:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745565238; cv=none; b=jH7X5i0Hm8NnCNdxgo4LbygwfUPbtBaBG7u483jqsZU0i19XGClm0JLMsnsfU5yClXumdHllpaXYzmBUzzg+hqXjwhBnQ+wUnEm30LOfChhpVf4rFQ6pgNkzcsVWS/cIBgsQhpTBABbf2A1JrkEUcMMr8LGatkxH5fAgtQvQGwc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745565238; c=relaxed/simple; bh=8ht6CFnJ+xOrz1MUeE1fJUbi02R0O8GllLmGzGZXdI8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=V4vAylJ3J123jErK9qj4h/rRX+1/J4rh/fLsEkKVrPXEZC1eGjkVed/t5XVbIYURpiR9ezRuaUvhU8Dfb+/ntDoFuVokaD+TQyhtDaS7W1kfmpdVX976fHTmCtPw+MGsCVDENRQ8DscLVx+19mhS4ZLITrssbq5WaKtjMtDdIrY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=W4xqKXxg; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="W4xqKXxg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F75DC4CEEB; Fri, 25 Apr 2025 07:13:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745565238; bh=8ht6CFnJ+xOrz1MUeE1fJUbi02R0O8GllLmGzGZXdI8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W4xqKXxgE2kAuh2nQCFC89WDz7OrprgGEjOwuKb1cmBpBV+Jh1XurURM1yEcN4Gst kzrwSA+3t2gB7xZ0RmRP9542aEHFy0nBX+th+LOjKjCEYUtaC5WK4YL2ZXi2ywetRv Dvx5UBm3B4XnYPvokDKqyQVXW1ZQdBvLV+P7yGsum8HsbYrjYBwl0DvhUnMAuZnmm/ weIUUioXUeCnQnB+SpkLZYk+Koku4ONi99guaA84qPU76IZwZGRIZe41QT84Xk5xoI xiUQTsVXZ47DK7nOt7ONpTzErVLoqhKJ0ujUmF3XbkcUQ4Af+RwP7ZZ5E0U4vnENoG QqC4qHdf1O54Q== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1u8DFv-00000000TG0-43yQ; Fri, 25 Apr 2025 15:13:51 +0800 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , Kees Cook , linux-kernel@vger.kernel.org Subject: [PATCH 1/3] docs: Sphinx: kerneldoc: only initialize kernel-doc classes once Date: Fri, 25 Apr 2025 15:13:38 +0800 Message-ID: X-Mailer: git-send-email 2.49.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" Instead of re-creating the objects every time, initialize it just once. This allows caching previously parsed objects. Signed-off-by: Mauro Carvalho Chehab --- Documentation/sphinx/kerneldoc.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/Documentation/sphinx/kerneldoc.py b/Documentation/sphinx/kerne= ldoc.py index 27baf28fb754..b713a2c4a615 100644 --- a/Documentation/sphinx/kerneldoc.py +++ b/Documentation/sphinx/kerneldoc.py @@ -48,7 +48,8 @@ from kdoc_files import KernelFiles from kdoc_output import RestFormat =20 __version__ =3D '1.0' -use_kfiles =3D False +kfiles =3D None +logger =3D logging.getLogger('kerneldoc') =20 def cmd_str(cmd): """ @@ -86,7 +87,6 @@ class KernelDocDirective(Directive): 'functions': directives.unchanged, } has_content =3D False - logger =3D logging.getLogger('kerneldoc') verbose =3D 0 =20 parse_args =3D {} @@ -204,7 +204,7 @@ class KernelDocDirective(Directive): node =3D nodes.section() =20 try: - self.logger.verbose("calling kernel-doc '%s'" % (" ".join(cmd)= )) + logger.verbose("calling kernel-doc '%s'" % (" ".join(cmd))) =20 p =3D subprocess.Popen(cmd, stdout=3Dsubprocess.PIPE, stderr= =3Dsubprocess.PIPE) out, err =3D p.communicate() @@ -214,14 +214,14 @@ class KernelDocDirective(Directive): if p.returncode !=3D 0: sys.stderr.write(err) =20 - self.logger.warning("kernel-doc '%s' failed with return co= de %d" + logger.warning("kernel-doc '%s' failed with return code %d" % (" ".join(cmd), p.returncode)) return [nodes.error(None, nodes.paragraph(text =3D "kernel= -doc missing"))] elif env.config.kerneldoc_verbosity > 0: sys.stderr.write(err) =20 except Exception as e: # pylint: disable=3DW0703 - self.logger.warning("kernel-doc '%s' processing failed with: %= s" % + logger.warning("kernel-doc '%s' processing failed with: %s" % (" ".join(cmd), str(e))) return [nodes.error(None, nodes.paragraph(text =3D "kernel-doc= missing"))] =20 @@ -261,7 +261,7 @@ class KernelDocDirective(Directive): self.do_parse(result, node) =20 except Exception as e: # pylint: disable=3DW0703 - self.logger.warning("kernel-doc '%s' processing failed with: %= s" % + logger.warning("kernel-doc '%s' processing failed with: %s" % (cmd_str(cmd), str(e))) return [nodes.error(None, nodes.paragraph(text =3D "kernel-doc= missing"))] =20 @@ -292,11 +292,9 @@ class KernelDocDirective(Directive): return node.children =20 def run(self): - global use_kfiles + global kfiles =20 - if use_kfiles: - out_style =3D RestFormat() - kfiles =3D KernelFiles(out_style=3Dout_style, logger=3Dself.lo= gger) + if kfiles: return self.run_kdoc(kfiles) else: return self.run_cmd() @@ -306,13 +304,14 @@ class KernelDocDirective(Directive): self.state.nested_parse(result, 0, node, match_titles=3D1) =20 def setup_kfiles(app): - global use_kfiles + global kfiles =20 kerneldoc_bin =3D app.env.config.kerneldoc_bin =20 if kerneldoc_bin and kerneldoc_bin.endswith("kernel-doc.py"): print("Using Python kernel-doc") - use_kfiles =3D True + out_style =3D RestFormat() + kfiles =3D KernelFiles(out_style=3Dout_style, logger=3Dlogger) else: print(f"Using {kerneldoc_bin}") =20 --=20 2.49.0 From nobody Sun Feb 8 05:27:50 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D90DC2309BD; Fri, 25 Apr 2025 07:13:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745565238; cv=none; b=V4+d2uQH5DzeZmte/1Jepu4s7eTSk9OaUr5RH7zNU5m86XAOBbqugaHFrzwkuGg34SNlNp9xDjulSYznxQN/blr8va3yv+gTQ+FljGdsOh7UjDEtUWIUmY46Ic2yOGguXPBvTpSLucwYlHNrW7PIl+OvJGR+BTgf7/SAyPcTUJc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745565238; c=relaxed/simple; bh=e73mxh6g7pPdU5IQV9QrUPN4paBARSHM/bPj/DASL0g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FmQBO58JDNx0g4nGScgbxyp5ret1PB4Ab7R2Rw2Pz7wZ7VgxlxXeRB+JXX+4aFsHcyQbsOk3nQqc5ConN5bbIA1oBmIq0q+cUI6a2yMuhOQlsKhUWJXXYBRMHb7a2TBd9iDvniY7n1FGOZeoUpOo4jHK8ilNkkK43gHnOlrr3ek= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NpWHiEUk; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NpWHiEUk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F3B7C4CEEA; Fri, 25 Apr 2025 07:13:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745565238; bh=e73mxh6g7pPdU5IQV9QrUPN4paBARSHM/bPj/DASL0g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NpWHiEUk5utvkts/u/WFDpHgdtPTxLZb+Y85bT3vkUeOa8vYzDcxw3O4jw8TYkZcM PLtUu6WBRbhlqLfzV6vALgbVmJ+5d6WWUOW32UZzBjEFaO38wouR4h2hPk/qKXJF95 EPArfiQOrsW7R3MrLZue1sFo+rNzJuhea4lcta5wwhQ6ApTHLUkHQqq4SMAk2d8fxJ E+bX6Bm03NHdMYUCg+cJZL/ZTeWBBix4l6UlqrTkcbIeu2grPw5ej3oEFJ3aGmQvfu F2Mpcc9/kn08rMhOzT+tREFBqGjoPk1b2jLYQvuOmVDqmSDOw9Ev+vBG7Vybs1L6iQ cidAzDPxIcaeA== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1u8DFw-00000000TG3-05Ht; Fri, 25 Apr 2025 15:13:52 +0800 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , Sean Anderson , linux-kernel@vger.kernel.org Subject: [PATCH 2/3] scripts/lib/kdoc: change mode to 0644 Date: Fri, 25 Apr 2025 15:13:39 +0800 Message-ID: X-Mailer: git-send-email 2.49.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" The script library here contain just classes. Remove execution permission. Signed-off-by: Mauro Carvalho Chehab --- scripts/lib/kdoc/kdoc_output.py | 0 scripts/lib/kdoc/kdoc_parser.py | 0 scripts/lib/kdoc/kdoc_re.py | 0 3 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 =3D> 100644 scripts/lib/kdoc/kdoc_output.py mode change 100755 =3D> 100644 scripts/lib/kdoc/kdoc_parser.py mode change 100755 =3D> 100644 scripts/lib/kdoc/kdoc_re.py diff --git a/scripts/lib/kdoc/kdoc_output.py b/scripts/lib/kdoc/kdoc_output= .py old mode 100755 new mode 100644 diff --git a/scripts/lib/kdoc/kdoc_parser.py b/scripts/lib/kdoc/kdoc_parser= .py old mode 100755 new mode 100644 diff --git a/scripts/lib/kdoc/kdoc_re.py b/scripts/lib/kdoc/kdoc_re.py old mode 100755 new mode 100644 --=20 2.49.0 From nobody Sun Feb 8 05:27:50 2026 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8FBFF230D0F; Fri, 25 Apr 2025 07:13:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745565239; cv=none; b=Nd+1OU0h1qs9ziec9mN57gBO6vvqdxUfEMUrmGQnwZ28LNpYI4YEHCAuGFPXnbAqddBgUVrPRuIicnsj+Rshg2ab9jLYOphT9FgRkcLOLb2xbaiH007IR6D1n1/lGmD98gUdk5DwJDQ8yuvBbUBkVJ9iTegwGPR58IQbNmZu8rA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745565239; c=relaxed/simple; bh=W7TZX/lhi/us1KLr9toBvMbmOQHi/YzpspyRCuqCUT4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LY6gQRQUAXQFrciQxXYxuWtveaKXWlhnbEiqeMp4F69UBttZAw5Q5NYOtT3YdVno4G2MIKqXTD48ET09vp4c0vu/X3GQYiDHRkyFOarXVC5igVrXF+44sh3oaU9l3vKNu9emXzi/EBKNKlxMai6mzbpMmqohO4GeOcoXQ7m77uA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=As73L0Hq; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="As73L0Hq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F78AC4AF09; Fri, 25 Apr 2025 07:13:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745565239; bh=W7TZX/lhi/us1KLr9toBvMbmOQHi/YzpspyRCuqCUT4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=As73L0HqwFGHjFDX8cSJ+bL2PQt1yGMkMmlE8eAh3Bpz1Hhm9gLQBQbPyr3Ppxeml pP4ggq6p9/rucvucCXxPr9Pb/WSEWL+DqMfgug1G6fylgI1kMO59B592ZQsiXgj1zK OAnLSSwjGSL6+91xZquzvkeZmrKU5X32Sxtq364ggMYzUSfBdHusQYzMwAY+SQ/52u bzqHEZb0zjwVBVHCa/NFtrMxVf6X1Skp0uGLw1WMpv0NE9lG9x3r7QubIwnApn3TTO OC3aZWyI2/mxTCKi0GDOT82K6IQPvgsv468gjuVv6hrbM5gtvrLClWxtQ/bpX6dSqe sA6IDlZ/QcVkQ== Received: from mchehab by mail.kernel.org with local (Exim 4.98.2) (envelope-from ) id 1u8DFw-00000000TG6-0JJ0; Fri, 25 Apr 2025 15:13:52 +0800 From: Mauro Carvalho Chehab To: Linux Doc Mailing List , Jonathan Corbet Cc: Mauro Carvalho Chehab , Sean Anderson , linux-kernel@vger.kernel.org Subject: [PATCH 3/3] scripts/lib/kdoc/kdoc_parser.py: move kernel entry to a class Date: Fri, 25 Apr 2025 15:13:40 +0800 Message-ID: <28b456f726a022011f0ce5810dbcc26827c1403a.1745564565.git.mchehab+huawei@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: Mauro Carvalho Chehab Content-Type: text/plain; charset="utf-8" The KernelDoc class is too complex. Start optimizing it by placing the kernel-doc parser entry to a separate class. Signed-off-by: Mauro Carvalho Chehab --- scripts/lib/kdoc/kdoc_parser.py | 277 +++++++++++++++++--------------- 1 file changed, 151 insertions(+), 126 deletions(-) diff --git a/scripts/lib/kdoc/kdoc_parser.py b/scripts/lib/kdoc/kdoc_parser= .py index 461e0acb0fb7..062453eefc7a 100644 --- a/scripts/lib/kdoc/kdoc_parser.py +++ b/scripts/lib/kdoc/kdoc_parser.py @@ -12,7 +12,6 @@ Read a C language source or header FILE and extract embed= ded documentation comments """ =20 -import argparse import re from pprint import pformat =20 @@ -104,6 +103,97 @@ class state: "_ERROR", ] =20 +SECTION_DEFAULT =3D "Description" # default section + +class KernelEntry: + + def __init__(self, config, ln): + self.config =3D config + + self.contents =3D "" + self.function =3D "" + self.sectcheck =3D "" + self.struct_actual =3D "" + self.prototype =3D "" + + self.warnings =3D [] + + self.parameterlist =3D [] + self.parameterdescs =3D {} + self.parametertypes =3D {} + self.parameterdesc_start_lines =3D {} + + self.section_start_lines =3D {} + self.sectionlist =3D [] + self.sections =3D {} + + self.anon_struct_union =3D False + + self.leading_space =3D None + + # State flags + self.brcount =3D 0 + + self.in_doc_sect =3D False + self.declaration_start_line =3D ln + 1 + + # TODO: rename to emit_message after removal of kernel-doc.pl + def emit_msg(self, log_msg, warning=3DTrue): + """Emit a message""" + + if not warning: + self.config.log.info(log_msg) + return + + # Delegate warning output to output logic, as this way it + # will report warnings/info only for symbols that are output + + self.warnings.append(log_msg) + return + + def dump_section(self, start_new=3DTrue): + """ + Dumps section contents to arrays/hashes intended for that purpose. + """ + + name =3D self.section + contents =3D self.contents + + if type_param.match(name): + name =3D type_param.group(1) + + self.parameterdescs[name] =3D contents + self.parameterdesc_start_lines[name] =3D self.new_start_line + + self.sectcheck +=3D name + " " + self.new_start_line =3D 0 + + elif name =3D=3D "@...": + name =3D "..." + self.parameterdescs[name] =3D contents + self.sectcheck +=3D name + " " + self.parameterdesc_start_lines[name] =3D self.new_start_line + self.new_start_line =3D 0 + + else: + if name in self.sections and self.sections[name] !=3D "": + # Only warn on user-specified duplicate section names + if name !=3D SECTION_DEFAULT: + self.emit_msg(self.new_start_line, + f"duplicate section name '{name}'\n") + self.sections[name] +=3D contents + else: + self.sections[name] =3D contents + self.sectionlist.append(name) + self.section_start_lines[name] =3D self.new_start_line + self.new_start_line =3D 0 + +# self.config.log.debug("Section: %s : %s", name, pformat(vars(self= ))) + + if start_new: + self.section =3D SECTION_DEFAULT + self.contents =3D "" + =20 class KernelDoc: """ @@ -113,7 +203,6 @@ class KernelDoc: =20 # Section names =20 - section_default =3D "Description" # default section section_intro =3D "Introduction" section_context =3D "Context" section_return =3D "Return" @@ -136,67 +225,27 @@ class KernelDoc: # Place all potential outputs into an array self.entries =3D [] =20 - # TODO: rename to emit_message after removal of kernel-doc.pl - def emit_warning(self, ln, msg, warning=3DTrue): + def emit_msg(self, ln, msg, warning=3DTrue): """Emit a message""" =20 log_msg =3D f"{self.fname}:{ln} {msg}" =20 - if not warning: + if self.entry: + self.entry.emit_msg(log_msg, warning) + return + + if warning: + self.config.log.warning(log_msg) + else: self.config.log.info(log_msg) - return - - if self.entry: - # Delegate warning output to output logic, as this way it - # will report warnings/info only for symbols that are output - - self.entry.warnings.append(log_msg) - return - - self.config.log.warning(log_msg) =20 def dump_section(self, start_new=3DTrue): """ Dumps section contents to arrays/hashes intended for that purpose. """ =20 - name =3D self.entry.section - contents =3D self.entry.contents - - if type_param.match(name): - name =3D type_param.group(1) - - self.entry.parameterdescs[name] =3D contents - self.entry.parameterdesc_start_lines[name] =3D self.entry.new_= start_line - - self.entry.sectcheck +=3D name + " " - self.entry.new_start_line =3D 0 - - elif name =3D=3D "@...": - name =3D "..." - self.entry.parameterdescs[name] =3D contents - self.entry.sectcheck +=3D name + " " - self.entry.parameterdesc_start_lines[name] =3D self.entry.new_= start_line - self.entry.new_start_line =3D 0 - - else: - if name in self.entry.sections and self.entry.sections[name] != =3D "": - # Only warn on user-specified duplicate section names - if name !=3D self.section_default: - self.emit_warning(self.entry.new_start_line, - f"duplicate section name '{name}'\n") - self.entry.sections[name] +=3D contents - else: - self.entry.sections[name] =3D contents - self.entry.sectionlist.append(name) - self.entry.section_start_lines[name] =3D self.entry.new_st= art_line - self.entry.new_start_line =3D 0 - -# self.config.log.debug("Section: %s : %s", name, pformat(vars(self= .entry))) - - if start_new: - self.entry.section =3D self.section_default - self.entry.contents =3D "" + if self.entry: + self.entry.dump_section(start_new) =20 # TODO: rename it to store_declaration after removal of kernel-doc.pl def output_declaration(self, dtype, name, **args): @@ -241,36 +290,11 @@ class KernelDoc: variables used by the state machine. """ =20 - self.entry =3D argparse.Namespace - - self.entry.contents =3D "" - self.entry.function =3D "" - self.entry.sectcheck =3D "" - self.entry.struct_actual =3D "" - self.entry.prototype =3D "" - - self.entry.warnings =3D [] - - self.entry.parameterlist =3D [] - self.entry.parameterdescs =3D {} - self.entry.parametertypes =3D {} - self.entry.parameterdesc_start_lines =3D {} - - self.entry.section_start_lines =3D {} - self.entry.sectionlist =3D [] - self.entry.sections =3D {} - - self.entry.anon_struct_union =3D False - - self.entry.leading_space =3D None + self.entry =3D KernelEntry(self.config, ln) =20 # State flags self.state =3D state.NORMAL self.inline_doc_state =3D state.INLINE_NA - self.entry.brcount =3D 0 - - self.entry.in_doc_sect =3D False - self.entry.declaration_start_line =3D ln + 1 =20 def push_parameter(self, ln, decl_type, param, dtype, org_arg, declaration_name): @@ -328,8 +352,8 @@ class KernelDoc: else: dname =3D f"{decl_type} member" =20 - self.emit_warning(ln, - f"{dname} '{param}' not described in '{d= eclaration_name}'") + self.emit_msg(ln, + f"{dname} '{param}' not described in '{decla= ration_name}'") =20 # Strip spaces from param so that it is one continuous string on # parameterlist. This fixes a problem where check_sections() @@ -393,7 +417,7 @@ class KernelDoc: if r.match(arg): param =3D r.group(1) else: - self.emit_warning(ln, f"Invalid param: {arg}") + self.emit_msg(ln, f"Invalid param: {arg}") param =3D arg =20 dtype =3D KernRe(r'([^\(]+\(\*?)\s*' + re.escape(param)).s= ub(r'\1', arg) @@ -409,7 +433,7 @@ class KernelDoc: if r.match(arg): param =3D r.group(1) else: - self.emit_warning(ln, f"Invalid param: {arg}") + self.emit_msg(ln, f"Invalid param: {arg}") param =3D arg =20 dtype =3D KernRe(r'([^\(]+\(\*?)\s*' + re.escape(param)).s= ub(r'\1', arg) @@ -442,7 +466,7 @@ class KernelDoc: if KernRe(r'^(\*+)\s*(.*)').match(param): r =3D KernRe(r'^(\*+)\s*(.*)') if not r.match(param): - self.emit_warning(ln, f"Invalid param: {param}= ") + self.emit_msg(ln, f"Invalid param: {param}") continue =20 param =3D r.group(1) @@ -455,7 +479,7 @@ class KernelDoc: elif KernRe(r'(.*?):(\w+)').search(param): r =3D KernRe(r'(.*?):(\w+)') if not r.match(param): - self.emit_warning(ln, f"Invalid param: {param}= ") + self.emit_msg(ln, f"Invalid param: {param}") continue =20 if dtype !=3D "": # Skip unnamed bit-fields @@ -503,8 +527,8 @@ class KernelDoc: else: dname =3D f"{decl_type} member" =20 - self.emit_warning(ln, - f"Excess {dname} '{sects[sx]}' descripti= on in '{decl_name}'") + self.emit_msg(ln, + f"Excess {dname} '{sects[sx]}' description i= n '{decl_name}'") =20 def check_return_section(self, ln, declaration_name, return_type): """ @@ -521,8 +545,8 @@ class KernelDoc: return =20 if not self.entry.sections.get("Return", None): - self.emit_warning(ln, - f"No description found for return value of '= {declaration_name}'") + self.emit_msg(ln, + f"No description found for return value of '{dec= laration_name}'") =20 def dump_struct(self, ln, proto): """ @@ -561,12 +585,12 @@ class KernelDoc: members =3D r.group(2) =20 if not members: - self.emit_warning(ln, f"{proto} error: Cannot parse struct or = union!") + self.emit_msg(ln, f"{proto} error: Cannot parse struct or unio= n!") return =20 if self.entry.identifier !=3D declaration_name: - self.emit_warning(ln, - f"expecting prototype for {decl_type} {self.= entry.identifier}. Prototype was for {decl_type} {declaration_name} instead= \n") + self.emit_msg(ln, + f"expecting prototype for {decl_type} {self.entr= y.identifier}. Prototype was for {decl_type} {declaration_name} instead\n") return =20 args_pattern =3D r'([^,)]+)' @@ -835,16 +859,16 @@ class KernelDoc: members =3D r.group(2).rstrip() =20 if not members: - self.emit_warning(ln, f"{proto}: error: Cannot parse enum!") + self.emit_msg(ln, f"{proto}: error: Cannot parse enum!") return =20 if self.entry.identifier !=3D declaration_name: if self.entry.identifier =3D=3D "": - self.emit_warning(ln, - f"{proto}: wrong kernel-doc identifier o= n prototype") + self.emit_msg(ln, + f"{proto}: wrong kernel-doc identifier on pr= ototype") else: - self.emit_warning(ln, - f"expecting prototype for enum {self.ent= ry.identifier}. Prototype was for enum {declaration_name} instead") + self.emit_msg(ln, + f"expecting prototype for enum {self.entry.i= dentifier}. Prototype was for enum {declaration_name} instead") return =20 if not declaration_name: @@ -861,14 +885,14 @@ class KernelDoc: self.entry.parameterlist.append(arg) if arg not in self.entry.parameterdescs: self.entry.parameterdescs[arg] =3D self.undescribed - self.emit_warning(ln, - f"Enum value '{arg}' not described in en= um '{declaration_name}'") + self.emit_msg(ln, + f"Enum value '{arg}' not described in enum '= {declaration_name}'") member_set.add(arg) =20 for k in self.entry.parameterdescs: if k not in member_set: - self.emit_warning(ln, - f"Excess enum value '%{k}' description i= n '{declaration_name}'") + self.emit_msg(ln, + f"Excess enum value '%{k}' description in '{= declaration_name}'") =20 self.output_declaration('enum', declaration_name, enum=3Ddeclaration_name, @@ -1023,13 +1047,13 @@ class KernelDoc: found =3D True break if not found: - self.emit_warning(ln, - f"cannot understand function prototype: '{pr= ototype}'") + self.emit_msg(ln, + f"cannot understand function prototype: '{protot= ype}'") return =20 if self.entry.identifier !=3D declaration_name: - self.emit_warning(ln, - f"expecting prototype for {self.entry.identi= fier}(). Prototype was for {declaration_name}() instead") + self.emit_msg(ln, + f"expecting prototype for {self.entry.identifier= }(). Prototype was for {declaration_name}() instead") return =20 prms =3D " ".join(self.entry.parameterlist) @@ -1092,8 +1116,8 @@ class KernelDoc: args =3D r.group(3) =20 if self.entry.identifier !=3D declaration_name: - self.emit_warning(ln, - f"expecting prototype for typedef {self.= entry.identifier}. Prototype was for typedef {declaration_name} instead\n") + self.emit_msg(ln, + f"expecting prototype for typedef {self.entr= y.identifier}. Prototype was for typedef {declaration_name} instead\n") return =20 decl_type =3D 'function' @@ -1124,7 +1148,8 @@ class KernelDoc: declaration_name =3D r.group(1) =20 if self.entry.identifier !=3D declaration_name: - self.emit_warning(ln, f"expecting prototype for typedef {s= elf.entry.identifier}. Prototype was for typedef {declaration_name} instead= \n") + self.emit_msg(ln, + f"expecting prototype for typedef {self.entr= y.identifier}. Prototype was for typedef {declaration_name} instead\n") return =20 self.output_declaration('typedef', declaration_name, @@ -1135,7 +1160,7 @@ class KernelDoc: purpose=3Dself.entry.declaration_purpo= se) return =20 - self.emit_warning(ln, "error: Cannot parse typedef!") + self.emit_msg(ln, "error: Cannot parse typedef!") =20 @staticmethod def process_export(function_set, line): @@ -1232,7 +1257,7 @@ class KernelDoc: self.state =3D state.BODY =20 # if there's no @param blocks need to set up default section h= ere - self.entry.section =3D self.section_default + self.entry.section =3D SECTION_DEFAULT self.entry.new_start_line =3D ln + 1 =20 r =3D KernRe("[-:](.*)") @@ -1248,28 +1273,28 @@ class KernelDoc: self.entry.declaration_purpose =3D "" =20 if not self.entry.is_kernel_comment: - self.emit_warning(ln, - f"This comment starts with '/**', but is= n't a kernel-doc comment. Refer Documentation/doc-guide/kernel-doc.rst\n{li= ne}") + self.emit_msg(ln, + f"This comment starts with '/**', but isn't = a kernel-doc comment. Refer Documentation/doc-guide/kernel-doc.rst\n{line}") self.state =3D state.NORMAL =20 if not self.entry.declaration_purpose and self.config.wshort_d= esc: - self.emit_warning(ln, - f"missing initial short description on l= ine:\n{line}") + self.emit_msg(ln, + f"missing initial short description on line:= \n{line}") =20 if not self.entry.identifier and self.entry.decl_type !=3D "en= um": - self.emit_warning(ln, - f"wrong kernel-doc identifier on line:\n= {line}") + self.emit_msg(ln, + f"wrong kernel-doc identifier on line:\n{lin= e}") self.state =3D state.NORMAL =20 if self.config.verbose: - self.emit_warning(ln, - f"Scanning doc for {self.entry.decl_type= } {self.entry.identifier}", + self.emit_msg(ln, + f"Scanning doc for {self.entry.decl_type} {s= elf.entry.identifier}", warning=3DFalse) =20 return =20 # Failed to find an identifier. Emit a warning - self.emit_warning(ln, f"Cannot find identifier on line:\n{line}") + self.emit_msg(ln, f"Cannot find identifier on line:\n{line}") =20 def process_body(self, ln, line): """ @@ -1280,7 +1305,7 @@ class KernelDoc: r =3D KernRe(r"\s*\*\s?\S") if r.match(line): self.dump_section() - self.entry.section =3D self.section_default + self.entry.section =3D SECTION_DEFAULT self.entry.new_start_line =3D ln self.entry.contents =3D "" =20 @@ -1325,7 +1350,7 @@ class KernelDoc: # Look for doc_com + + doc_end: r =3D KernRe(r'\s*\*\s*[a-zA-Z_0-9:\.]+\*/') if r.match(line): - self.emit_warning(ln, f"suspicious ending line: {line}") + self.emit_msg(ln, f"suspicious ending line: {line}") =20 self.entry.prototype =3D "" self.entry.new_start_line =3D ln + 1 @@ -1343,7 +1368,7 @@ class KernelDoc: self.entry.new_start_line =3D ln self.state =3D state.BODY else: - if self.entry.section !=3D self.section_default: + if self.entry.section !=3D SECTION_DEFAULT: self.state =3D state.BODY_WITH_BLANK_LINE else: self.state =3D state.BODY @@ -1388,7 +1413,7 @@ class KernelDoc: return =20 # Unknown line, ignore - self.emit_warning(ln, f"bad line: {line}") + self.emit_msg(ln, f"bad line: {line}") =20 def process_inline(self, ln, line): """STATE_INLINE: docbook comments within a prototype.""" @@ -1421,8 +1446,8 @@ class KernelDoc: self.entry.contents =3D "" =20 elif self.inline_doc_state =3D=3D state.INLINE_NAME: - self.emit_warning(ln, - f"Incorrect use of kernel-doc format: {l= ine}") + self.emit_msg(ln, + f"Incorrect use of kernel-doc format: {line}= ") =20 self.inline_doc_state =3D state.INLINE_ERROR =20 @@ -1494,8 +1519,8 @@ class KernelDoc: tracepointargs =3D r.group(1) =20 if not tracepointname or not tracepointargs: - self.emit_warning(ln, - f"Unrecognized tracepoint format:\n{proto}\n= ") + self.emit_msg(ln, + f"Unrecognized tracepoint format:\n{proto}\n") else: proto =3D f"static inline void trace_{tracepointname}({tracepo= intargs})" self.entry.identifier =3D f"trace_{self.entry.identifier}" --=20 2.49.0