Blob Blame History Raw
From: Wang Sheng-Hui <shhuiw@foxmail.com>
Date: Wed, 25 Apr 2018 10:07:13 +0800
Subject: samples, bpf: remove redundant ret assignment in bpf_load_program()
Patch-mainline: v4.18-rc1
Git-commit: c0885f61bbb6a89c35397d3a8fe49c35822cde81
References: bsc#1109837

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>
Acked-by: Thomas Bogendoerfer <tbogendoerfer@suse.de>
---
 samples/bpf/bpf_load.c |    2 --
 1 file changed, 2 deletions(-)

--- a/samples/bpf/bpf_load.c
+++ b/samples/bpf/bpf_load.c
@@ -535,7 +535,6 @@ static int do_load_bpf_file(const char *
 		if (nr_maps < 0) {
 			printf("Error: Failed loading ELF maps (errno:%d):%s\n",
 			       nr_maps, strerror(-nr_maps));
-			ret = 1;
 			goto done;
 		}
 		if (load_maps(map_data, nr_maps, fixup_map))
@@ -600,7 +599,6 @@ static int do_load_bpf_file(const char *
 		}
 	}
 
-	ret = 0;
 done:
 	close(fd);
 	return ret;