public inbox for linux-doc@vger.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@intel.com>
To: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>,
	Linux Doc Mailing List <linux-doc@vger.kernel.org>,
	Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>,
	linux-kernel@vger.kernel.org, Jonathan Corbet <corbet@lwn.net>
Subject: Re: [PATCH 2/4] scripts/kernel-doc: avoid error_count overflows
Date: Mon, 12 Jan 2026 14:02:10 +0200	[thread overview]
Message-ID: <ea13b9a9b0fbd4272db4b09564a60545eda871b3@intel.com> (raw)
In-Reply-To: <bb0bd9ecbf38f8d28749ea15f8d04fb640e0c76d.1768216455.git.mchehab+huawei@kernel.org>

On Mon, 12 Jan 2026, Mauro Carvalho Chehab <mchehab+huawei@kernel.org> wrote:
> 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>
> ---
>  scripts/kernel-doc.py | 32 ++++++++++++++++++++++----------
>  1 file changed, 22 insertions(+), 10 deletions(-)
>
> diff --git a/scripts/kernel-doc.py b/scripts/kernel-doc.py
> index 7a1eaf986bcd..600bdfea6a96 100755
> --- a/scripts/kernel-doc.py
> +++ b/scripts/kernel-doc.py
> @@ -176,7 +176,14 @@ class MsgFormatter(logging.Formatter):
>          return logging.Formatter.format(self, record)
>  
>  def main():
> -    """Main program"""
> +    """
> +    Main program
> +    By default, the return value is zero on parsing errors or when the
> +    Python version is not compatible with kernel-doc. The rationale is
> +    to not break Linux compilation on such cases.
> +    If -Werror is used, it will return the number of parse errors, up to
> +    255 errors, as this is the maximum value allowed by glibc.
> +    """
>  
>      parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter,
>                                       description=DESC)
> @@ -321,18 +328,23 @@ def main():
>      if not error_count:
>          sys.exit(0)
>  
> +    if args.verbose:
> +        print("%s errors" % error_count)                # pylint: disable=C0209
> +
> +
>      if args.werror:
>          print("%s warnings as errors" % error_count)    # pylint: disable=C0209
> +
> +        #
> +        # Return code is 8-bits, as seen at:
> +        #   https://www.gnu.org/software/libc/manual/html_node/Exit-Status.html
> +        # Truncate to avoid overflow
> +        #
> +        if error_count > 255:
> +            error_count = 255

What's the point in returning the error count anyway?

I'd rather see some error/warning classification in the exit code than a
count. Like, the argparser uses exit code 2 by default, so you can't
even trust the exit code to return the count anyway.

BR,
Jani.

> +
>          sys.exit(error_count)
> -
> -    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__":

-- 
Jani Nikula, Intel

  reply	other threads:[~2026-01-12 12:02 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-12 11:23 [PATCH 0/4] kernel-doc: fix -Werror issues Mauro Carvalho Chehab
2026-01-12 11:23 ` [PATCH 1/4] scripts/kernel-doc: fix logic to handle unissued warnings Mauro Carvalho Chehab
2026-01-12 11:43   ` Andy Shevchenko
2026-01-12 11:23 ` [PATCH 2/4] scripts/kernel-doc: avoid error_count overflows Mauro Carvalho Chehab
2026-01-12 12:02   ` Jani Nikula [this message]
2026-01-12 14:39     ` Mauro Carvalho Chehab
2026-01-12 11:23 ` [PATCH 3/4] scripts/kernel-doc: ensure that comments are using our coding style Mauro Carvalho Chehab
2026-01-12 11:23 ` [PATCH 4/4] scripts/kernel-doc: some fixes to kernel-doc comments Mauro Carvalho Chehab
2026-01-12 12:11   ` Jani Nikula

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=ea13b9a9b0fbd4272db4b09564a60545eda871b3@intel.com \
    --to=jani.nikula@intel.com \
    --cc=corbet@lwn.net \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchehab+huawei@kernel.org \
    --cc=mchehab@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