The uninit struct timespec can have large values so set it to 0
and use VALGRIND_MAKE_MEM_UNDEFINED to trigger the error.
-
+#include "../../memcheck.h"
#include <time.h>
/* should complain about rqtp and rmtp */
void valgrind_should_complain(void)
{
- struct timespec ts_uninitialized;
+ struct timespec ts_uninitialized = {0};
+
+ VALGRIND_MAKE_MEM_UNDEFINED(&ts_uninitialized, sizeof(ts_uninitialized));
clock_nanosleep(CLOCK_MONOTONIC, 0, &ts_uninitialized, &ts_uninitialized);
}
Syscall param clock_nanosleep(rqtp) points to uninitialised byte(s)
...
- by 0x........: valgrind_should_complain (bug483786.c:9)
- by 0x........: main (bug483786.c:32)
+ by 0x........: valgrind_should_complain (bug483786.c:11)
+ by 0x........: main (bug483786.c:34)
Address 0x........ is on thread 1's stack
in frame #1, created by valgrind_should_complain (bug483786.c:6)