lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 26 Nov 2012 17:43:35 -0800
From:	Randy Dunlap <rdunlap@...radead.org>
To:	Yacine Belkadi <yacine.belkadi.1@...il.com>
CC:	Andrew Morton <akpm@...ux-foundation.org>,
	Randy Dunlap <rdunlap@...otime.net>,
	Daniel Santos <daniel.santos@...ox.com>,
	Michal Marek <mmarek@...e.cz>, linux-doc@...r.kernel.org,
	linux-kernel@...r.kernel.org, Rob Landley <rob@...dley.net>
Subject: Re: [PATCHv2 2/2] scripts/kernel-doc: check that non-void fcts describe
 their return value

On 11/26/2012 01:22 PM, 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@...il.com>


Both patches:
Acked-by: Randy Dunlap <rdunlap@...radead.org>

Michal, please merge patches 1 and 2.

Thanks.

> ---
>  scripts/kernel-doc |   34 ++++++++++++++++++++++++++++++++++
>  1 file changed, 34 insertions(+)
> 
> diff --git a/scripts/kernel-doc b/scripts/kernel-doc
> index 46e7aff..28b7615 100755
> --- a/scripts/kernel-doc
> +++ b/scripts/kernel-doc
> @@ -137,6 +137,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(s).
>  # Example-sections should contain the string EXAMPLE so that they are marked
>  # appropriately in DocBook.
>  #
> @@ -315,6 +317,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 --";
>  
> @@ -2039,6 +2042,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.
> @@ -2109,6 +2134,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,



-- 
~Randy
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ