Commit b599015f authored by David Yang's avatar David Yang Committed by Andrii Nakryiko

samples/bpf: Fix application of sizeof to pointer

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: default avatarZeal Robot <zealci@zte.com.cn>
Signed-off-by: default avatarDavid Yang <davidcomponentone@gmail.com>
Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20211012111649.983253-1-davidcomponentone@gmail.com
parent efc36d6c
...@@ -325,7 +325,6 @@ int main(int argc, char **argv) ...@@ -325,7 +325,6 @@ int main(int argc, char **argv)
int add_cpu = -1; int add_cpu = -1;
int ifindex = -1; int ifindex = -1;
int *cpu, i, opt; int *cpu, i, opt;
char *ifname;
__u32 qsize; __u32 qsize;
int n_cpus; int n_cpus;
...@@ -393,9 +392,8 @@ int main(int argc, char **argv) ...@@ -393,9 +392,8 @@ int main(int argc, char **argv)
fprintf(stderr, "-d/--dev name too long\n"); fprintf(stderr, "-d/--dev name too long\n");
goto end_cpu; goto end_cpu;
} }
ifname = (char *)&ifname_buf; safe_strncpy(ifname_buf, optarg, strlen(ifname_buf));
safe_strncpy(ifname, optarg, sizeof(ifname)); ifindex = if_nametoindex(ifname_buf);
ifindex = if_nametoindex(ifname);
if (!ifindex) if (!ifindex)
ifindex = strtoul(optarg, NULL, 0); ifindex = strtoul(optarg, NULL, 0);
if (!ifindex) { if (!ifindex) {
......
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