Skip to content

Commit 20360ce

Browse files
RobinKastbergkartben
authored andcommitted
tests: kernel: Don't use VLA in pipe_api test.
In the current pipe_api test file we inadvertantly use VLA. Toolchains are allowed by standard to allocate VLA on heap for example. Therefore in my opinion we shouldn't use VLA atleast in kernel+kernel tests. Signed-off-by: Robin Kastberg <[email protected]>
1 parent 28e188b commit 20360ce

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

tests/kernel/pipe/pipe_api/src/stress.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
#include <zephyr/random/random.h>
1212
#include <zephyr/timing/timing.h>
1313

14+
#define WRITE_LEN 512
15+
#define READ_LEN 512
16+
1417
LOG_MODULE_REGISTER(k_k_pipe_stress, LOG_LEVEL_INF);
1518

1619
ZTEST_SUITE(k_pipe_stress, NULL, NULL, NULL, NULL, NULL);
@@ -19,9 +22,9 @@ ZTEST(k_pipe_stress, test_write)
1922
{
2023
int rc;
2124
struct k_pipe pipe;
22-
size_t len = 512;
23-
uint8_t buffer[len];
24-
uint8_t buf[len];
25+
const size_t len = WRITE_LEN;
26+
uint8_t buffer[WRITE_LEN];
27+
uint8_t buf[WRITE_LEN];
2528
size_t sent;
2629
uint32_t start_cycles, end_cycles;
2730

@@ -41,9 +44,9 @@ ZTEST(k_pipe_stress, test_read)
4144
{
4245
int rc;
4346
struct k_pipe pipe;
44-
size_t len = 512;
45-
uint8_t buffer[len];
46-
uint8_t buf[len];
47+
const size_t len = READ_LEN;
48+
uint8_t buffer[READ_LEN];
49+
uint8_t buf[READ_LEN];
4750
size_t sent, read;
4851
uint32_t start_cycles, end_cycles;
4952

0 commit comments

Comments
 (0)