aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_string.py
diff options
context:
space:
mode:
authorSteven Luong <sluong@cisco.com>2021-11-03 15:33:21 -0700
committerDamjan Marion <dmarion@me.com>2021-11-05 19:20:10 +0000
commit51ddd38deb5866b10bbe9712ba6e8c4fb6da6381 (patch)
tree5a326543ec4cc0e4f8b72c19c0853303ada7bef4 /test/test_string.py
parent6259406668cee37d39ef3eb0b17ee5dc94ff02fe (diff)
unittest: gcc-11 errors for clib_strcpy, clib_strstr, clib_strcat, and clib_strncat
There are 3 versions of the string functions. For example, for strcpy, they are 1. strcpy(dst, src) -- the legacy unsafe version 2. strcpy_s(dst, dmax, src) -- C11 safeC version which has an addition argument named dmax. 3. clib_strcpy(dst,src) -- clib version to enable legacy code that uses strcpy to make use of strcpy_s without adding the additional argument, dmax, which is required by the C11 safeC version. The implementation for the clib version is to artificially provide dmax to strcpy_s. In this case, it uses 4096 which assumes that if the legacy code works without blowing up, it is likely to work with the clib version without problem. gcc-11 is getting smarter by checking if dmax is within the object's boundary. When the object is declared as static array, it will flag a warning/error if dmax is out of bound for the object since the real size of dst can be determined at compile time. There is no way to find the real size of dst if the object is dynamically allocated at compile time. For this reason, we simply can't provide support for the clib version of the function anymore. If any code is using the clib version, the choice is to migrate to the safeC version. Type: fix Fixes: b0598497afde60146fe8480331c9f96e7a79475a Signed-off-by: Steven Luong <sluong@cisco.com> Change-Id: I99fa59c878331f995b734588cca3906a1d4782f5
Diffstat (limited to 'test/test_string.py')
-rw-r--r--test/test_string.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/test/test_string.py b/test/test_string.py
index 51c6a141402..c599cf1d3b8 100644
--- a/test/test_string.py
+++ b/test/test_string.py
@@ -27,9 +27,8 @@ class TestString(VppTestCase):
""" String unit tests """
names = ["memcpy_s",
"clib_memcmp", "clib_memcpy", "clib_memset",
- "clib_strcat", "clib_strcmp", "clib_strcpy",
- "clib_strncat", "clib_strncmp", "clib_strncpy",
- "clib_strnlen", "clib_strstr", "clib_strtok",
+ "clib_strcmp", "clib_strncmp", "clib_strncpy",
+ "clib_strnlen", "clib_strtok",
"memcmp_s", "memcpy_s", "memset_s ",
"strcat_s", "strcmp_s", "strcpy_s",
"strncat_s", "strncmp_s", "strncpy_s",
@@ -41,5 +40,6 @@ class TestString(VppTestCase):
self.logger.critical("FAILURE in the " + name + " test")
self.assertNotIn("failed", error)
+
if __name__ == '__main__':
unittest.main(testRunner=VppTestRunner)