Skip to content

Commit

Permalink
AP_HAL: fix ringbuffer test on clang.
Browse files Browse the repository at this point in the history
../../libraries/AP_HAL/utility/tests/test_ringbuffer.cpp:46:17: fatal error: variable-sized object may not be initialized
    uint8_t buf[strlen(str)+5] {};
  • Loading branch information
khancyr authored and peterbarker committed Sep 4, 2021
1 parent 8d5a0d8 commit 2b44f86
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions libraries/AP_HAL/utility/tests/test_ringbuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@ TEST(ByteBufferTest, Basic)
EXPECT_EQ(x.space(), unsigned(size-1));
EXPECT_TRUE(x.is_empty());

static const char *str = "fo";
constexpr auto str_size = 3;
static const char str[str_size] = "fo";
EXPECT_EQ(x.write((uint8_t*)str, 2), 2U);
uint8_t buf[strlen(str)+5] {};
uint8_t buf[str_size+5] {};
EXPECT_EQ(x.read(buf, sizeof(buf)), 2U);
EXPECT_STREQ((char*)buf, (char*)str);
}
Expand Down

0 comments on commit 2b44f86

Please sign in to comment.