# HG changeset patch # User Augie Fackler # Date 2016-03-20 00:18:38 # Node ID d3990da5163799db2b26b27956cb366c5a070d28 # Parent e60c492a0d9b00f9177a220cf3b812701b9f9af1 check-code: prevent use of strcpy diff --git a/contrib/check-code.py b/contrib/check-code.py --- a/contrib/check-code.py +++ b/contrib/check-code.py @@ -359,6 +359,7 @@ cpats = [ (r'^#\s+\w', "use #foo, not # foo"), (r'[^\n]\Z', "no trailing newline"), (r'^\s*#import\b', "use only #include in standard C code"), + (r'strcpy\(', "don't use strcpy, use strlcpy or memcpy"), ], # warnings [] diff --git a/tests/test-contrib-check-code.t b/tests/test-contrib-check-code.t --- a/tests/test-contrib-check-code.t +++ b/tests/test-contrib-check-code.t @@ -69,6 +69,22 @@ dict() is different in Py2 and 3 and is slower than {} [1] + $ cat > foo.c < void narf() { + > strcpy(foo, bar); + > // strcpy_s is okay, but this comment is not + > strcpy_s(foo, bar); + > } + > EOF + $ "$check_code" ./foo.c + ./foo.c:2: + > strcpy(foo, bar); + don't use strcpy, use strlcpy or memcpy + ./foo.c:3: + > // strcpy_s is okay, but this comment is not + don't use //-style comments + [1] + $ cat > is-op.py < # is-operator comparing number or string literal > x = None