diff options
author | Tom Hughes <tomhughes@chromium.org> | 2022-06-24 14:33:32 -0700 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-07-07 18:43:57 +0000 |
commit | a32330b63cbf94c2314fc7bf62534ba4c7717e0d (patch) | |
tree | 4f84504efb057dfc1f22d0a4a88a680b2cf81610 /test/stdlib.c | |
parent | ff355e3dc31830f70b5ad603c5fce17e1ca012ce (diff) | |
download | chrome-ec-a32330b63cbf94c2314fc7bf62534ba4c7717e0d.tar.gz |
test/stdlib: Disable gcc stringop-truncation warning
gcc warns:
error: ‘__builtin_strncpy’ output truncated copying 10 bytes from a
string of length 12 [-Werror=stringop-truncation]
In this case the test is intentionally copying a subset of the string.
Also, since it's not obvious, add a note that when building this test
for the host we're actually testing the toolchain's C standard library,
not the EC "builtin" version.
BRANCH=none
BUG=b:234181908, b:237823627
TEST=./util/compare_build.sh -b all -j 120
=> MATCH
Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Change-Id: I943de03ae62d7ae5e431809305ae68100e6da418
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3724490
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Diffstat (limited to 'test/stdlib.c')
-rw-r--r-- | test/stdlib.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/test/stdlib.c b/test/stdlib.c index 4d9a4d6f87..cd018af09b 100644 --- a/test/stdlib.c +++ b/test/stdlib.c @@ -120,7 +120,15 @@ static int test_strncpy(void) TEST_ASSERT_ARRAY_EQ("test", dest, 5); strncpy(dest, "12345", 6); TEST_ASSERT_ARRAY_EQ("12345", dest, 6); + /* + * gcc complains: + * error: ‘__builtin_strncpy’ output truncated copying 10 bytes from a + * string of length 12 [-Werror=stringop-truncation] + */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-truncation" strncpy(dest, "testtesttest", 10); +#pragma GCC diagnostic pop TEST_ASSERT_ARRAY_EQ("testtestte", dest, 10); return EC_SUCCESS; |