libbpf: fix warning that PTR_ERR_OR_ZERO can be used
authorHariprasad Kelam <hariprasad.kelam@gmail.com>
Sat, 25 May 2019 09:02:57 +0000 (14:32 +0530)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 28 May 2019 08:56:05 +0000 (10:56 +0200)
Fix below warning reported by coccicheck:

/tools/lib/bpf/libbpf.c:3461:1-3: WARNING: PTR_ERR_OR_ZERO can be used

Signed-off-by: Hariprasad Kelam <hariprasad.kelam@gmail.com>
Acked-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
tools/lib/bpf/libbpf.c

index ff149372b3c07050f2fb7d9f8c442619db7cbc33..fd5905ac2ec37a58e8269f0d26a0ca4377053849 100644 (file)
@@ -3460,9 +3460,7 @@ bpf_object__find_map_by_offset(struct bpf_object *obj, size_t offset)
 
 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,