checksrc: add STRNCPY as an opt-in rule to detect and error on strncpy
make "lib/.checksrc" enable it Closes #14830
This commit is contained in:
parent
344a177aac
commit
80df6a5c12
@ -1 +1,2 @@
|
||||
enable STRERROR
|
||||
enable STRNCPY
|
||||
|
||||
@ -50,6 +50,7 @@ my @ignore_line;
|
||||
my %warnings_extended = (
|
||||
'COPYRIGHTYEAR' => 'copyright year incorrect',
|
||||
'STRERROR', => 'strerror() detected',
|
||||
'STRNCPY', => 'strncpy() detected',
|
||||
'STDERR', => 'stderr detected',
|
||||
);
|
||||
|
||||
@ -751,6 +752,18 @@ sub scanfile {
|
||||
}
|
||||
}
|
||||
}
|
||||
if($warnings{"STRNCPY"}) {
|
||||
# scan for use of banned strncpy. This is not a BANNEDFUNC to
|
||||
# allow for individual enable/disable of this warning.
|
||||
if($l =~ /^(.*\W)(strncpy)\s*\(/x) {
|
||||
if($1 !~ /^ *\#/) {
|
||||
# skip preprocessor lines
|
||||
checkwarn("STRNCPY",
|
||||
$line, length($1), $file, $ol,
|
||||
"use of $2 is banned");
|
||||
}
|
||||
}
|
||||
}
|
||||
if($warnings{"STDERR"}) {
|
||||
# scan for use of banned stderr. This is not a BANNEDFUNC to
|
||||
# allow for individual enable/disable of this warning.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user