From: Michal Marek <mmarek@suse.cz>
To: Yacine Belkadi <yacine.belkadi.1@gmail.com>,
Randy Dunlap <rdunlap@xenotime.net>
Cc: Rob Landley <rob@landley.net>,
linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] scripts/kernel-doc: check that non-void fcts describe their return value
Date: Tue, 20 Nov 2012 10:29:58 +0100 [thread overview]
Message-ID: <50AB4D96.7050509@suse.cz> (raw)
In-Reply-To: <1349040737-1659-2-git-send-email-yacine.belkadi.1@gmail.com>
On 30.9.2012 23:32, Yacine Belkadi wrote:
> If a function has a return value, but its kernel-doc comment doesn't contain a
> "Return" section, then emit the following warning:
>
> Warning(file.h:129): No description found for return value of 'fct'
>
> Note: This check emits a lot of warnings at the moment, because many functions
> don't have a 'Return' doc section. So until the number of warnings goes
> sufficiently down, the check is only performed in verbose mode.
>
> Signed-off-by: Yacine Belkadi <yacine.belkadi.1@gmail.com>
Randy, are you fine merging this to kbuild.git?
Thanks,
Michal
> ---
> scripts/kernel-doc | 34 ++++++++++++++++++++++++++++++++++
> 1 file changed, 34 insertions(+)
>
> diff --git a/scripts/kernel-doc b/scripts/kernel-doc
> index 8fd107a..7f82aa8 100755
> --- a/scripts/kernel-doc
> +++ b/scripts/kernel-doc
> @@ -130,6 +130,8 @@ use strict;
> # should document the "Context:" of the function, e.g. whether the functions
> # can be called form interrupts. Unlike other sections you can end it with an
> # empty line.
> +# A non-void function should have a "Return:" section describing the return
> +# value.
> # Example-sections should contain the string EXAMPLE so that they are marked
> # appropriately in DocBook.
> #
> @@ -298,6 +300,7 @@ my $section_default = "Description"; # default section
> my $section_intro = "Introduction";
> my $section = $section_default;
> my $section_context = "Context";
> +my $section_return = "Return";
>
> my $undescribed = "-- undescribed --";
>
> @@ -1767,6 +1770,28 @@ sub check_sections($$$$$$) {
> }
>
> ##
> +# Checks the section describing the return value of a function.
> +sub check_return_section {
> + my $file = shift;
> + my $declaration_name = shift;
> + my $return_type = shift;
> +
> + # Ignore an empty return type (It's a macro)
> + # Ignore functions with a "void" return type. (But don't ignore "void *")
> + if (($return_type eq "") || ($return_type =~ /void\s*\w*\s*$/)) {
> + return;
> + }
> +
> + if (!defined($sections{$section_return}) ||
> + $sections{$section_return} eq "") {
> + print STDERR "Warning(${file}:$.): " .
> + "No description found for return value of " .
> + "'$declaration_name'\n";
> + ++$warnings;
> + }
> +}
> +
> +##
> # takes a function prototype and the name of the current file being
> # processed and spits out all the details stored in the global
> # arrays/hashes.
> @@ -1837,6 +1862,15 @@ sub dump_function($$) {
> my $prms = join " ", @parameterlist;
> check_sections($file, $declaration_name, "function", $sectcheck, $prms, "");
>
> + # This check emits a lot of warnings at the moment, because many
> + # functions don't have a 'Return' doc section. So until the number
> + # of warnings goes sufficiently down, the check is only performed in
> + # verbose mode.
> + # TODO: always perform the check.
> + if ($verbose) {
> + check_return_section($file, $declaration_name, $return_type);
> + }
> +
> output_declaration($declaration_name,
> 'function',
> {'function' => $declaration_name,
>
next prev parent reply other threads:[~2012-11-20 9:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-30 21:32 [PATCH 1/2] Kernel-doc: Convention: Use a "Return" section to describe return values Yacine Belkadi
2012-09-30 21:32 ` [PATCH 2/2] scripts/kernel-doc: check that non-void fcts describe their return value Yacine Belkadi
2012-11-20 9:29 ` Michal Marek [this message]
2012-11-20 17:45 ` Randy Dunlap
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=50AB4D96.7050509@suse.cz \
--to=mmarek@suse.cz \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rdunlap@xenotime.net \
--cc=rob@landley.net \
--cc=yacine.belkadi.1@gmail.com \
/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