I'm getting following errors when compiling with -Wcast-qual:
bpf/btf.h: In function ‘btf_var* btf_var(const btf_type*)’:
bpf/btf.h:296:33: warning: cast from type ‘const btf_type*’ to type
‘btf_var*’ casts away qualifiers [-Wcast-qual]
296 | return (struct btf_var *)(t + 1);
| ^
The argument is const so the cast to following struct btf_var
pointer should be const as well.
Signed-off-by: Jiri Olsa <[email protected]>
---
tools/lib/bpf/btf.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/lib/bpf/btf.h b/tools/lib/bpf/btf.h
index 2817cf7ce2ee..480dbe780fa7 100644
--- a/tools/lib/bpf/btf.h
+++ b/tools/lib/bpf/btf.h
@@ -291,9 +291,9 @@ static inline const struct btf_param *btf_params(const
struct btf_type *t)
return (const struct btf_param *)(t + 1);
}
-static inline struct btf_var *btf_var(const struct btf_type *t)
+static inline const struct btf_var *btf_var(const struct btf_type *t)
{
- return (struct btf_var *)(t + 1);
+ return (const struct btf_var *)(t + 1);
}
static inline struct btf_var_secinfo *
--
2.21.0