Skip to contentSkip to conversation

libbpf: forward-declare bpf_stats_type for systems with outdated UAPI headers

PATCH Applied Andrii Nakryiko 3 participants 3 messages Jun 21, 2020 – Jun 22, 2020

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libbpf: forward-declare bpf_stats_type for systems with outdated UAPI headers

Systems that doesn't yet have the very latest linux/bpf.h header, enum bpf_stats_type will be undefined, causing compilation warnings. Prevents this by forward-declaring enum.

Fixes 0bee106716cf ("libbpf: Add support for command BPF_ENABLE_STATS")
---
 tools/lib/bpf/bpf.h | 2 ++
 1 file changed, 2 insertions(+)
tools/lib/bpf/bpf.h +2 -0
index 1b6015b21ba8..dbef24ebcfcb 100644
@@ -233,6 +233,8 @@ LIBBPF_API int bpf_load_btf(void *btf, __u32 btf_size, char *log_buf,
 LIBBPF_API int bpf_task_fd_query(int pid, int fd, __u32 flags, char *buf,
 				 __u32 *buf_len, __u32 *prog_id, __u32 *fd_type,
 				 __u64 *probe_offset, __u64 *probe_addr);
+
+enum bpf_stats_type; /* defined in up-to-date linux/bpf.h */
 LIBBPF_API int bpf_enable_stats(enum bpf_stats_type type);
 
 #ifdef __cplusplus
Signature · 1 line
2.24.1
reviewer Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · Andrii Nakryiko

Systems that doesn't yet have the very latest linux/bpf.h header, enum bpf_stats_type will be undefined, causing compilation warnings. Prevents this by forward-declaring enum.

Fixes 0bee106716cf ("libbpf: Add support for command BPF_ENABLE_STATS")

Thanks for the fix!

maintainer Applied
#2 lore raw
In reply to Andrii Nakryiko
Quoted 6 lines · Andrii Nakryiko

Systems that doesn't yet have the very latest linux/bpf.h header, enum bpf_stats_type will be undefined, causing compilation warnings. Prevents this by forward-declaring enum.

Fixes 0bee106716cf ("libbpf: Add support for command BPF_ENABLE_STATS")

Applied, thanks!