forked from mirrors/linux
		
	kernel-doc: don't let V=1 change outcome
The kernel-doc script currently reports a number of issues only in "verbose" mode, but that's initialized from V=1 (via KBUILD_VERBOSE), so if you use KDOC_WERROR=1 then adding V=1 might actually break the build. This is rather unexpected. Change kernel-doc to not change its behaviour wrt. errors (or warnings) when verbose mode is enabled, but rather add separate warning flags (and -Wall) for it. Allow enabling those flags via environment/make variables in the kernel's build system for easier user use, but to not have to parse them in the script itself. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Acked-by: Jonathan Corbet <corbet@lwn.net> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
This commit is contained in:
		
							parent
							
								
									3a3f1e573a
								
							
						
					
					
						commit
						56b0f453db
					
				
					 3 changed files with 30 additions and 6 deletions
				
			
		| 
						 | 
					@ -150,6 +150,12 @@ the UTS_MACHINE variable, and on some architectures also the kernel config.
 | 
				
			||||||
The value of KBUILD_DEBARCH is assumed (not checked) to be a valid Debian
 | 
					The value of KBUILD_DEBARCH is assumed (not checked) to be a valid Debian
 | 
				
			||||||
architecture.
 | 
					architecture.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					KDOCFLAGS
 | 
				
			||||||
 | 
					---------
 | 
				
			||||||
 | 
					Specify extra (warning/error) flags for kernel-doc checks during the build,
 | 
				
			||||||
 | 
					see scripts/kernel-doc for which flags are supported. Note that this doesn't
 | 
				
			||||||
 | 
					(currently) apply to documentation builds.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ARCH
 | 
					ARCH
 | 
				
			||||||
----
 | 
					----
 | 
				
			||||||
Set ARCH to the architecture to be built.
 | 
					Set ARCH to the architecture to be built.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -101,7 +101,7 @@ else ifeq ($(KBUILD_CHECKSRC),2)
 | 
				
			||||||
endif
 | 
					endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ifneq ($(KBUILD_EXTRA_WARN),)
 | 
					ifneq ($(KBUILD_EXTRA_WARN),)
 | 
				
			||||||
  cmd_checkdoc = $(srctree)/scripts/kernel-doc -none $<
 | 
					  cmd_checkdoc = $(srctree)/scripts/kernel-doc -none $(KDOCFLAGS) $<
 | 
				
			||||||
endif
 | 
					endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Compile C sources (.c)
 | 
					# Compile C sources (.c)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -23,7 +23,7 @@ kernel-doc - Print formatted kernel documentation to stdout
 | 
				
			||||||
 | 
					
 | 
				
			||||||
=head1 SYNOPSIS
 | 
					=head1 SYNOPSIS
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 kernel-doc [-h] [-v] [-Werror]
 | 
					 kernel-doc [-h] [-v] [-Werror] [-Wall] [-Wreturn] [-Wshort-description] [-Wcontents-before-sections]
 | 
				
			||||||
   [ -man |
 | 
					   [ -man |
 | 
				
			||||||
     -rst [-sphinx-version VERSION] [-enable-lineno] |
 | 
					     -rst [-sphinx-version VERSION] [-enable-lineno] |
 | 
				
			||||||
     -none
 | 
					     -none
 | 
				
			||||||
| 
						 | 
					@ -133,6 +133,9 @@ my $dohighlight = "";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
my $verbose = 0;
 | 
					my $verbose = 0;
 | 
				
			||||||
my $Werror = 0;
 | 
					my $Werror = 0;
 | 
				
			||||||
 | 
					my $Wreturn = 0;
 | 
				
			||||||
 | 
					my $Wshort_desc = 0;
 | 
				
			||||||
 | 
					my $Wcontents_before_sections = 0;
 | 
				
			||||||
my $output_mode = "rst";
 | 
					my $output_mode = "rst";
 | 
				
			||||||
my $output_preformatted = 0;
 | 
					my $output_preformatted = 0;
 | 
				
			||||||
my $no_doc_sections = 0;
 | 
					my $no_doc_sections = 0;
 | 
				
			||||||
| 
						 | 
					@ -187,9 +190,14 @@ if (defined($ENV{'KCFLAGS'})) {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# reading this variable is for backwards compat just in case
 | 
				
			||||||
 | 
					# someone was calling it with the variable from outside the
 | 
				
			||||||
 | 
					# kernel's build system
 | 
				
			||||||
if (defined($ENV{'KDOC_WERROR'})) {
 | 
					if (defined($ENV{'KDOC_WERROR'})) {
 | 
				
			||||||
	$Werror = "$ENV{'KDOC_WERROR'}";
 | 
						$Werror = "$ENV{'KDOC_WERROR'}";
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					# other environment variables are converted to command-line
 | 
				
			||||||
 | 
					# arguments in cmd_checkdoc in the build system
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Generated docbook code is inserted in a template at a point where
 | 
					# Generated docbook code is inserted in a template at a point where
 | 
				
			||||||
# docbook v3.1 requires a non-zero sequence of RefEntry's; see:
 | 
					# docbook v3.1 requires a non-zero sequence of RefEntry's; see:
 | 
				
			||||||
| 
						 | 
					@ -318,6 +326,16 @@ while ($ARGV[0] =~ m/^--?(.*)/) {
 | 
				
			||||||
	$verbose = 1;
 | 
						$verbose = 1;
 | 
				
			||||||
    } elsif ($cmd eq "Werror") {
 | 
					    } elsif ($cmd eq "Werror") {
 | 
				
			||||||
	$Werror = 1;
 | 
						$Werror = 1;
 | 
				
			||||||
 | 
					    } elsif ($cmd eq "Wreturn") {
 | 
				
			||||||
 | 
						$Wreturn = 1;
 | 
				
			||||||
 | 
					    } elsif ($cmd eq "Wshort-desc") {
 | 
				
			||||||
 | 
						$Wshort_desc = 1;
 | 
				
			||||||
 | 
					    } elsif ($cmd eq "Wcontents-before-sections") {
 | 
				
			||||||
 | 
						$Wcontents_before_sections = 1;
 | 
				
			||||||
 | 
					    } elsif ($cmd eq "Wall") {
 | 
				
			||||||
 | 
					        $Wreturn = 1;
 | 
				
			||||||
 | 
					        $Wshort_desc = 1;
 | 
				
			||||||
 | 
					        $Wcontents_before_sections = 1;
 | 
				
			||||||
    } elsif (($cmd eq "h") || ($cmd eq "help")) {
 | 
					    } elsif (($cmd eq "h") || ($cmd eq "help")) {
 | 
				
			||||||
		pod2usage(-exitval => 0, -verbose => 2);
 | 
							pod2usage(-exitval => 0, -verbose => 2);
 | 
				
			||||||
    } elsif ($cmd eq 'no-doc-sections') {
 | 
					    } elsif ($cmd eq 'no-doc-sections') {
 | 
				
			||||||
| 
						 | 
					@ -1748,9 +1766,9 @@ sub dump_function($$) {
 | 
				
			||||||
    # This check emits a lot of warnings at the moment, because many
 | 
					    # This check emits a lot of warnings at the moment, because many
 | 
				
			||||||
    # functions don't have a 'Return' doc section. So until the number
 | 
					    # functions don't have a 'Return' doc section. So until the number
 | 
				
			||||||
    # of warnings goes sufficiently down, the check is only performed in
 | 
					    # of warnings goes sufficiently down, the check is only performed in
 | 
				
			||||||
    # verbose mode.
 | 
					    # -Wreturn mode.
 | 
				
			||||||
    # TODO: always perform the check.
 | 
					    # TODO: always perform the check.
 | 
				
			||||||
    if ($verbose && !$noret) {
 | 
					    if ($Wreturn && !$noret) {
 | 
				
			||||||
	    check_return_section($file, $declaration_name, $return_type);
 | 
						    check_return_section($file, $declaration_name, $return_type);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2054,7 +2072,7 @@ sub process_name($$) {
 | 
				
			||||||
	    $state = STATE_NORMAL;
 | 
						    $state = STATE_NORMAL;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (($declaration_purpose eq "") && $verbose) {
 | 
						if (($declaration_purpose eq "") && $Wshort_desc) {
 | 
				
			||||||
	    emit_warning("${file}:$.", "missing initial short description on line:\n$_");
 | 
						    emit_warning("${file}:$.", "missing initial short description on line:\n$_");
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2103,7 +2121,7 @@ sub process_body($$) {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (($contents ne "") && ($contents ne "\n")) {
 | 
						if (($contents ne "") && ($contents ne "\n")) {
 | 
				
			||||||
	    if (!$in_doc_sect && $verbose) {
 | 
						    if (!$in_doc_sect && $Wcontents_before_sections) {
 | 
				
			||||||
		emit_warning("${file}:$.", "contents before sections\n");
 | 
							emit_warning("${file}:$.", "contents before sections\n");
 | 
				
			||||||
	    }
 | 
						    }
 | 
				
			||||||
	    dump_section($file, $section, $contents);
 | 
						    dump_section($file, $section, $contents);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue