Commit bd9bedf8 authored by Andrii Nakryiko's avatar Andrii Nakryiko Committed by Alexei Starovoitov

libbpf: Wrap source argument of BPF_CORE_READ macro in parentheses

Wrap source argument of BPF_CORE_READ family of macros into parentheses to
allow uses like this:

BPF_CORE_READ((struct cast_struct *)src, a, b, c);

Fixes: 7db3822a ("libbpf: Add BPF_CORE_READ/BPF_CORE_READ_INTO helpers")
Signed-off-by: default avatarAndrii Nakryiko <andriin@fb.com>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200619231703.738941-8-andriin@fb.com
parent 05aca6da
...@@ -217,7 +217,7 @@ enum bpf_field_info_kind { ...@@ -217,7 +217,7 @@ enum bpf_field_info_kind {
*/ */
#define BPF_CORE_READ_INTO(dst, src, a, ...) \ #define BPF_CORE_READ_INTO(dst, src, a, ...) \
({ \ ({ \
___core_read(bpf_core_read, dst, src, a, ##__VA_ARGS__) \ ___core_read(bpf_core_read, dst, (src), a, ##__VA_ARGS__) \
}) })
/* /*
...@@ -227,7 +227,7 @@ enum bpf_field_info_kind { ...@@ -227,7 +227,7 @@ enum bpf_field_info_kind {
*/ */
#define BPF_CORE_READ_STR_INTO(dst, src, a, ...) \ #define BPF_CORE_READ_STR_INTO(dst, src, a, ...) \
({ \ ({ \
___core_read(bpf_core_read_str, dst, src, a, ##__VA_ARGS__) \ ___core_read(bpf_core_read_str, dst, (src), a, ##__VA_ARGS__)\
}) })
/* /*
...@@ -254,8 +254,8 @@ enum bpf_field_info_kind { ...@@ -254,8 +254,8 @@ enum bpf_field_info_kind {
*/ */
#define BPF_CORE_READ(src, a, ...) \ #define BPF_CORE_READ(src, a, ...) \
({ \ ({ \
___type(src, a, ##__VA_ARGS__) __r; \ ___type((src), a, ##__VA_ARGS__) __r; \
BPF_CORE_READ_INTO(&__r, src, a, ##__VA_ARGS__); \ BPF_CORE_READ_INTO(&__r, (src), a, ##__VA_ARGS__); \
__r; \ __r; \
}) })
......
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