Skip to content

Commit b599015

Browse files
David Yanganakryiko
David Yang
authored andcommitted
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: Zeal Robot <[email protected]> Signed-off-by: David Yang <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent efc36d6 commit b599015

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

samples/bpf/xdp_redirect_cpu_user.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,6 @@ int main(int argc, char **argv)
325325
int add_cpu = -1;
326326
int ifindex = -1;
327327
int *cpu, i, opt;
328-
char *ifname;
329328
__u32 qsize;
330329
int n_cpus;
331330

@@ -393,9 +392,8 @@ int main(int argc, char **argv)
393392
fprintf(stderr, "-d/--dev name too long\n");
394393
goto end_cpu;
395394
}
396-
ifname = (char *)&ifname_buf;
397-
safe_strncpy(ifname, optarg, sizeof(ifname));
398-
ifindex = if_nametoindex(ifname);
395+
safe_strncpy(ifname_buf, optarg, strlen(ifname_buf));
396+
ifindex = if_nametoindex(ifname_buf);
399397
if (!ifindex)
400398
ifindex = strtoul(optarg, NULL, 0);
401399
if (!ifindex) {

0 commit comments

Comments
 (0)