Commit 713461b8 authored by Andrii Nakryiko's avatar Andrii Nakryiko Committed by Alexei Starovoitov

selftests/bpf: add __sink() macro to fake variable consumption

Add __sink(expr) macro that forces compiler to believe that passed in
expression is both read and written. It used a simple embedded asm for
this. This is useful in a lot of tests where we assign value to some variable
to trigger some action, but later don't read variable, causing compiler
to complain (if corresponding compiler warnings are turned on, which
we'll do in the next patch).
Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/r/20230309054015.4068562-3-andrii@kernel.orgSigned-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent 2498e623
...@@ -76,6 +76,9 @@ ...@@ -76,6 +76,9 @@
#define FUNC_REG_ARG_CNT 5 #define FUNC_REG_ARG_CNT 5
#endif #endif
/* make it look to compiler like value is read and written */
#define __sink(expr) asm volatile("" : "+g"(expr))
struct bpf_iter_num; struct bpf_iter_num;
extern int bpf_iter_num_new(struct bpf_iter_num *it, int start, int end) __ksym; extern int bpf_iter_num_new(struct bpf_iter_num *it, int start, int end) __ksym;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment