mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 19:38:20 +00:00
refactor: Remove strncpy/STRNCPY. (#6008)
Closes #731 References #851 Note: This does not remove some intentional legacy usages of strncpy. - memcpy isn't equivalent because it doesn't check the string length of `src`, and doesn't zero-out the remainder of `dst`. - xstrlcpy isn't equivalent because it doesn't zero-out the remainder of `dst`. Some Vim logic depends on that (e.g. ex_append which calls vim_strnsave). Helped-by: Douglas Schneider <ds3@ualberta.ca> Helped-by: oni-link <knil.ino@gmail.com> Helped-by: James McCoy <jamessan@jamessan.com>
This commit is contained in:
11
src/clint.py
11
src/clint.py
@@ -3167,14 +3167,19 @@ def CheckLanguage(filename, clean_lines, linenum, file_extension,
|
||||
if Search(r'\bsprintf\b', line):
|
||||
error(filename, linenum, 'runtime/printf', 5,
|
||||
'Use snprintf instead of sprintf.')
|
||||
match = Search(r'\b(STRCPY|strcpy)\b', line)
|
||||
match = Search(r'\b(strncpy|STRNCPY)\b', line)
|
||||
if match:
|
||||
error(filename, linenum, 'runtime/printf', 4,
|
||||
'Use xstrlcpy or snprintf instead of %s (unless this is from Vim)'
|
||||
% match.group(1))
|
||||
match = Search(r'\b(strcpy)\b', line)
|
||||
if match:
|
||||
error(filename, linenum, 'runtime/printf', 4,
|
||||
'Use xstrlcpy or snprintf instead of %s' % match.group(1))
|
||||
match = Search(r'\b(STRNCAT|strncat)\b', line)
|
||||
match = Search(r'\b(STRNCAT|strncat|strcat)\b', line)
|
||||
if match:
|
||||
error(filename, linenum, 'runtime/printf', 4,
|
||||
'Use xstrlcat instead of %s' % match.group(1))
|
||||
'Use xstrlcat or snprintf instead of %s' % match.group(1))
|
||||
|
||||
# Check for suspicious usage of "if" like
|
||||
# } if (a == b) {
|
||||
|
Reference in New Issue
Block a user