[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220312171354.661448-1-ytcoode@gmail.com>
Date: Sun, 13 Mar 2022 01:13:54 +0800
From: Yuntao Wang <ytcoode@...il.com>
To: Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii@...nel.org>
Cc: Martin KaFai Lau <kafai@...com>, Song Liu <songliubraving@...com>,
Yonghong Song <yhs@...com>,
John Fastabend <john.fastabend@...il.com>,
KP Singh <kpsingh@...nel.org>, netdev@...r.kernel.org,
bpf@...r.kernel.org, linux-kernel@...r.kernel.org,
Yuntao Wang <ytcoode@...il.com>
Subject: [PATCH bpf-next] libbpf: Remove redundant check in btf_ext__new()
Since 'core_relo_len' is the last field of 'struct btf_ext_header', if
'xxx->hdr_len' is not less than 'offsetofend(xxx, core_relo_len)', then
'xxx->hdr_len' must also be not less than 'offsetofend(xxx, line_info_len)'.
We can check 'xxx->hdr_len < offsetofend(xxx, core_relo_len)' first, if it
passes, the 'xxx->hdr_len < offsetofend(xxx, line_info_len)' check will be
redundant, it can be removed.
Signed-off-by: Yuntao Wang <ytcoode@...il.com>
---
tools/lib/bpf/btf.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
index 1383e26c5d1f..d55b44124c3e 100644
--- a/tools/lib/bpf/btf.c
+++ b/tools/lib/bpf/btf.c
@@ -2813,7 +2813,7 @@ struct btf_ext *btf_ext__new(const __u8 *data, __u32 size)
if (err)
goto done;
- if (btf_ext->hdr->hdr_len < offsetofend(struct btf_ext_header, line_info_len)) {
+ if (btf_ext->hdr->hdr_len < offsetofend(struct btf_ext_header, core_relo_len)) {
err = -EINVAL;
goto done;
}
@@ -2826,11 +2826,6 @@ struct btf_ext *btf_ext__new(const __u8 *data, __u32 size)
if (err)
goto done;
- if (btf_ext->hdr->hdr_len < offsetofend(struct btf_ext_header, core_relo_len)) {
- err = -EINVAL;
- goto done;
- }
-
err = btf_ext_setup_core_relos(btf_ext);
if (err)
goto done;
--
2.35.1
Powered by blists - more mailing lists