diff options
author | Oliver Smith <osmith@sysmocom.de> | 2021-09-15 10:59:14 +0200 |
---|---|---|
committer | Oliver Smith <osmith@sysmocom.de> | 2021-09-15 11:08:40 +0200 |
commit | cbc58a68740333a6dcf75a2a948a1f48707cd4ce (patch) | |
tree | f03a07de839a43f2265ddc3ab031042639621396 | |
parent | 654cfb319262e44eb3c4e7625aa13b2cb279c9f3 (diff) |
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
-rwxr-xr-x | lint/checkpatch/checkpatch.pl | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lint/checkpatch/checkpatch.pl b/lint/checkpatch/checkpatch.pl index 059a2a6..06e6e36 100755 --- a/lint/checkpatch/checkpatch.pl +++ b/lint/checkpatch/checkpatch.pl @@ -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; |