Commit 11e17ae4 authored by Jiapeng Chong's avatar Jiapeng Chong Committed by Daniel Borkmann

bpf: Use swap() instead of open coding it

Clean the following coccicheck warning:

./kernel/trace/bpf_trace.c:2263:34-35: WARNING opportunity for swap().
./kernel/trace/bpf_trace.c:2264:40-41: WARNING opportunity for swap().
Reported-by: default avatarAbaci Robot <abaci@linux.alibaba.com>
Signed-off-by: default avatarJiapeng Chong <jiapeng.chong@linux.alibaba.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20220322062149.109180-1-jiapeng.chong@linux.alibaba.com
parent 38608ee7
...@@ -2254,15 +2254,13 @@ static void bpf_kprobe_multi_cookie_swap(void *a, void *b, int size, const void ...@@ -2254,15 +2254,13 @@ static void bpf_kprobe_multi_cookie_swap(void *a, void *b, int size, const void
const struct bpf_kprobe_multi_link *link = priv; const struct bpf_kprobe_multi_link *link = priv;
unsigned long *addr_a = a, *addr_b = b; unsigned long *addr_a = a, *addr_b = b;
u64 *cookie_a, *cookie_b; u64 *cookie_a, *cookie_b;
unsigned long tmp1;
u64 tmp2;
cookie_a = link->cookies + (addr_a - link->addrs); cookie_a = link->cookies + (addr_a - link->addrs);
cookie_b = link->cookies + (addr_b - link->addrs); cookie_b = link->cookies + (addr_b - link->addrs);
/* swap addr_a/addr_b and cookie_a/cookie_b values */ /* swap addr_a/addr_b and cookie_a/cookie_b values */
tmp1 = *addr_a; *addr_a = *addr_b; *addr_b = tmp1; swap(*addr_a, *addr_b);
tmp2 = *cookie_a; *cookie_a = *cookie_b; *cookie_b = tmp2; swap(*cookie_a, *cookie_b);
} }
static int __bpf_kprobe_multi_cookie_cmp(const void *a, const void *b) static int __bpf_kprobe_multi_cookie_cmp(const void *a, const void *b)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment