summaryrefslogtreecommitdiff
path: root/samples
diff options
context:
space:
mode:
authorDavid Yang <davidcomponentone@gmail.com>2021-10-12 14:16:49 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-11-18 21:16:18 +0300
commit3d890ac58a855a5a92518e9f4b5f3b224bf2f1f1 (patch)
tree6456db7f53c368472baef52d2dbb8ea2820d6dc8 /samples
parent54718ee9b8eed43ab5e20df936a6e638416a4bcf (diff)
downloadlinux-3d890ac58a855a5a92518e9f4b5f3b224bf2f1f1.tar.xz
samples/bpf: Fix application of sizeof to pointer
[ Upstream commit b599015f044df53e93ad0a2957b615bc1a26bf73 ] The coccinelle check report: "./samples/bpf/xdp_redirect_cpu_user.c:397:32-38: ERROR: application of sizeof to pointer" Using the "strlen" to fix it. Reported-by: Zeal Robot <zealci@zte.com.cn> Signed-off-by: David Yang <davidcomponentone@gmail.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20211012111649.983253-1-davidcomponentone@gmail.com Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'samples')
-rw-r--r--samples/bpf/xdp_redirect_cpu_user.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/samples/bpf/xdp_redirect_cpu_user.c b/samples/bpf/xdp_redirect_cpu_user.c
index 6e25fba64c72..d84e6949007c 100644
--- a/samples/bpf/xdp_redirect_cpu_user.c
+++ b/samples/bpf/xdp_redirect_cpu_user.c
@@ -325,7 +325,6 @@ int main(int argc, char **argv)
int add_cpu = -1;
int ifindex = -1;
int *cpu, i, opt;
- char *ifname;
__u32 qsize;
int n_cpus;
@@ -393,9 +392,8 @@ int main(int argc, char **argv)
fprintf(stderr, "-d/--dev name too long\n");
goto end_cpu;
}
- ifname = (char *)&ifname_buf;
- safe_strncpy(ifname, optarg, sizeof(ifname));
- ifindex = if_nametoindex(ifname);
+ safe_strncpy(ifname_buf, optarg, strlen(ifname_buf));
+ ifindex = if_nametoindex(ifname_buf);
if (!ifindex)
ifindex = strtoul(optarg, NULL, 0);
if (!ifindex) {