From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
To: Jonathan Corbet <corbet@lwn.net>,
Linux Doc Mailing List <linux-doc@vger.kernel.org>
Cc: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>,
dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org,
linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org,
workflows@vger.kernel.org,
Mauro Carvalho Chehab <mchehab@kernel.org>,
stable@vger.kernel.org
Subject: [PATCH 2/9] docs: kdoc: avoid error_count overflows
Date: Mon, 19 Jan 2026 13:04:57 +0100 [thread overview]
Message-ID: <233d1674db99ed8feb405a2f781de350f0fba0ac.1768823489.git.mchehab+huawei@kernel.org> (raw)
In-Reply-To: <cover.1768823489.git.mchehab+huawei@kernel.org>
The glibc library limits the return code to 8 bits. We need to
stick to this limit when using sys.exit(error_count).
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Cc: stable@vger.kernel.org
---
scripts/kernel-doc.py | 26 +++++++++++++++++++-------
1 file changed, 19 insertions(+), 7 deletions(-)
diff --git a/scripts/kernel-doc.py b/scripts/kernel-doc.py
index 7a1eaf986bcd..1ebb16b9bb08 100755
--- a/scripts/kernel-doc.py
+++ b/scripts/kernel-doc.py
@@ -116,6 +116,8 @@ SRC_DIR = os.path.dirname(os.path.realpath(__file__))
sys.path.insert(0, os.path.join(SRC_DIR, LIB_DIR))
+WERROR_RETURN_CODE = 3
+
DESC = """
Read C language source or header FILEs, extract embedded documentation comments,
and print formatted documentation to standard output.
@@ -176,7 +178,21 @@ class MsgFormatter(logging.Formatter):
return logging.Formatter.format(self, record)
def main():
- """Main program"""
+ """
+ Main program.
+
+ By default, the return value is:
+
+ - 0: success or Python version is not compatible with
+ kernel-doc. If -Werror is not used, it will also
+ return 0 if there are issues at kernel-doc markups;
+
+ - 1: an abnormal condition happened;
+
+ - 2: argparse issued an error;
+
+ - 3: -Werror is used, and one or more unfiltered parse warnings happened.
+ """
parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter,
description=DESC)
@@ -323,16 +339,12 @@ def main():
if args.werror:
print("%s warnings as errors" % error_count) # pylint: disable=C0209
- sys.exit(error_count)
+ sys.exit(WERROR_RETURN_CODE)
if args.verbose:
print("%s errors" % error_count) # pylint: disable=C0209
- if args.none:
- sys.exit(0)
-
- sys.exit(error_count)
-
+ sys.exit(0)
# Call main method
if __name__ == "__main__":
--
2.52.0
next prev parent reply other threads:[~2026-01-19 12:05 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-19 12:04 [PATCH 0/9] docs: Fix kernel-doc -Werror and moves it to tools/docs Mauro Carvalho Chehab
2026-01-19 12:04 ` [PATCH 1/9] docs: kdoc: fix logic to handle unissued warnings Mauro Carvalho Chehab
2026-01-19 12:04 ` Mauro Carvalho Chehab [this message]
2026-01-19 12:04 ` [PATCH 3/9] docs: kdoc: ensure that comments are using our coding style Mauro Carvalho Chehab
2026-01-19 12:04 ` [PATCH 4/9] docs: kdoc: some fixes to kernel-doc comments Mauro Carvalho Chehab
2026-01-19 12:05 ` [PATCH 5/9] docs: kdoc: remove support for an external kernel-doc from sphinx Mauro Carvalho Chehab
2026-01-19 12:05 ` [PATCH 6/9] docs: kdoc: move kernel-doc to tools/docs Mauro Carvalho Chehab
2026-01-19 12:05 ` [PATCH 7/9] docs: kdoc: move the return values to the helper message Mauro Carvalho Chehab
2026-01-19 12:05 ` [PATCH 8/9] docs: kdoc: improve description of MsgFormatter Mauro Carvalho Chehab
2026-01-19 12:05 ` [PATCH 9/9] docs: conf.py: get rid of the now unused kerneldoc_bin env var Mauro Carvalho Chehab
2026-01-20 22:56 ` [PATCH 0/9] docs: Fix kernel-doc -Werror and moves it to tools/docs Jonathan Corbet
2026-01-20 23:00 ` Mauro Carvalho Chehab
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=233d1674db99ed8feb405a2f781de350f0fba0ac.1768823489.git.mchehab+huawei@kernel.org \
--to=mchehab+huawei@kernel.org \
--cc=corbet@lwn.net \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=stable@vger.kernel.org \
--cc=workflows@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox