Add optional check for bad kernel-doc comments

Implement a '-none' output mode for kernel-doc which will only output
warning messages, and suppresses the warning message about there being
no kernel-doc in the file.

If the build has requested additional warnings, automatically check all
.c files.  This patch does not check .h files.  Enabling the warning
by default would add about 1300 warnings, so it's default off for now.
People who care can use this to check they didn't break the docs and
maybe we'll get all the warnings fixed and be able to enable this check
by default in the future.

Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
This commit is contained in:
Matthew Wilcox 2017-11-20 10:40:40 -08:00 коммит произвёл Jonathan Corbet
Родитель e7e61fc0ba
Коммит 3a025e1d1c
2 изменённых файлов: 29 добавлений и 1 удалений

Просмотреть файл

@ -108,6 +108,10 @@ ifneq ($(KBUILD_CHECKSRC),0)
endif endif
endif endif
ifneq ($(KBUILD_ENABLE_EXTRA_GCC_CHECKS),)
cmd_checkdoc = $(srctree)/scripts/kernel-doc -none $< ;
endif
# Do section mismatch analysis for each module/built-in.o # Do section mismatch analysis for each module/built-in.o
ifdef CONFIG_DEBUG_SECTION_MISMATCH ifdef CONFIG_DEBUG_SECTION_MISMATCH
cmd_secanalysis = ; scripts/mod/modpost $@ cmd_secanalysis = ; scripts/mod/modpost $@
@ -289,6 +293,7 @@ define rule_cc_o_c
$(call echo-cmd,checksrc) $(cmd_checksrc) \ $(call echo-cmd,checksrc) $(cmd_checksrc) \
$(call cmd_and_fixdep,cc_o_c) \ $(call cmd_and_fixdep,cc_o_c) \
$(cmd_modversions_c) \ $(cmd_modversions_c) \
$(cmd_checkdoc) \
$(call echo-cmd,objtool) $(cmd_objtool) \ $(call echo-cmd,objtool) $(cmd_objtool) \
$(call echo-cmd,record_mcount) $(cmd_record_mcount) $(call echo-cmd,record_mcount) $(cmd_record_mcount)
endef endef

Просмотреть файл

@ -58,6 +58,7 @@ Output format selection (mutually exclusive):
-man Output troff manual page format. This is the default. -man Output troff manual page format. This is the default.
-rst Output reStructuredText format. -rst Output reStructuredText format.
-text Output plain text format. -text Output plain text format.
-none Do not output documentation, only warnings.
Output selection (mutually exclusive): Output selection (mutually exclusive):
-export Only output documentation for symbols that have been -export Only output documentation for symbols that have been
@ -532,6 +533,8 @@ while ($ARGV[0] =~ m/^-(.*)/) {
$output_mode = "gnome"; $output_mode = "gnome";
@highlights = @highlights_gnome; @highlights = @highlights_gnome;
$blankline = $blankline_gnome; $blankline = $blankline_gnome;
} elsif ($cmd eq "-none") {
$output_mode = "none";
} elsif ($cmd eq "-module") { # not needed for XML, inherits from calling document } elsif ($cmd eq "-module") { # not needed for XML, inherits from calling document
$modulename = shift @ARGV; $modulename = shift @ARGV;
} elsif ($cmd eq "-function") { # to only output specific functions } elsif ($cmd eq "-function") { # to only output specific functions
@ -2117,6 +2120,24 @@ sub output_blockhead_list(%) {
} }
} }
## none mode output functions
sub output_function_none(%) {
}
sub output_enum_none(%) {
}
sub output_typedef_none(%) {
}
sub output_struct_none(%) {
}
sub output_blockhead_none(%) {
}
## ##
# generic output function for all types (function, struct/union, typedef, enum); # generic output function for all types (function, struct/union, typedef, enum);
# calls the generated, variable output_ function name based on # calls the generated, variable output_ function name based on
@ -3145,7 +3166,9 @@ sub process_file($) {
} }
} }
if ($initial_section_counter == $section_counter) { if ($initial_section_counter == $section_counter) {
print STDERR "${file}:1: warning: no structured comments found\n"; if ($output_mode ne "none") {
print STDERR "${file}:1: warning: no structured comments found\n";
}
if (($output_selection == OUTPUT_INCLUDE) && ($show_not_found == 1)) { if (($output_selection == OUTPUT_INCLUDE) && ($show_not_found == 1)) {
print STDERR " Was looking for '$_'.\n" for keys %function_table; print STDERR " Was looking for '$_'.\n" for keys %function_table;
} }