Skip to content

Commit 802774d

Browse files
mchehabJonathan Corbet
authored andcommitted
docs: kdoc: avoid error_count overflows
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 Signed-off-by: Jonathan Corbet <corbet@lwn.net> Message-ID: <233d1674db99ed8feb405a2f781de350f0fba0ac.1768823489.git.mchehab+huawei@kernel.org>
1 parent 292eca3 commit 802774d

1 file changed

Lines changed: 19 additions & 7 deletions

File tree

scripts/kernel-doc.py

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,8 @@
116116

117117
sys.path.insert(0, os.path.join(SRC_DIR, LIB_DIR))
118118

119+
WERROR_RETURN_CODE = 3
120+
119121
DESC = """
120122
Read C language source or header FILEs, extract embedded documentation comments,
121123
and print formatted documentation to standard output.
@@ -176,7 +178,21 @@ def format(self, record):
176178
return logging.Formatter.format(self, record)
177179

178180
def main():
179-
"""Main program"""
181+
"""
182+
Main program.
183+
184+
By default, the return value is:
185+
186+
- 0: success or Python version is not compatible with
187+
kernel-doc. If -Werror is not used, it will also
188+
return 0 if there are issues at kernel-doc markups;
189+
190+
- 1: an abnormal condition happened;
191+
192+
- 2: argparse issued an error;
193+
194+
- 3: -Werror is used, and one or more unfiltered parse warnings happened.
195+
"""
180196

181197
parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter,
182198
description=DESC)
@@ -323,16 +339,12 @@ def main():
323339

324340
if args.werror:
325341
print("%s warnings as errors" % error_count) # pylint: disable=C0209
326-
sys.exit(error_count)
342+
sys.exit(WERROR_RETURN_CODE)
327343

328344
if args.verbose:
329345
print("%s errors" % error_count) # pylint: disable=C0209
330346

331-
if args.none:
332-
sys.exit(0)
333-
334-
sys.exit(error_count)
335-
347+
sys.exit(0)
336348

337349
# Call main method
338350
if __name__ == "__main__":

0 commit comments

Comments
 (0)