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
This commit is contained in:
Mauro Carvalho Chehab
2025-04-08 18:09:31 +08:00
committed by Jonathan Corbet
parent e4b2bd908c
commit 11afeab6d7
4 changed files with 35 additions and 18 deletions

View File

@@ -12,7 +12,6 @@ import argparse
import logging
import os
import re
import sys
from kdoc_parser import KernelDoc
from kdoc_output import OutputFormat
@@ -109,7 +108,7 @@ class KernelFiles():
KernelDoc.process_export(self.config.function_table, line)
except IOError:
print(f"Error: Cannot open fname {fname}", fname=sys.stderr)
self.config.log.error("Error: Cannot open fname %s", fname)
self.config.errors += 1
def file_not_found_cb(self, fname):
@@ -262,3 +261,12 @@ class KernelFiles():
fname, ln, dtype)
if msg:
yield fname, msg
@property
def errors(self):
"""
Return a count of the number of warnings found, including
the ones displayed while interacting over self.msg.
"""
return self.config.errors