checkpatch: added check for memcpy calls

Added check for memcpy calls and warning that they should be
memcpy_s calls if possible.

Signed-off-by: Jakub Dabek <jakub.dabek@intel.com>
This commit is contained in:
Jakub Dabek 2019-05-14 13:38:47 +02:00 committed by Tomasz Lauda
parent 1d3b0ccfc3
commit db16f82c8c
1 changed files with 13 additions and 0 deletions

View File

@ -5683,6 +5683,19 @@ sub process {
} }
} }
# check for memcpy uses that should be memcpy_s
if ($line =~ /memcpy\s*\(.*/) {
my $fmt = get_quoted_string($line, $rawline);
$fmt =~ s/%%//g;
if ($fmt !~ /%/) {
if (WARN("PREFER_MEMCPY_S",
"Use safe version of memcpy - memcpy_s whenever possible\n" . $herecurr) &&
$fix) {
$fixed[$fixlinenr] =~ s/memcpy\b/memcpy_s/;
}
}
}
# check for vsprintf extension %p<foo> misuses # check for vsprintf extension %p<foo> misuses
if ($^V && $^V ge 5.10.0 && if ($^V && $^V ge 5.10.0 &&
defined $stat && defined $stat &&