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.

scripts/kernel-doc.py: Properly handle Werror and exit codes

The original kernel-doc script has a logic to return warnings
as errors, and to report the number of warnings found, if in
verbose mode.

Implement it to be fully compatible with the original script.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/de33b0cebd9fdf82d8b221bcfe41db7269286222.1744106242.git.mchehab+huawei@kernel.org

authored by

Mauro Carvalho Chehab and committed by
Jonathan Corbet
11afeab6 e4b2bd90

+35 -18
+16 -2
scripts/kernel-doc.py
··· 78 78 # Yacine Belkadi <yacine.belkadi.1@gmail.com> 79 79 # Yujie Liu <yujie.liu@intel.com> 80 80 81 - # TODO: implement warning filtering 82 - 83 81 """ 84 82 kernel_doc 85 83 ========== ··· 292 294 msg = t[1] 293 295 if msg: 294 296 print(msg) 297 + 298 + error_count = kfiles.errors 299 + if not error_count: 300 + sys.exit(0) 301 + 302 + if args.werror: 303 + print(f"{error_count} warnings as errors") 304 + sys.exit(error_count) 305 + 306 + if args.verbose: 307 + print(f"{error_count} errors") 308 + 309 + if args.none: 310 + sys.exit(0) 311 + 312 + sys.exit(error_count) 295 313 296 314 297 315 # Call main method
+10 -2
scripts/lib/kdoc/kdoc_files.py
··· 12 12 import logging 13 13 import os 14 14 import re 15 - import sys 16 15 17 16 from kdoc_parser import KernelDoc 18 17 from kdoc_output import OutputFormat ··· 108 109 KernelDoc.process_export(self.config.function_table, line) 109 110 110 111 except IOError: 111 - print(f"Error: Cannot open fname {fname}", fname=sys.stderr) 112 + self.config.log.error("Error: Cannot open fname %s", fname) 112 113 self.config.errors += 1 113 114 114 115 def file_not_found_cb(self, fname): ··· 261 262 fname, ln, dtype) 262 263 if msg: 263 264 yield fname, msg 265 + 266 + @property 267 + def errors(self): 268 + """ 269 + Return a count of the number of warnings found, including 270 + the ones displayed while interacting over self.msg. 271 + """ 272 + 273 + return self.config.errors
+3 -5
scripts/lib/kdoc/kdoc_output.py
··· 128 128 129 129 warnings = args.get('warnings', []) 130 130 131 - for warning, log_msg in warnings: 132 - if warning: 133 - self.config.log.warning(log_msg) 134 - else: 135 - self.config.log.info(log_msg) 131 + for log_msg in warnings: 132 + self.config.log.warning(log_msg) 133 + self.config.errors += 1 136 134 137 135 def check_doc(self, name, args): 138 136 """Check if DOC should be output"""
+6 -9
scripts/lib/kdoc/kdoc_parser.py
··· 137 137 138 138 log_msg = f"{self.fname}:{ln} {msg}" 139 139 140 + if not warning: 141 + self.config.log.info(log_msg) 142 + return 143 + 140 144 if self.entry: 141 145 # Delegate warning output to output logic, as this way it 142 146 # will report warnings/info only for symbols that are output 143 147 144 - self.entry.warnings.append((warning, log_msg)) 148 + self.entry.warnings.append(log_msg) 145 149 return 146 150 147 - if warning: 148 - self.config.log.warning(log_msg) 149 - else: 150 - self.config.log.info(log_msg) 151 + self.config.log.warning(log_msg) 151 152 152 153 def dump_section(self, start_new=True): 153 154 """ ··· 557 556 558 557 if not members: 559 558 self.emit_warning(ln, f"{proto} error: Cannot parse struct or union!") 560 - self.config.errors += 1 561 559 return 562 560 563 561 if self.entry.identifier != declaration_name: ··· 831 831 832 832 if not members: 833 833 self.emit_warning(ln, f"{proto}: error: Cannot parse enum!") 834 - self.config.errors += 1 835 834 return 836 835 837 836 if self.entry.identifier != declaration_name: ··· 1131 1132 return 1132 1133 1133 1134 self.emit_warning(ln, "error: Cannot parse typedef!") 1134 - self.config.errors += 1 1135 1135 1136 1136 @staticmethod 1137 1137 def process_export(function_table, line): ··· 1675 1677 self.process_docblock(ln, line) 1676 1678 except OSError: 1677 1679 self.config.log.error(f"Error: Cannot open file {self.fname}") 1678 - self.config.errors += 1