Skip to content

Commit 75442fb

Browse files
mchehabgregkh
authored andcommitted
docs: Kconfig/Makefile: add a check for broken ABI files
The files under Documentation/ABI should follow the syntax as defined at Documentation/ABI/README. Allow checking if they're following the syntax by running the ABI parser script on COMPILE_TEST. With that, when there's a problem with a file under Documentation/ABI, it would produce a warning like: Warning: file ./Documentation/ABI/testing/sysfs-bus-pci-devices-aer_stats#14: What '/sys/bus/pci/devices/<dev>/aer_stats/aer_rootport_total_err_cor' doesn't have a description Warning: file ./Documentation/ABI/testing/sysfs-bus-pci-devices-aer_stats#21: What '/sys/bus/pci/devices/<dev>/aer_stats/aer_rootport_total_err_fatal' doesn't have a description Acked-by: Jonathan Corbet <corbet@lwn.net> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Link: https://lore.kernel.org/r/57a38de85cb4b548857207cf1fc1bf1ee08613c9.1604042072.git.mchehab+huawei@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 50865d0 commit 75442fb

4 files changed

Lines changed: 28 additions & 3 deletions

File tree

Documentation/Kconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,14 @@ config WARN_MISSING_DOCUMENTS
1010

1111
If unsure, select 'N'.
1212

13+
config WARN_ABI_ERRORS
14+
bool "Warn if there are errors at ABI files"
15+
depends on COMPILE_TEST
16+
help
17+
The files under Documentation/ABI should follow what's
18+
described at Documentation/ABI/README. Yet, as they're manually
19+
written, it would be possible that some of those files would
20+
have errors that would break them for being parsed by
21+
scripts/get_abi.pl. Add a check to verify them.
1322

23+
If unsure, select 'N'.

Documentation/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@ ifeq ($(CONFIG_WARN_MISSING_DOCUMENTS),y)
1010
$(shell $(srctree)/scripts/documentation-file-ref-check --warn)
1111
endif
1212

13+
# Check for broken ABI files
14+
ifeq ($(CONFIG_WARN_ABI_ERRORS),y)
15+
$(shell $(srctree)/scripts/get_abi.pl validate --dir $(srctree)/Documentation/ABI)
16+
endif
17+
1318
# You can set these variables from the command line.
1419
SPHINXBUILD = sphinx-build
1520
SPHINXOPTS =

lib/Kconfig.debug

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2446,4 +2446,6 @@ config HYPERV_TESTING
24462446

24472447
endmenu # "Kernel Testing and Coverage"
24482448

2449+
source "Documentation/Kconfig"
2450+
24492451
endmenu # Kernel hacking

scripts/get_abi.pl

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,15 @@
5050
sub parse_error($$$$) {
5151
my ($file, $ln, $msg, $data) = @_;
5252

53-
print STDERR "file $file#$ln: $msg at\n\t$data";
53+
$data =~ s/\s+$/\n/;
54+
55+
print STDERR "Warning: file $file#$ln:\n\t$msg";
56+
57+
if ($data ne "") {
58+
print STDERR ". Line\n\t\t$data";
59+
} else {
60+
print STDERR "\n";
61+
}
5462
}
5563

5664
#
@@ -110,7 +118,7 @@ sub parse_abi {
110118

111119
# Invalid, but it is a common mistake
112120
if ($new_tag eq "where") {
113-
parse_error($file, $ln, "tag 'Where' is invalid. Should be 'What:' instead", $_);
121+
parse_error($file, $ln, "tag 'Where' is invalid. Should be 'What:' instead", "");
114122
$new_tag = "what";
115123
}
116124

@@ -225,7 +233,7 @@ sub parse_abi {
225233
}
226234

227235
# Everything else is error
228-
parse_error($file, $ln, "Unexpected line:", $_);
236+
parse_error($file, $ln, "Unexpected content", $_);
229237
}
230238
$data{$nametag}->{description} =~ s/^\n+// if ($data{$nametag}->{description});
231239
if ($what) {

0 commit comments

Comments
 (0)