Skip to contentSkip to conversation

tools lib bpf: Use PTR_ERR_OR_ZERO()

PATCH New Vasyl Gomonovych 1 participant 1 message Nov 27, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools lib bpf: Use PTR_ERR_OR_ZERO()

Fix ptr_ret.cocci warnings:
tools/lib/bpf/libbpf.c:1744:1-3: WARNING: PTR_ERR_OR_ZERO can be used

Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR

Generated by: scripts/coccinelle/api/ptr_ret.cocci

---
 tools/lib/bpf/libbpf.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
tools/lib/bpf/libbpf.c +1 -3
index 35f6dfcdc565..c0894ef65631 100644
@@ -1741,9 +1741,7 @@ struct bpf_map *
 
 long libbpf_get_error(const void *ptr)
 {
-	if (IS_ERR(ptr))
-		return PTR_ERR(ptr);
-	return 0;
+	return PTR_ERR_OR_ZERO(ptr);
 }
 
 int bpf_prog_load(const char *file, enum bpf_prog_type type,
Signature · 1 line
1.9.1