lint: checkpatch.pl: add STRCPY_OSMO

Add Osmocom specific check to forbid using strncpy() and strcpy().
Instead, osmo_strlcpy() or OSMO_STRLCPY_ARRAY() should be used.

Related: OS#5087
Related: https://lists.osmocom.org/pipermail/openbsc/2021-September/013538.html
Change-Id: I6fa96c8f3d15110dd3d3509faa593285a78f469e
This commit is contained in:
Oliver Smith 2021-09-15 10:59:14 +02:00
parent 654cfb3192
commit cbc58a6874
1 changed files with 7 additions and 0 deletions

View File

@ -7201,6 +7201,13 @@ sub process {
"Where possible, use lockdep_assert_held instead of assertions based on spin_is_locked\n" . $herecurr);
}
# Osmocom specific: check for strncpy(), strcpy()
# https://lists.osmocom.org/pipermail/openbsc/2021-September/013538.html
if ($line =~ /\bstr(n)?cpy\(/) {
ERROR("STRCPY_OSMO",
"Instead of strncpy()/strcpy(), use osmo_strlcpy() or OSMO_STRLCPY_ARRAY()\n" . $herecurr);
}
# check for deprecated apis
if ($line =~ /\b($deprecated_apis_search)\b\s*\(/) {
my $deprecated_api = $1;