aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWang Sheng-Hui <shhuiw@foxmail.com>2018-04-24 22:07:13 -0400
committerDaniel Borkmann <daniel@iogearbox.net>2018-04-26 18:47:06 -0400
commitc0885f61bbb6a89c35397d3a8fe49c35822cde81 (patch)
tree025e0167db35c4c5c6cd4e386aad75b85b4e7999
parenta6712d45b03e89800e687873fd4af015f5aaf4dd (diff)
samples, bpf: remove redundant ret assignment in bpf_load_program()
2 redundant ret assignments removed: * 'ret = 1' before the logic 'if (data_maps)', and if any errors jump to label 'done'. No 'ret = 1' needed before the error jump. * After the '/* load programs */' part, if everything goes well, then the BPF code will be loaded and 'ret' set to 0 by load_and_attach(). If something goes wrong, 'ret' set to none-O, the redundant 'ret = 0' after the for clause will make the error skipped. For example, if some BPF code cannot provide supported program types in ELF SEC("unknown"), the for clause will not call load_and_attach() to load the BPF code. 1 should be returned to callees instead of 0. Signed-off-by: Wang Sheng-Hui <shhuiw@foxmail.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
-rw-r--r--samples/bpf/bpf_load.c2
1 files changed, 0 insertions, 2 deletions
diff --git a/samples/bpf/bpf_load.c b/samples/bpf/bpf_load.c
index bebe4188b4b3..feca497d6afd 100644
--- a/samples/bpf/bpf_load.c
+++ b/samples/bpf/bpf_load.c
@@ -549,7 +549,6 @@ static int do_load_bpf_file(const char *path, fixup_map_cb fixup_map)
549 if (nr_maps < 0) { 549 if (nr_maps < 0) {
550 printf("Error: Failed loading ELF maps (errno:%d):%s\n", 550 printf("Error: Failed loading ELF maps (errno:%d):%s\n",
551 nr_maps, strerror(-nr_maps)); 551 nr_maps, strerror(-nr_maps));
552 ret = 1;
553 goto done; 552 goto done;
554 } 553 }
555 if (load_maps(map_data, nr_maps, fixup_map)) 554 if (load_maps(map_data, nr_maps, fixup_map))
@@ -615,7 +614,6 @@ static int do_load_bpf_file(const char *path, fixup_map_cb fixup_map)
615 } 614 }
616 } 615 }
617 616
618 ret = 0;
619done: 617done:
620 close(fd); 618 close(fd);
621 return ret; 619 return ret;