From: Cong Wang <xiyou.wangcong@gmail.com>
To: guanjing <guanjing@cmss.chinamobile.com>
Cc: andrii@kernel.org, eddyz87@gmail.com, mykolal@fb.com,
ast@kernel.org, daniel@iogearbox.net, martin.lau@linux.dev,
song@kernel.org, yonghong.song@linux.dev,
john.fastabend@gmail.com, kpsingh@kernel.org, sdf@fomichev.me,
haoluo@google.com, jolsa@kernel.org, shuah@kernel.org,
dxu@dxuuu.xyz, antony.antony@secunet.com,
cupertino.miranda@oracle.com, asavkov@redhat.com,
bpf@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1] selftests/bpf: fix application of sizeof to pointer
Date: Mon, 18 Nov 2024 19:37:19 -0800 [thread overview]
Message-ID: <ZzwH77QE/Ch9+evD@pop-os.localdomain> (raw)
In-Reply-To: <20241117031838.161576-1-guanjing@cmss.chinamobile.com>
On Sun, Nov 17, 2024 at 11:18:38AM +0800, guanjing wrote:
> sizeof when applied to a pointer typed expression gives the size of
> the pointer.
>
> tools/testing/selftests/bpf/progs/test_tunnel_kern.c:678:41-47: ERROR: application of sizeof to pointer
>
> The proper fix in this particular case is to code sizeof(*gopt)
> instead of sizeof(gopt).
>
> This issue was detected with the help of Coccinelle.
>
> Fixes: 5ddafcc377f9 ("selftests/bpf: Fix a few tests for GCC related warnings.")
> Signed-off-by: guanjing <guanjing@cmss.chinamobile.com>
> ---
> tools/testing/selftests/bpf/progs/test_tunnel_kern.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/bpf/progs/test_tunnel_kern.c b/tools/testing/selftests/bpf/progs/test_tunnel_kern.c
> index 32127f1cd687..3a437cdc5c15 100644
> --- a/tools/testing/selftests/bpf/progs/test_tunnel_kern.c
> +++ b/tools/testing/selftests/bpf/progs/test_tunnel_kern.c
> @@ -675,7 +675,7 @@ int ip6geneve_set_tunnel(struct __sk_buff *skb)
> gopt->length = 2; /* 4-byte multiple */
> *(int *) &gopt->opt_data = bpf_htonl(0xfeedbeef);
>
> - ret = bpf_skb_set_tunnel_opt(skb, gopt, sizeof(gopt));
> + ret = bpf_skb_set_tunnel_opt(skb, gopt, sizeof(*gopt));
Good catch!
I think sizeof(local_gopt) is better, to align with geneve_set_tunnel(),
what do you think?
Thanks.
prev parent reply other threads:[~2024-11-19 3:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-17 3:18 guanjing
2024-11-19 3:37 ` Cong Wang [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZzwH77QE/Ch9+evD@pop-os.localdomain \
--to=xiyou.wangcong@gmail.com \
--cc=andrii@kernel.org \
--cc=antony.antony@secunet.com \
--cc=asavkov@redhat.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=cupertino.miranda@oracle.com \
--cc=daniel@iogearbox.net \
--cc=dxu@dxuuu.xyz \
--cc=eddyz87@gmail.com \
--cc=guanjing@cmss.chinamobile.com \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=mykolal@fb.com \
--cc=sdf@fomichev.me \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®