Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'mauro' into docs-mw

A combination of Mauro's -Werror work and my long-belated kernel-doc move.

+120 -117
-4
Documentation/conf.py
··· 582 582 ("kernel-documentation", "Kernel", "Kernel", "J. Random Bozo"), 583 583 ] 584 584 585 - # kernel-doc extension configuration for running Sphinx directly (e.g. by Read 586 - # the Docs). In a normal build, these are supplied from the Makefile via command 587 - # line arguments. 588 - kerneldoc_bin = "../scripts/kernel-doc.py" 589 585 kerneldoc_srctree = ".." 590 586 591 587 def setup(app):
+4 -4
Documentation/doc-guide/kernel-doc.rst
··· 54 54 output generation may be used to verify proper formatting of the 55 55 documentation comments. For example:: 56 56 57 - scripts/kernel-doc -v -none drivers/foo/bar.c 57 + tools/docs/kernel-doc -v -none drivers/foo/bar.c 58 58 59 59 The documentation format of ``.c`` files is also verified by the kernel build 60 60 when it is requested to perform extra gcc checks:: ··· 365 365 left parenthesis ('(') for function-like macros or not followed by one 366 366 for object-like macros. 367 367 368 - Function-like macros are handled like functions by ``scripts/kernel-doc``. 368 + Function-like macros are handled like functions by ``tools/docs/kernel-doc``. 369 369 They may have a parameter list. Object-like macros have do not have a 370 370 parameter list. 371 371 ··· 596 596 597 597 The kernel-doc extension is included in the kernel source tree, at 598 598 ``Documentation/sphinx/kerneldoc.py``. Internally, it uses the 599 - ``scripts/kernel-doc`` script to extract the documentation comments from the 600 - source. 599 + ``tools/docs/kernel-doc`` script to extract the documentation comments from 600 + the source. 601 601 602 602 .. _kernel_doc: 603 603
+1 -1
Documentation/kbuild/kbuild.rst
··· 180 180 KDOCFLAGS 181 181 --------- 182 182 Specify extra (warning/error) flags for kernel-doc checks during the build, 183 - see scripts/kernel-doc for which flags are supported. Note that this doesn't 183 + see tools/docs/kernel-doc for which flags are supported. Note that this doesn't 184 184 (currently) apply to documentation builds. 185 185 186 186 ARCH
+1 -1
Documentation/process/coding-style.rst
··· 614 614 615 615 When commenting the kernel API functions, please use the kernel-doc format. 616 616 See the files at :ref:`Documentation/doc-guide/ <doc_guide>` and 617 - ``scripts/kernel-doc`` for details. Note that the danger of over-commenting 617 + ``tools/docs/kernel-doc`` for details. Note that the danger of over-commenting 618 618 applies to kernel-doc comments all the same. Do not add boilerplate 619 619 kernel-doc which simply reiterates what's obvious from the signature 620 620 of the function.
+11 -49
Documentation/sphinx/kerneldoc.py
··· 47 47 from kdoc.kdoc_files import KernelFiles 48 48 from kdoc.kdoc_output import RestFormat 49 49 50 + # Used when verbose is active to show how to reproduce kernel-doc 51 + # issues via command line 52 + kerneldoc_bin = "tools/docs/kernel-doc" 53 + 50 54 __version__ = '1.0' 51 55 kfiles = None 52 56 logger = logging.getLogger(__name__) ··· 99 95 def handle_args(self): 100 96 101 97 env = self.state.document.settings.env 102 - cmd = [env.config.kerneldoc_bin, '-rst', '-enable-lineno'] 98 + cmd = [kerneldoc_bin, '-rst', '-enable-lineno'] 103 99 104 100 filename = env.config.kerneldoc_srctree + '/' + self.arguments[0] 105 101 ··· 194 190 195 191 return cmd 196 192 197 - def run_cmd(self, cmd): 198 - """ 199 - Execute an external kernel-doc command. 200 - """ 201 - 202 - env = self.state.document.settings.env 203 - node = nodes.section() 204 - 205 - p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) 206 - out, err = p.communicate() 207 - 208 - out, err = codecs.decode(out, 'utf-8'), codecs.decode(err, 'utf-8') 209 - 210 - if p.returncode != 0: 211 - sys.stderr.write(err) 212 - 213 - logger.warning("kernel-doc '%s' failed with return code %d" 214 - % (" ".join(cmd), p.returncode)) 215 - return [nodes.error(None, nodes.paragraph(text = "kernel-doc missing"))] 216 - elif env.config.kerneldoc_verbosity > 0: 217 - sys.stderr.write(err) 218 - 219 - filenames = self.parse_args["file_list"] 220 - for filename in filenames: 221 - self.parse_msg(filename, node, out, cmd) 222 - 223 - return node.children 224 - 225 - def parse_msg(self, filename, node, out, cmd): 193 + def parse_msg(self, filename, node, out): 226 194 """ 227 195 Handles a kernel-doc output for a given file 228 196 """ ··· 220 244 221 245 self.do_parse(result, node) 222 246 223 - def run_kdoc(self, cmd, kfiles): 247 + def run_kdoc(self, kfiles): 224 248 """ 225 249 Execute kernel-doc classes directly instead of running as a separate 226 250 command. ··· 234 258 filenames = self.parse_args["file_list"] 235 259 236 260 for filename, out in kfiles.msg(**self.msg_args, filenames=filenames): 237 - self.parse_msg(filename, node, out, cmd) 261 + self.parse_msg(filename, node, out) 238 262 239 263 return node.children 240 264 241 265 def run(self): 242 - global kfiles 243 - 244 266 cmd = self.handle_args() 245 267 if self.verbose >= 1: 246 268 logger.info(cmd_str(cmd)) 247 269 248 270 try: 249 - if kfiles: 250 - return self.run_kdoc(cmd, kfiles) 251 - else: 252 - return self.run_cmd(cmd) 253 - 271 + return self.run_kdoc(kfiles) 254 272 except Exception as e: # pylint: disable=W0703 255 273 logger.warning("kernel-doc '%s' processing failed with: %s" % 256 274 (cmd_str(cmd), pformat(e))) ··· 256 286 257 287 def setup_kfiles(app): 258 288 global kfiles 259 - 260 - kerneldoc_bin = app.env.config.kerneldoc_bin 261 - 262 - if kerneldoc_bin and kerneldoc_bin.endswith("kernel-doc.py"): 263 - print("Using Python kernel-doc") 264 - out_style = RestFormat() 265 - kfiles = KernelFiles(out_style=out_style, logger=logger) 266 - else: 267 - print(f"Using {kerneldoc_bin}") 289 + out_style = RestFormat() 290 + kfiles = KernelFiles(out_style=out_style, logger=logger) 268 291 269 292 270 293 def setup(app): 271 - app.add_config_value('kerneldoc_bin', None, 'env') 272 294 app.add_config_value('kerneldoc_srctree', None, 'env') 273 295 app.add_config_value('kerneldoc_verbosity', 1, 'env') 274 296
+4 -4
Documentation/translations/it_IT/doc-guide/kernel-doc.rst
··· 80 80 eseguire il programma ``kernel-doc`` con un livello di verbosità alto e senza 81 81 che questo produca alcuna documentazione. Per esempio:: 82 82 83 - scripts/kernel-doc -v -none drivers/foo/bar.c 83 + tools/docs/kernel-doc -v -none drivers/foo/bar.c 84 84 85 85 Il formato della documentazione è verificato della procedura di generazione 86 86 del kernel quando viene richiesto di effettuare dei controlli extra con GCC:: ··· 378 378 immediatamente seguito da una parentesi sinistra ('(') mentre in quelle simili a 379 379 oggetti no. 380 380 381 - Le macro simili a funzioni sono gestite come funzioni da ``scripts/kernel-doc``. 381 + Le macro simili a funzioni sono gestite come funzioni da ``tools/docs/kernel-doc``. 382 382 Possono avere un elenco di parametri. Le macro simili a oggetti non hanno un 383 383 elenco di parametri. 384 384 ··· 595 595 596 596 L'estensione kernel-doc fa parte dei sorgenti del kernel, la si può trovare 597 597 in ``Documentation/sphinx/kerneldoc.py``. Internamente, viene utilizzato 598 - lo script ``scripts/kernel-doc`` per estrarre i commenti di documentazione 598 + lo script ``tools/docs/kernel-doc`` per estrarre i commenti di documentazione 599 599 dai file sorgenti. 600 600 601 601 Come utilizzare kernel-doc per generare pagine man ··· 604 604 Se volete utilizzare kernel-doc solo per generare delle pagine man, potete 605 605 farlo direttamente dai sorgenti del kernel:: 606 606 607 - $ scripts/kernel-doc -man $(git grep -l '/\*\*' -- :^Documentation :^tools) | scripts/split-man.pl /tmp/man 607 + $ tools/docs/kernel-doc -man $(git grep -l '/\*\*' -- :^Documentation :^tools) | scripts/split-man.pl /tmp/man
+1 -1
Documentation/translations/sp_SP/process/coding-style.rst
··· 633 633 634 634 Al comentar las funciones de la API del kernel, utilice el formato 635 635 kernel-doc. Consulte los archivos en :ref:`Documentation/doc-guide/ <doc_guide>` 636 - y ``scripts/kernel-doc`` para más detalles. 636 + y ``tools/docs/kernel-doc`` para más detalles. 637 637 638 638 El estilo preferido para comentarios largos (de varias líneas) es: 639 639
+5 -5
Documentation/translations/zh_CN/doc-guide/kernel-doc.rst
··· 43 43 用详细模式和不生成实际输出来运行 ``kernel-doc`` 工具,可以验证文档注释的格式 44 44 是否正确。例如:: 45 45 46 - scripts/kernel-doc -v -none drivers/foo/bar.c 46 + tools/docs/kernel-doc -v -none drivers/foo/bar.c 47 47 48 48 当请求执行额外的gcc检查时,内核构建将验证文档格式:: 49 49 ··· 473 473 如果没有选项,kernel-doc指令将包含源文件中的所有文档注释。 474 474 475 475 kernel-doc扩展包含在内核源代码树中,位于 ``Documentation/sphinx/kerneldoc.py`` 。 476 - 在内部,它使用 ``scripts/kernel-doc`` 脚本从源代码中提取文档注释。 476 + 在内部,它使用 ``tools/docs/kernel-doc`` 脚本从源代码中提取文档注释。 477 477 478 478 .. _kernel_doc_zh: 479 479 ··· 482 482 483 483 如果您只想使用kernel-doc生成手册页,可以从内核git树这样做:: 484 484 485 - $ scripts/kernel-doc -man \ 485 + $ tools/docs/kernel-doc -man \ 486 486 $(git grep -l '/\*\*' -- :^Documentation :^tools) \ 487 487 | scripts/split-man.pl /tmp/man 488 488 489 489 一些旧版本的git不支持路径排除语法的某些变体。 490 490 以下命令之一可能适用于这些版本:: 491 491 492 - $ scripts/kernel-doc -man \ 492 + $ tools/docs/kernel-doc -man \ 493 493 $(git grep -l '/\*\*' -- . ':!Documentation' ':!tools') \ 494 494 | scripts/split-man.pl /tmp/man 495 495 496 - $ scripts/kernel-doc -man \ 496 + $ tools/docs/kernel-doc -man \ 497 497 $(git grep -l '/\*\*' -- . ":(exclude)Documentation" ":(exclude)tools") \ 498 498 | scripts/split-man.pl /tmp/man 499 499
+1 -1
Documentation/translations/zh_CN/kbuild/kbuild.rst
··· 174 174 KDOCFLAGS 175 175 --------- 176 176 指定在构建过程中用于 kernel-doc 检查的额外(警告/错误)标志,查看 177 - scripts/kernel-doc 了解支持的标志。请注意,这目前不适用于文档构建。 177 + tools/docs/kernel-doc 了解支持的标志。请注意,这目前不适用于文档构建。 178 178 179 179 ARCH 180 180 ----
+1 -1
Documentation/translations/zh_CN/process/coding-style.rst
··· 545 545 也可以加上它做这些事情的原因。 546 546 547 547 当注释内核 API 函数时,请使用 kernel-doc 格式。详见 548 - Documentation/translations/zh_CN/doc-guide/index.rst 和 scripts/kernel-doc 。 548 + Documentation/translations/zh_CN/doc-guide/index.rst 和 tools/docs/kernel-doc 。 549 549 550 550 长 (多行) 注释的首选风格是: 551 551
+1 -1
Documentation/translations/zh_TW/process/coding-style.rst
··· 548 548 也可以加上它做這些事情的原因。 549 549 550 550 當註釋內核 API 函數時,請使用 kernel-doc 格式。詳見 551 - Documentation/translations/zh_CN/doc-guide/index.rst 和 scripts/kernel-doc 。 551 + Documentation/translations/zh_CN/doc-guide/index.rst 和 tools/docs/kernel-doc 。 552 552 553 553 長 (多行) 註釋的首選風格是: 554 554
-2
MAINTAINERS
··· 7523 7523 P: Documentation/doc-guide/maintainer-profile.rst 7524 7524 T: git git://git.lwn.net/linux.git docs-next 7525 7525 F: Documentation/ 7526 - F: scripts/kernel-doc* 7527 7526 F: tools/lib/python/* 7528 7527 F: tools/docs/ 7529 7528 F: tools/net/ynl/pyynl/lib/doc_generator.py ··· 7560 7561 L: linux-doc@vger.kernel.org 7561 7562 S: Maintained 7562 7563 F: Documentation/sphinx/ 7563 - F: scripts/kernel-doc* 7564 7564 F: tools/lib/python/* 7565 7565 F: tools/docs/ 7566 7566
+1 -1
Makefile
··· 460 460 461 461 # the KERNELDOC macro needs to be exported, as scripts/Makefile.build 462 462 # has a logic to call it 463 - KERNELDOC = $(srctree)/scripts/kernel-doc.py 463 + KERNELDOC = $(srctree)/tools/docs/kernel-doc 464 464 export KERNELDOC 465 465 466 466 KBUILD_USERHOSTCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \
+1 -1
drivers/gpu/drm/i915/Makefile
··· 443 443 444 444 quiet_cmd_hdrtest = HDRTEST $(patsubst %.hdrtest,%.h,$@) 445 445 cmd_hdrtest = $(CC) $(filter-out $(CFLAGS_GCOV), $(c_flags)) -S -o /dev/null -x c /dev/null -include $<; \ 446 - $(srctree)/scripts/kernel-doc -none -Werror $<; touch $@ 446 + $(KERNELDOC) -none -Werror $<; touch $@ 447 447 448 448 $(obj)/%.hdrtest: $(src)/%.h FORCE 449 449 $(call if_changed_dep,hdrtest)
+58 -31
scripts/kernel-doc.py tools/docs/kernel-doc
··· 3 3 # Copyright(c) 2025: Mauro Carvalho Chehab <mchehab@kernel.org>. 4 4 # 5 5 # pylint: disable=C0103,R0912,R0914,R0915 6 - 6 + # 7 7 # NOTE: While kernel-doc requires at least version 3.6 to run, the 8 8 # command line should work with Python 3.2+ (tested with 3.4). 9 9 # The rationale is that it shall fail gracefully during Kernel 10 10 # compilation with older Kernel versions. Due to that: 11 11 # - encoding line is needed here; 12 - # - no f-strings can be used on this file. 13 - # - the libraries that require newer versions can only be included 14 - # after Python version is checked. 15 - 12 + # - f-strings cannot be used in this file. 13 + # - libraries that require newer versions can only be included 14 + # after the Python version has been checked. 15 + # 16 16 # Converted from the kernel-doc script originally written in Perl 17 17 # under GPLv2, copyrighted since 1998 by the following authors: 18 18 # ··· 88 88 # Yujie Liu <yujie.liu@intel.com> 89 89 90 90 """ 91 - kernel_doc 92 - ========== 93 - 94 - Print formatted kernel documentation to stdout 91 + Print formatted kernel documentation to stdout. 95 92 96 93 Read C language source or header FILEs, extract embedded 97 94 documentation comments, and print formatted documentation 98 95 to standard output. 99 96 100 - The documentation comments are identified by the "/**" 97 + The documentation comments are identified by the ``/**`` 101 98 opening comment mark. 102 99 103 100 See Documentation/doc-guide/kernel-doc.rst for the ··· 108 111 109 112 # Import Python modules 110 113 111 - LIB_DIR = "../tools/lib/python" 114 + LIB_DIR = "../lib/python" 112 115 SRC_DIR = os.path.dirname(os.path.realpath(__file__)) 113 116 114 117 sys.path.insert(0, os.path.join(SRC_DIR, LIB_DIR)) 118 + 119 + WERROR_RETURN_CODE = 3 115 120 116 121 DESC = """ 117 122 Read C language source or header FILEs, extract embedded documentation comments, ··· 131 132 """ 132 133 133 134 EXPORT_DESC = """ 134 - Only output documentation for the symbols that have been 135 + Only output documentation for symbols that have been 135 136 exported using EXPORT_SYMBOL() and related macros in any input 136 137 FILE or -export-file FILE. 137 138 """ 138 139 139 140 INTERNAL_DESC = """ 140 - Only output documentation for the symbols that have NOT been 141 + Only output documentation for symbols that have NOT been 141 142 exported using EXPORT_SYMBOL() and related macros in any input 142 143 FILE or -export-file FILE. 143 144 """ ··· 160 161 """ 161 162 162 163 WARN_CONTENTS_BEFORE_SECTIONS_DESC = """ 163 - Warns if there are contents before sections (deprecated). 164 + Warn if there are contents before sections (deprecated). 164 165 165 166 This option is kept just for backward-compatibility, but it does nothing, 166 167 neither here nor at the original Perl script. 167 168 """ 168 169 170 + EPILOG = """ 171 + The return value is: 172 + 173 + - 0: success or Python version is not compatible with 174 + kernel-doc. If -Werror is not used, it will also 175 + return 0 if there are issues at kernel-doc markups; 176 + 177 + - 1: an abnormal condition happened; 178 + 179 + - 2: argparse issued an error; 180 + 181 + - 3: When -Werror is used, it means that one or more unfiltered parse 182 + warnings happened. 183 + """ 169 184 170 185 class MsgFormatter(logging.Formatter): 171 - """Helper class to format warnings on a similar way to kernel-doc.pl""" 186 + """ 187 + Helper class to capitalize errors and warnings, the same way 188 + the venerable (now retired) kernel-doc.pl used to do. 189 + """ 172 190 173 191 def format(self, record): 174 192 record.levelname = record.levelname.capitalize() 175 193 return logging.Formatter.format(self, record) 176 194 177 195 def main(): 178 - """Main program""" 196 + """ 197 + Main program. 198 + 199 + """ 179 200 180 201 parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter, 181 - description=DESC) 202 + description=DESC, epilog=EPILOG) 182 203 204 + # 183 205 # Normal arguments 184 - 206 + # 185 207 parser.add_argument("-v", "-verbose", "--verbose", action="store_true", 186 208 help="Verbose output, more warnings and other information.") 187 209 ··· 217 197 action="store_true", 218 198 help="Enable line number output (only in ReST mode)") 219 199 200 + # 220 201 # Arguments to control the warning behavior 221 - 202 + # 222 203 parser.add_argument("-Wreturn", "--wreturn", action="store_true", 223 204 help="Warns about the lack of a return markup on functions.") 224 205 ··· 240 219 parser.add_argument("-export-file", "--export-file", action='append', 241 220 help=EXPORT_FILE_DESC) 242 221 222 + # 243 223 # Output format mutually-exclusive group 244 - 224 + # 245 225 out_group = parser.add_argument_group("Output format selection (mutually exclusive)") 246 226 247 227 out_fmt = out_group.add_mutually_exclusive_group() ··· 254 232 out_fmt.add_argument("-N", "-none", "--none", action="store_true", 255 233 help="Do not output documentation, only warnings.") 256 234 235 + # 257 236 # Output selection mutually-exclusive group 258 - 237 + # 259 238 sel_group = parser.add_argument_group("Output selection (mutually exclusive)") 260 239 sel_mut = sel_group.add_mutually_exclusive_group() 261 240 ··· 269 246 sel_mut.add_argument("-s", "-function", "--symbol", action='append', 270 247 help=FUNCTION_DESC) 271 248 249 + # 272 250 # Those are valid for all 3 types of filter 251 + # 273 252 parser.add_argument("-n", "-nosymbol", "--nosymbol", action='append', 274 253 help=NOSYMBOL_DESC) 275 254 276 255 parser.add_argument("-D", "-no-doc-sections", "--no-doc-sections", 277 - action='store_true', help="Don't outputt DOC sections") 256 + action='store_true', help="Don't output DOC sections") 278 257 279 258 parser.add_argument("files", metavar="FILE", 280 259 nargs="+", help=FILES_DESC) ··· 304 279 305 280 python_ver = sys.version_info[:2] 306 281 if python_ver < (3,6): 307 - # Depending on Kernel configuration, kernel-doc --none is called at 282 + # 283 + # Depending on the Kernel configuration, kernel-doc --none is called at 308 284 # build time. As we don't want to break compilation due to the 309 285 # usage of an old Python version, return 0 here. 286 + # 310 287 if args.none: 311 - logger.error("Python 3.6 or later is required by kernel-doc. skipping checks") 288 + logger.error("Python 3.6 or later is required by kernel-doc. Skipping checks") 312 289 sys.exit(0) 313 290 314 291 sys.exit("Python 3.6 or later is required by kernel-doc. Aborting.") ··· 318 291 if python_ver < (3,7): 319 292 logger.warning("Python 3.7 or later is required for correct results") 320 293 321 - # Import kernel-doc libraries only after checking Python version 294 + # 295 + # Import kernel-doc libraries only after checking the Python version 296 + # 322 297 from kdoc.kdoc_files import KernelFiles # pylint: disable=C0415 323 298 from kdoc.kdoc_output import RestFormat, ManFormat # pylint: disable=C0415 324 299 ··· 352 323 353 324 if args.werror: 354 325 print("%s warnings as errors" % error_count) # pylint: disable=C0209 355 - sys.exit(error_count) 326 + sys.exit(WERROR_RETURN_CODE) 356 327 357 328 if args.verbose: 358 329 print("%s errors" % error_count) # pylint: disable=C0209 359 330 360 - if args.none: 361 - sys.exit(0) 331 + sys.exit(0) 362 332 363 - sys.exit(error_count) 364 - 365 - 333 + # 366 334 # Call main method 335 + # 367 336 if __name__ == "__main__": 368 337 main()
+1 -1
tools/docs/find-unused-docs.sh
··· 54 54 if [[ ${FILES_INCLUDED[$file]+_} ]]; then 55 55 continue; 56 56 fi 57 - str=$(PYTHONDONTWRITEBYTECODE=1 scripts/kernel-doc -export "$file" 2>/dev/null) 57 + str=$(PYTHONDONTWRITEBYTECODE=1 tools/docs/kernel-doc -export "$file" 2>/dev/null) 58 58 if [[ -n "$str" ]]; then 59 59 echo "$file" 60 60 fi
+1 -2
tools/docs/sphinx-build-wrapper
··· 246 246 # 247 247 self.sphinxbuild = os.environ.get("SPHINXBUILD", "sphinx-build") 248 248 self.kerneldoc = self.get_path(os.environ.get("KERNELDOC", 249 - "scripts/kernel-doc.py")) 249 + "tools/docs/kernel-doc")) 250 250 self.builddir = self.get_path(builddir, use_cwd=True, abs_path=True) 251 251 252 252 # ··· 750 750 751 751 build_args = args + [ 752 752 "-d", doctree_dir, 753 - "-D", f"kerneldoc_bin={kerneldoc}", 754 753 "-D", f"version={self.kernelversion}", 755 754 "-D", f"release={self.kernelrelease}", 756 755 "-D", f"kerneldoc_srctree={self.srctree}",
+28 -7
tools/lib/python/kdoc/kdoc_parser.py
··· 295 295 296 296 # TODO: rename to emit_message after removal of kernel-doc.pl 297 297 def emit_msg(self, ln, msg, *, warning=True): 298 - """Emit a message""" 298 + """Emit a message.""" 299 299 300 300 log_msg = f"{self.fname}:{ln} {msg}" 301 301 ··· 448 448 449 449 self.config.log.debug("Output: %s:%s = %s", dtype, name, pformat(args)) 450 450 451 + def emit_unused_warnings(self): 452 + """ 453 + When the parser fails to produce a valid entry, it places some 454 + warnings under `entry.warnings` that will be discarded when resetting 455 + the state. 456 + 457 + Ensure that those warnings are not lost. 458 + 459 + .. note:: 460 + 461 + Because we are calling `config.warning()` here, those 462 + warnings are not filtered by the `-W` parameters: they will all 463 + be produced even when `-Wreturn`, `-Wshort-desc`, and/or 464 + `-Wcontents-before-sections` are used. 465 + 466 + Allowing those warnings to be filtered is complex, because it 467 + would require storing them in a buffer and then filtering them 468 + during the output step of the code, depending on the 469 + selected symbols. 470 + """ 471 + if self.entry and self.entry not in self.entries: 472 + for log_msg in self.entry.warnings: 473 + self.config.warning(log_msg) 474 + 451 475 def reset_state(self, ln): 452 476 """ 453 477 Ancillary routine to create a new entry. It initializes all 454 478 variables used by the state machine. 455 479 """ 456 480 457 - # 458 - # Flush the warnings out before we proceed further 459 - # 460 - if self.entry and self.entry not in self.entries: 461 - for log_msg in self.entry.warnings: 462 - self.config.log.warning(log_msg) 481 + self.emit_unused_warnings() 463 482 464 483 self.entry = KernelEntry(self.config, self.fname, ln) 465 484 ··· 1759 1740 not self.process_export(export_table, line): 1760 1741 # Hand this line to the appropriate state handler 1761 1742 self.state_actions[self.state](self, ln, line) 1743 + 1744 + self.emit_unused_warnings() 1762 1745 1763 1746 except OSError: 1764 1747 self.config.log.error(f"Error: Cannot open file {self.fname}")