scripts/checkpatch: Check for patches adding #defines for libc APIs
All code in the Zephyr core must use only the Zephyr C library API according to rules A.4 and A.5. Such code is not permitted to request API extensions from the C library via any of the API request mechanisms. This addition to checkpatch.pl verifies that patches don't #define any of these: __STRICT_ANSI__ _POSIX_SOURCE _POSIX_C_SOURCE _XOPEN_SOURCE _ISOC99_SOURCE _ISOC11_SOURCE _ATFILE_SOURCE _GNU_SOURCE _BSD_SOURCE _SVID_SOURCE _DEFAULT_SOURCE Reference: #49922 Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
parent
f937c031d8
commit
b021dece98
|
@ -592,6 +592,20 @@ our @mode_permission_funcs = (
|
|||
["__ATTR", 2],
|
||||
);
|
||||
|
||||
our $api_defines = qr{(?x:
|
||||
_ATFILE_SOURCE|
|
||||
_BSD_SOURCE|
|
||||
_DEFAULT_SOURCE
|
||||
_GNU_SOURCE|
|
||||
_ISOC11_SOURCE|
|
||||
_ISOC99_SOURCE|
|
||||
_POSIX_C_SOURCE|
|
||||
_POSIX_SOURCE|
|
||||
_SVID_SOURCE|
|
||||
_XOPEN_SOURCE|
|
||||
_XOPEN_SOURCE_EXTENDED|
|
||||
)};
|
||||
|
||||
my $word_pattern = '\b[A-Z]?[a-z]{2,}\b';
|
||||
|
||||
#Create a search pattern for all these functions to speed up a loop below
|
||||
|
@ -6527,6 +6541,13 @@ sub process {
|
|||
}
|
||||
}
|
||||
|
||||
# check for feature test macros that request C library API extensions, violating rules A.4 and A.5
|
||||
|
||||
if ($line =~ /#\s*define\s+$api_defines/) {
|
||||
ERROR("API_DEFINE",
|
||||
"do not specify a non-Zephyr API for libc\n" . "$here$rawline\n");
|
||||
}
|
||||
|
||||
# check for IS_ENABLED() without CONFIG_<FOO> ($rawline for comments too)
|
||||
if ($rawline =~ /\bIS_ENABLED\s*\(\s*(\w+)\s*\)/ && $1 !~ /^CONFIG_/) {
|
||||
WARN("IS_ENABLED_CONFIG",
|
||||
|
|
Loading…
Reference in a new issue