1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-26 23:11:19 +01:00

tests/ssp: prevent that memset is optimized out

This commit is contained in:
Gunar Schorcht 2019-11-21 10:47:08 +01:00 committed by benpicco
parent 43d989b4d5
commit 74c0cc3878

View File

@ -24,6 +24,14 @@
#include <stdio.h>
#include <string.h>
__attribute__((weak)) void
_prevent_memset_lto(void *const s, int c, const size_t n)
{
(void) s;
(void) c;
(void) n;
}
void test_func(void)
{
char buf[16];
@ -35,6 +43,9 @@ void test_func(void)
/* cppcheck-suppress bufferAccessOutOfBounds
* (reason: deliberately overflowing stack) */
memset(buffer_to_confuse_compiler, 0, 32);
/* prevent that memset call is optimized out by LTO */
_prevent_memset_lto(buf, 0, 32);
}
int main(void)