diff mbox series

[6/7] libbpf: Return const btf_var from btf_var inline function

Message ID 20190906073144.31068-7-jolsa@kernel.org
State Rejected
Delegated to: BPF Maintainers
Headers show
Series libbpf: Fix cast away const qualifiers in btf.h | expand

Commit Message

Jiri Olsa Sept. 6, 2019, 7:31 a.m. UTC
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 <jolsa@kernel.org>
 tools/lib/bpf/btf.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series


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 *