summaryrefslogtreecommitdiff
path: root/test-str.c
diff options
context:
space:
mode:
authorPeter Jones <pjones@redhat.com>2021-03-21 15:57:03 -0400
committerPeter Jones <pjones@redhat.com>2021-03-22 16:43:44 -0400
commit33db42def2ce6fe040b5f77642347e8b3c6420e5 (patch)
tree1cb9857acb523d9d5e2be6222328a38a5d4b1e74 /test-str.c
parentd4494b5cff75b64a70cb27b2d8544b4debb7fa6b (diff)
downloadefi-boot-shim-33db42def2ce6fe040b5f77642347e8b3c6420e5.tar.gz
efi-boot-shim-33db42def2ce6fe040b5f77642347e8b3c6420e5.zip
Make 'make test' work on gcc 4.8.5
Diffstat (limited to 'test-str.c')
-rw-r--r--test-str.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/test-str.c b/test-str.c
index 87605b26..70d1637c 100644
--- a/test-str.c
+++ b/test-str.c
@@ -6,6 +6,8 @@
#pragma GCC diagnostic error "-Wnonnull"
#pragma GCC diagnostic error "-Wunused-function"
+#pragma GCC diagnostic warning "-Wcpp"
+
#ifndef SHIM_UNIT_TEST
#define SHIM_UNIT_TEST
#endif
@@ -1046,8 +1048,29 @@ test_strcat(void)
memset(s1, 0, 4096);
assert_equal_return(strcat(s1, s0), s1, -1, "got %p expected %p\n");
+ /* For unknown reasons, gcc 4.8.5 gives us this here:
+ * | In file included from shim.h:64:0,
+ * | from test-str.c:14:
+ * | test-str.c: In function 'test_strcat':
+ * | include/test.h:85:10: warning: array subscript is below array bounds [-Warray-bounds]
+ * | printf("%s:%d:got %lld, expected zero " fmt, __func__, \
+ * | ^
+ * | include/test.h:112:10: warning: array subscript is below array bounds [-Warray-bounds]
+ * | printf("%s:%d:got %lld, expected < 0 " fmt, __func__, \
+ * | ^
+ *
+ * This clearly isn't a useful error message, as it doesn't tell us
+ * /anything about the problem/, but also it isn't reported on
+ * later compilers, and it isn't clear that there's any problem
+ * when examining these functions.
+ *
+ * I don't know.
+ */
+#pragma GCC diagnostic push
+#pragma GCC diagnostic warning "-Warray-bounds"
assert_zero_return(strncmp(s1, s0, sizeof(s)-1), 0, -1, "\n");
assert_negative_return(memcmp(s1, s0, sizeof(s)), 0, -1, "\n");
+#pragma GCC diagnostic pop
memset(s1, 0, 4096);
assert_equal_return(strcat(s1, s0), s1, -1, "got %p expected %p\n");