From 0ea38c9a53dfcff17703ea22f701ed1cc5bbd7d3 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sat, 20 Apr 2024 19:31:00 +0800 Subject: refactor: add xmemcpyz() and use it in place of some xstrlcpy() (#28422) Problem: Using xstrlcpy() when the exact length of the string to be copied is known is not ideal because it requires adding 1 to the length and an unnecessary strlen(). Solution: Add xmemcpyz() and use it in place of such xstrlcpy() calls. --- src/clint.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/clint.py') diff --git a/src/clint.py b/src/clint.py index 9bca634171..41058469b1 100755 --- a/src/clint.py +++ b/src/clint.py @@ -1989,12 +1989,12 @@ def CheckLanguage(filename, clean_lines, linenum, error): 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)' + 'Use xstrlcpy, xmemcpyz 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)) + 'Use xstrlcpy, xmemcpyz or snprintf instead of %s' % match.group(1)) match = Search(r'\b(STRNCAT|strncat|strcat|vim_strcat)\b', line) if match: error(filename, linenum, 'runtime/printf', 4, -- cgit