Skip to contentSkip to conversation

libbpf: simplify the return expression of build_map_pin_path()

PATCH In review Xu Wang 2 participants 3 messages Aug 18, 2020

Subsystems (4)
lore
Share & tools
lore

Xu Wang

author
#0 lore raw

PATCH 1/1 libbpf: simplify the return expression of build_map_pin_path()

Simplify the return expression.

---
 tools/lib/bpf/libbpf.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
tools/lib/bpf/libbpf.c +1 -5
index 5055e1531e43..b423fdaae0b6 100644
@@ -1935,11 +1935,7 @@ static int build_map_pin_path(struct bpf_map *map, const char *path)
 	else if (len >= PATH_MAX)
 		return -ENAMETOOLONG;
 
-	err = bpf_map__set_pin_path(map, buf);
-	if (err)
-		return err;
-
-	return 0;
+	return bpf_map__set_pin_path(map, buf);
 }
 
 
Signature · 1 line
2.17.1
#1 lore raw
Quoted 12 lines · Xu Wang

Simplify the return expression.

---
  tools/lib/bpf/libbpf.c | 6 +-----
  1 file changed, 1 insertion(+), 5 deletions(-)
tools/lib/bpf/libbpf.c +0 -0
index 5055e1531e43..b423fdaae0b6 100644

tools/lib/bpf/libbpf.c static int build_map_pin_path(struct bpf_map *map, const char *path) · line 1938

Quoted 9 lines
tools/lib/bpf/libbpf.c +1 -5
@@ -1935,11 +1935,7 @@ static int build_map_pin_path(struct bpf_map *map, const char *path)
  	else if (len >= PATH_MAX)
  		return -ENAMETOOLONG;
 
-	err = bpf_map__set_pin_path(map, buf);
-	if (err)
-		return err;
-
-	return 0;
+	return bpf_map__set_pin_path(map, buf);

After the above, the variable err will not be used any more, which may incur an unused variable warning. Could you remove it?

Quoted 4 lines
tools/lib/bpf/libbpf.c +0 -0
  }
 
 
#2 lore raw
In reply to Xu Wang
Quoted 3 lines · Xu Wang

Simplify the return expression.

Also, please tag your patch targeting to 'bpf-next' tree like [PATCH bpf-next] so people knows which tree the patch targets.

Quoted 22 lines
---
  tools/lib/bpf/libbpf.c | 6 +-----
  1 file changed, 1 insertion(+), 5 deletions(-)
tools/lib/bpf/libbpf.c +1 -5
index 5055e1531e43..b423fdaae0b6 100644
@@ -1935,11 +1935,7 @@ static int build_map_pin_path(struct bpf_map *map, const char *path)
  	else if (len >= PATH_MAX)
  		return -ENAMETOOLONG;
 
-	err = bpf_map__set_pin_path(map, buf);
-	if (err)
-		return err;
-
-	return 0;
+	return bpf_map__set_pin_path(map, buf);
  }