Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp81155imm; Tue, 31 Jul 2018 14:13:31 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcOY+9RNiZflZHTWTMmiiyvDaHZSGFMQiD2/QlgrkPBI497lQqs/sTPUGmLZOtPbUEja1Tj X-Received: by 2002:a63:8f03:: with SMTP id n3-v6mr22140826pgd.166.1533071611751; Tue, 31 Jul 2018 14:13:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533071611; cv=none; d=google.com; s=arc-20160816; b=RqZkChsyW9Vk29eQl4A+8lBoWbOy9c/CQlqqbQIM7gAh473GE9gFgAYbKumBPiI6P9 kbdQJPEqBBlcVyPvaeLi4cKuWqDYQjyDQQA4ywwtK7hUVXoo85fe+2Xf3NF8E65NUeRH pzh/22088SQ1f4ZqY38LVpwVONF9kjxQxtdOgtVKgEJXxW0N6W75wICy9gJ0tL5guMLx H/BNn+Kb/lO+SmgYs8V2y2YUNenNAzU2XX0BJVPscoOh1YGGTNsIIlLXbtuRbF+aJQ8A TpAr/tkCaOTvyfNFnd3s/+Ms8nvIvJQumjvoObTjK1vG8xnnTw7Nd4mffmmnmtw7P61s DaZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=c5XV+YfHPTrtaAxsNrKvZeZvBvnkWPCcOLyVd8137z8=; b=nmr7vThH13z9dIjKRv24Uf5scsJApP/k0/k3x4PPuB2YajceNqBGF6R69iSomwM2i/ 7HsdV3EGX2Wlu92oy4ALr7feaZzunIq9YVGXVMrHBR4xGWPSo9NzvsZv71wAD8bLVDnX TkYP9aYXqoUZ55AgXxcTLBXbNr3fjmaP35p0tRvBFYfp+AgYKeOGygVftemqJgq5NBtU X/Do74+P9pqzC1B9LwmWldESnYc8NYnbjVKR0ZdDuB2bJhfr01qEBEm5rdrU0i996XJX Ad99sWp5MBG3iDWx+GOcSvghgoEFH1/LinTDhbLpCpoZEWjJE46rrOblCRjYAtu2A5N1 eqUw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w22-v6si8362178ply.17.2018.07.31.14.13.12; Tue, 31 Jul 2018 14:13:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732412AbeGaWyC (ORCPT + 99 others); Tue, 31 Jul 2018 18:54:02 -0400 Received: from www62.your-server.de ([213.133.104.62]:60469 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729761AbeGaWyC (ORCPT ); Tue, 31 Jul 2018 18:54:02 -0400 Received: from [78.46.172.2] (helo=sslproxy05.your-server.de) by www62.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.85_2) (envelope-from ) id 1fkbvj-00007B-3f; Tue, 31 Jul 2018 23:11:43 +0200 Received: from [62.203.87.61] (helo=linux.home) by sslproxy05.your-server.de with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1fkbvi-0002su-V7; Tue, 31 Jul 2018 23:11:42 +0200 Subject: Re: [PATCH] lib/bpf/libbpf: Simplify the code by using PTR_ERR_OR_ZERO To: zhong jiang , ast@kernel.org, davem@davemloft.net Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <1533054656-36134-1-git-send-email-zhongjiang@huawei.com> From: Daniel Borkmann Message-ID: <4291dac0-8384-c357-1409-4a765bb70fb7@iogearbox.net> Date: Tue, 31 Jul 2018 23:11:42 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <1533054656-36134-1-git-send-email-zhongjiang@huawei.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.100.0/24800/Tue Jul 31 18:43:36 2018) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > 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