AP_HAL: fix unit test compilation due to -Werror=format-truncation

This commit is contained in:
Peter Barker 2019-11-06 17:08:55 +11:00 committed by Peter Barker
parent b5d21a71ef
commit 3f9a4ee5f9

View File

@ -36,7 +36,10 @@ TEST(vsnprintf_Test, Basic)
} }
{ // ensure rest of buffer survives { // ensure rest of buffer survives
memset(output, 'A', 10); memset(output, 'A', 10);
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-truncation"
const int bytes_required = snprintf(output, 5, "012345678"); const int bytes_required = snprintf(output, 5, "012345678");
#pragma GCC diagnostic pop
EXPECT_TRUE(streq(output, "0123")); EXPECT_TRUE(streq(output, "0123"));
EXPECT_EQ(bytes_required, 9); EXPECT_EQ(bytes_required, 9);
EXPECT_EQ(output[6], 'A'); EXPECT_EQ(output[6], 'A');