lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190906073144.31068-2-jolsa@kernel.org>
Date:   Fri,  6 Sep 2019 09:31:38 +0200
From:   Jiri Olsa <jolsa@...nel.org>
To:     Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>
Cc:     netdev@...r.kernel.org, bpf@...r.kernel.org,
        Andrii Nakryiko <andriin@...com>, Yonghong Song <yhs@...com>,
        Martin KaFai Lau <kafai@...com>
Subject: [PATCH 1/7] libbpf: Use const cast for btf_int_* functions

I'm getting following errors when compiling with -Wcast-qual:

  bpf/btf.h: In function ‘__u8 btf_int_offset(const btf_type*)’:
  bpf/btf.h:244:40: warning: cast from type ‘const btf_type*’ to type
  ‘__u32*’ {aka ‘unsigned int*’} casts away qualifiers [-Wcast-qual]
    244 |  return BTF_INT_OFFSET(*(__u32 *)(t + 1));
        |                                        ^

The argument is const so the cast to following __u32
pointer should be const as well.

Signed-off-by: Jiri Olsa <jolsa@...nel.org>
---
 tools/lib/bpf/btf.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/lib/bpf/btf.h b/tools/lib/bpf/btf.h
index 9cb44b4fbf60..952e3496467d 100644
--- a/tools/lib/bpf/btf.h
+++ b/tools/lib/bpf/btf.h
@@ -236,17 +236,17 @@ static inline bool btf_is_datasec(const struct btf_type *t)
 
 static inline __u8 btf_int_encoding(const struct btf_type *t)
 {
-	return BTF_INT_ENCODING(*(__u32 *)(t + 1));
+	return BTF_INT_ENCODING(*(const __u32 *)(t + 1));
 }
 
 static inline __u8 btf_int_offset(const struct btf_type *t)
 {
-	return BTF_INT_OFFSET(*(__u32 *)(t + 1));
+	return BTF_INT_OFFSET(*(const __u32 *)(t + 1));
 }
 
 static inline __u8 btf_int_bits(const struct btf_type *t)
 {
-	return BTF_INT_BITS(*(__u32 *)(t + 1));
+	return BTF_INT_BITS(*(const __u32 *)(t + 1));
 }
 
 static inline struct btf_array *btf_array(const struct btf_type *t)
-- 
2.21.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ