aboutsummaryrefslogtreecommitdiffstats
path: root/executor/common_test.h
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2019-03-21 13:17:23 +0100
committerDmitry Vyukov <dvyukov@google.com>2019-03-21 13:27:41 +0100
commit44270612b458144e4c3e881bac376d32bb395ee8 (patch)
tree9dee8506297bc249f11073feebfad12b2e0f2fea /executor/common_test.h
parent2dadc32780468044e81e77814e1f1969373f9c69 (diff)
executor: prevent non-null expected warnings
The added test triggers warnings like these: <stdin>: In function ‘syz_mount_image.constprop’: <stdin>:298:3: error: argument 1 null where non-null expected [-Werror=nonnull] In file included from <stdin>:26:0: /usr/include/x86_64-linux-gnu/sys/stat.h:320:12: note: in a call to function ‘mkdir’ declared here extern int mkdir (const char *__path, __mode_t __mode) ^~~~~ cc1: all warnings being treated as errors <stdin>: In function ‘syz_open_procfs.constprop’: <stdin>:530:41: error: ‘%s’ directive argument is null [-Werror=format-truncation=] <stdin>:85:110: note: in definition of macro ‘NONFAILING’ <stdin>:532:41: error: ‘%s’ directive argument is null [-Werror=format-truncation=] <stdin>:85:110: note: in definition of macro ‘NONFAILING’ <stdin>:534:41: error: ‘%s’ directive argument is null [-Werror=format-truncation=] <stdin>:85:110: note: in definition of macro ‘NONFAILING’ Use volatile for all arguments of syz_ functions to prevent compiler from treating the arguments as constants in reproducers. Popped up during bisection that used a repro that previously worked. Update #501
Diffstat (limited to 'executor/common_test.h')
-rw-r--r--executor/common_test.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/executor/common_test.h b/executor/common_test.h
index 826d2c8d8..428ea2ce1 100644
--- a/executor/common_test.h
+++ b/executor/common_test.h
@@ -10,7 +10,7 @@
#include <sys/mman.h>
// syz_mmap(addr vma, len len[addr])
-static long syz_mmap(long a0, long a1)
+static long syz_mmap(volatile long a0, volatile long a1)
{
return (long)mmap((void*)a0, a1, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE | MAP_FIXED, -1, 0);
}
@@ -20,7 +20,7 @@ static long syz_mmap(long a0, long a1)
#include <errno.h>
// syz_errno(v int32)
-static long syz_errno(long v)
+static long syz_errno(volatile long v)
{
errno = v;
return v == 0 ? 0 : -1;
@@ -29,7 +29,7 @@ static long syz_errno(long v)
#if SYZ_EXECUTOR || __NR_syz_exit
// syz_exit(status int32)
-static long syz_exit(long status)
+static long syz_exit(volatile long status)
{
_exit(status);
return 0;
@@ -41,7 +41,7 @@ static long syz_exit(long status)
#include <string.h>
// syz_compare(want ptr[in, string], want_len len[want], got ptr[in, compare_data], got_len len[got])
-static long syz_compare(long want, long want_len, long got, long got_len)
+static long syz_compare(volatile long want, volatile long want_len, volatile long got, volatile long got_len)
{
if (want_len != got_len) {
debug("syz_compare: want_len=%lu got_len=%lu\n", want_len, got_len);
@@ -65,7 +65,7 @@ static long syz_compare(long want, long want_len, long got, long got_len)
#include <stdarg.h>
// syz_compare_int$4(n const[2], v0 intptr, v1 intptr, v2 intptr, v3 intptr)
-static long syz_compare_int(long n, ...)
+static long syz_compare_int(volatile long n, ...)
{
va_list args;
va_start(args, n);