summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2018-12-14 15:27:40 -0500
committerDave Barach <dave@barachs.net>2018-12-14 15:38:07 -0500
commitc5b6b3198069717f836807b57d01607c6711fb02 (patch)
treead6ccd1fb8d1c57ae7368803b37442148f325033 /src
parenta5e73762d585e9fa405b56ebd9f5c78d12c4d1f9 (diff)
Revert gerrit 16429 to fix a Debian build-break
Change-Id: I9382bc981c25a29c293f7ddc6ed3d34130678696 Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/unittest/string_test.c66
1 files changed, 44 insertions, 22 deletions
diff --git a/src/plugins/unittest/string_test.c b/src/plugins/unittest/string_test.c
index 51daeb481b8..65b7c62ece8 100644
--- a/src/plugins/unittest/string_test.c
+++ b/src/plugins/unittest/string_test.c
@@ -530,7 +530,6 @@ test_strcpy_s (vlib_main_t * vm, unformat_input_t * input)
{
char src[] = "To err is human.";
char dst[64];
- char *dst_alias = dst;
int indicator;
size_t s1size = sizeof (dst); // including null
errno_t err;
@@ -560,9 +559,12 @@ test_strcpy_s (vlib_main_t * vm, unformat_input_t * input)
return -1;
/* overlap fail */
- err = strcpy_s (dst, s1size, dst_alias);
+#if __GNUC__ < 8
+ /* GCC 8 flunks this one at compile time... */
+ err = strcpy_s (dst, s1size, dst);
if (err == EOK)
return -1;
+#endif
/* overlap fail */
err = strcpy_s (dst, s1size, dst + 1);
@@ -578,7 +580,6 @@ test_clib_strcpy (vlib_main_t * vm, unformat_input_t * input)
{
char src[] = "The journey of a one thousand miles begins with one step.";
char dst[100];
- char *dst_alias = dst;
int indicator;
errno_t err;
@@ -612,9 +613,12 @@ test_clib_strcpy (vlib_main_t * vm, unformat_input_t * input)
return -1;
/* overlap fail */
- err = clib_strcpy (dst, dst_alias);
+#if __GNUC__ < 8
+ /* GCC 8 flunks this one at compile time... */
+ err = clib_strcpy (dst, dst);
if (err == EOK)
return -1;
+#endif
/* overlap fail */
err = clib_strcpy (dst, dst + 1);
@@ -630,7 +634,6 @@ test_strncpy_s (vlib_main_t * vm, unformat_input_t * input)
{
char src[] = "Those who dare to fail miserably can achieve greatly.";
char dst[100], old_dst[100];
- char *dst_alias = dst;
int indicator;
size_t s1size = sizeof (dst); // including null
errno_t err;
@@ -709,9 +712,12 @@ test_strncpy_s (vlib_main_t * vm, unformat_input_t * input)
return -1;
/* overlap fail */
- err = strncpy_s (dst, s1size, dst_alias, s1size);
+#if __GNUC__ < 8
+ /* GCC 8 flunks this one at compile time... */
+ err = strncpy_s (dst, s1size, dst, s1size);
if (err == EOK)
return -1;
+#endif
/* OK, seems to work */
return 0;
@@ -722,7 +728,6 @@ test_clib_strncpy (vlib_main_t * vm, unformat_input_t * input)
{
char src[] = "Those who dare to fail miserably can achieve greatly.";
char dst[100], old_dst[100];
- char *dst_alias = dst;
int indicator;
size_t s1size = sizeof (dst); // including null
errno_t err;
@@ -763,12 +768,15 @@ test_clib_strncpy (vlib_main_t * vm, unformat_input_t * input)
/* verify it against strncpy */
memset_s (dst, sizeof (dst), 0, sizeof (dst));
+#if __GNUC__ < 8
+ /* GCC 8 flunks this one at compile time... */
strncpy (dst, "The price of greatness is responsibility.", 10);
if (strcmp_s (dst, clib_strnlen (dst, sizeof (dst)), "The price ",
&indicator) != EOK)
return -1;
if (indicator != 0)
return -1;
+#endif
/* n > string len of src */
err = clib_strncpy (dst, src, clib_strnlen (src, sizeof (src)) + 10);
@@ -806,14 +814,17 @@ test_clib_strncpy (vlib_main_t * vm, unformat_input_t * input)
return -1;
/* overlap fail */
- err = clib_strncpy (dst, dst + 1, s1size - 1);
+ err = clib_strncpy (dst, dst + 1, s1size);
if (err == EOK)
return -1;
/* overlap fail */
- err = clib_strncpy (dst, dst_alias, s1size);
+#if __GNUC__ < 8
+ /* GCC 8 flunks this one at compile time... */
+ err = clib_strncpy (dst, dst, s1size);
if (err == EOK)
return -1;
+#endif
/* OK, seems to work */
return 0;
@@ -823,7 +834,6 @@ static int
test_strcat_s (vlib_main_t * vm, unformat_input_t * input)
{
char src[100], dst[100], old_dst[100];
- char *dst_alias = dst;
size_t s1size = sizeof (dst); // including null
errno_t err;
int indicator;
@@ -864,9 +874,12 @@ test_strcat_s (vlib_main_t * vm, unformat_input_t * input)
return -1;
/* overlap fail */
- err = strcat_s (dst, s1size, dst_alias);
+#if __GNUC__ < 8
+ /* GCC 8 flunks this one at compile time... */
+ err = strcat_s (dst, s1size, dst);
if (err != EINVAL)
return -1;
+#endif
/* not enough space for dst */
err = strcat_s (dst, 10, src);
@@ -881,7 +894,6 @@ static int
test_clib_strcat (vlib_main_t * vm, unformat_input_t * input)
{
char src[100], dst[100], old_dst[100];
- char *dst_alias = dst;
size_t s1size = sizeof (dst); // including null
errno_t err;
int indicator;
@@ -932,9 +944,12 @@ test_clib_strcat (vlib_main_t * vm, unformat_input_t * input)
return -1;
/* overlap fail */
- err = clib_strcat (dst, dst_alias);
+#if __GNUC__ < 8
+ /* GCC 8 flunks this one at compile time... */
+ err = clib_strcat (dst, dst);
if (err != EINVAL)
return -1;
+#endif
/* OK, seems to work */
return 0;
@@ -944,7 +959,6 @@ static int
test_strncat_s (vlib_main_t * vm, unformat_input_t * input)
{
char src[100], dst[100], old_dst[100];
- char *dst_alias = dst;
size_t s1size = sizeof (dst); // including null
errno_t err;
char s1[] = "Two things are infinite: ";
@@ -1054,9 +1068,12 @@ test_strncat_s (vlib_main_t * vm, unformat_input_t * input)
return -1;
/* overlap fail */
- err = strncat_s (dst, s1size, dst_alias, clib_strnlen (dst, sizeof (dst)));
+#if __GNUC__ < 8
+ /* GCC 8 flunks this one at compile time... */
+ err = strncat_s (dst, s1size, dst, clib_strnlen (dst, sizeof (dst)));
if (err != EINVAL)
return -1;
+#endif
/* OK, seems to work */
return 0;
@@ -1066,7 +1083,6 @@ static int
test_clib_strncat (vlib_main_t * vm, unformat_input_t * input)
{
char src[100], dst[100], old_dst[100];
- char *dst_alias = dst;
size_t s1size = sizeof (dst); // including null
errno_t err;
char s1[] = "Two things are infinite: ";
@@ -1169,9 +1185,12 @@ test_clib_strncat (vlib_main_t * vm, unformat_input_t * input)
return -1;
/* overlap fail */
- err = clib_strncat (dst, dst_alias, clib_strnlen (dst, sizeof (dst)));
+#if __GNUC__ < 8
+ /* GCC 8 flunks this one at compile time... */
+ err = clib_strncat (dst, dst, clib_strnlen (dst, sizeof (dst)));
if (err != EINVAL)
return -1;
+#endif
/* OK, seems to work */
return 0;
@@ -1275,7 +1294,9 @@ static int
test_clib_strtok (vlib_main_t * vm, unformat_input_t * input)
{
int indicator;
- char *s1, *s1_alias, *tok, *ptr;
+ char *s1 __attribute__ ((unused));
+ char *tok __attribute__ ((unused));
+ char *ptr __attribute__ ((unused));
char str1[40];
char *p2str;
char *tok1, *tok2, *tok3, *tok4, *tok5, *tok6, *tok7;
@@ -1377,16 +1398,17 @@ test_clib_strtok (vlib_main_t * vm, unformat_input_t * input)
/* negative stuff */
s1 = 0;
ptr = 0;
- s1_alias = s1;
- tok = clib_strtok (s1, s1_alias, (char **) 0);
+#if __GNUC__ < 8
+ /* GCC 8 flunks this one at compile time... */
+ tok = clib_strtok (s1, s1, (char **) 0);
if (tok != 0)
return -1;
/* s1 and ptr contents are null */
- s1_alias = s1;
- tok = clib_strtok (s1, s1_alias, &ptr);
+ tok = clib_strtok (s1, s1, &ptr);
if (tok != 0)
return -1;
+#endif
/* verify it against strtok_r */
/* No can do. This causes a crash in strtok_r */