lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4291dac0-8384-c357-1409-4a765bb70fb7@iogearbox.net>
Date:   Tue, 31 Jul 2018 23:11:42 +0200
From:   Daniel Borkmann <daniel@...earbox.net>
To:     zhong jiang <zhongjiang@...wei.com>, ast@...nel.org,
        davem@...emloft.net
Cc:     netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] lib/bpf/libbpf: Simplify the code by using
 PTR_ERR_OR_ZERO

On 07/31/2018 06:30 PM, zhong jiang wrote:
> Use PTR_ERR_OR_ZERO is better than the open code.
> 
> Signed-off-by: zhong jiang <zhongjiang@...wei.com>
> ---
>  tools/lib/bpf/libbpf.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> index 40211b5..9b61468 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
> @@ -2271,9 +2271,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,
> 

Looks like you didn't even bother to try to compile your change ...

# make
Warning: Kernel ABI header at 'tools/include/uapi/linux/if_link.h' differs from latest version at 'include/uapi/linux/if_link.h'
  CC       libbpf.o
  CC       nlattr.o
  CC       btf.o
  CC       bpf.o
  CC       libbpf_errno.o
libbpf.c: In function ‘libbpf_get_error’:
libbpf.c:2269:9: error: implicit declaration of function ‘PTR_ERR_OR_ZERO’ [-Werror=implicit-function-declaration]
  return PTR_ERR_OR_ZERO(ptr);
         ^~~~~~~~~~~~~~~
libbpf.c:2269:2: error: nested extern declaration of ‘PTR_ERR_OR_ZERO’ [-Werror=nested-externs]
  return PTR_ERR_OR_ZERO(ptr);
  ^~~~~~
cc1: all warnings being treated as errors

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ