[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAEf4BzYiNbJAW4TJjvQR0mfFGtBXrqyqgoM2TuwDqSJG18cA0Q@mail.gmail.com>
Date: Fri, 14 Jan 2022 17:29:43 -0800
From: Andrii Nakryiko <andrii.nakryiko@...il.com>
To: Jiapeng Chong <jiapeng.chong@...ux.alibaba.com>
Cc: Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
"David S. Miller" <davem@...emloft.net>,
Jakub Kicinski <kuba@...nel.org>,
Jesper Dangaard Brouer <hawk@...nel.org>,
john fastabend <john.fastabend@...il.com>,
Björn Töpel <bjorn@...nel.org>,
Magnus Karlsson <magnus.karlsson@...el.com>,
Jonathan Lemon <jonathan.lemon@...il.com>,
Andrii Nakryiko <andrii@...nel.org>, Martin Lau <kafai@...com>,
Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
KP Singh <kpsingh@...nel.org>,
Networking <netdev@...r.kernel.org>, bpf <bpf@...r.kernel.org>,
open list <linux-kernel@...r.kernel.org>,
Abaci Robot <abaci@...ux.alibaba.com>
Subject: Re: [PATCH] samples/bpf: xdpsock: Use swap() instead of open coding it
On Thu, Jan 13, 2022 at 8:22 AM Jiapeng Chong
<jiapeng.chong@...ux.alibaba.com> wrote:
>
> Clean the following coccicheck warning:
>
> ./samples/bpf/xdpsock_user.c:632:22-23: WARNING opportunity for swap().
>
> Reported-by: Abaci Robot <abaci@...ux.alibaba.com>
> Signed-off-by: Jiapeng Chong <jiapeng.chong@...ux.alibaba.com>
> ---
> samples/bpf/xdpsock_user.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/samples/bpf/xdpsock_user.c b/samples/bpf/xdpsock_user.c
> index aa50864e4415..30065c703c77 100644
> --- a/samples/bpf/xdpsock_user.c
> +++ b/samples/bpf/xdpsock_user.c
> @@ -626,11 +626,8 @@ static void swap_mac_addresses(void *data)
> struct ether_header *eth = (struct ether_header *)data;
> struct ether_addr *src_addr = (struct ether_addr *)ð->ether_shost;
> struct ether_addr *dst_addr = (struct ether_addr *)ð->ether_dhost;
> - struct ether_addr tmp;
>
> - tmp = *src_addr;
> - *src_addr = *dst_addr;
> - *dst_addr = tmp;
> + swap(*src_addr, *dst_addr);
Don't mindlessly apply any suggestion of any robot/script without at
least compile-testing:
/data/users/andriin/linux/samples/bpf/xdpsock_user.c: In function
‘swap_mac_addresses’:
/data/users/andriin/linux/samples/bpf/xdpsock_user.c:630:2: warning:
implicit declaration of function ‘swap’; did you mean ‘mmap’?
[-Wimplicit-function-declaration]
swap(*src_addr, *dst_addr);
^~~~
mmap
I think this exact change was accidentally applied recently and backed
out. Please stop sending such "improvements".
> }
>
> static void hex_dump(void *pkt, size_t length, u64 addr)
> --
> 2.20.1.7.g153144c
>
Powered by blists - more mailing lists