Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp5368558imm; Tue, 31 Jul 2018 09:45:12 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeBU5jslvSrEl57db25sP44pBpHYNT9v+TbALyCxFVLAvCfR6HSE8ldufkGreFwXEoD812i X-Received: by 2002:a63:4e5f:: with SMTP id o31-v6mr21587710pgl.256.1533055512074; Tue, 31 Jul 2018 09:45:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533055512; cv=none; d=google.com; s=arc-20160816; b=cHAPoQb4ohSF2jLFYxVWZyTQIrQxsY84qxfThLVPqzJTocUVlHbS3Achi36q0smHfz Tvdkn68KUpD1C4j9t1cMeTuOao2sfoduN+1nqYdozWd42lbYGjh9PgBaH5uqhVKUqpuc Lhsg3Gc/e85m1eetG3MwYaKhPpft14AqzpS3whQ+liWsaDCK1H00HmOOxfB/NhNzNTfk HU2ValBfhocU9CtGwmf7SQ3jJo9v+2kMsxHZdr4bdHp2sSiuW3oMLxKGKig7qCNuAUBi sqP/WRJon3n/BnYWDl0XVFNGhCeHt0XYO8sAnnrkPmSFVKlfNf1aDT6Y2gxEzOlrnlUW RVwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:arc-authentication-results; bh=H8gqnECM7VswdtY/8GHB3DWHeXyeYN3EgLLebL5Gnwk=; b=oTqNxz+mJ1QEZVZk9nJ69gO0qjyaX7R2FCMjO1ZgtUdn0a+PQu6dQ6E6cRQfV+Rg6x 38YOn1/gXL8IiIUzSk6x0oEZjFw229dS8Ddv5Ky88NOcWPhSOJI1TYp/4v6Da6wEz2JF DicWnzLvykLrck81MVVdvKJaCjUdaXUSU1R/8F+OB4wYfB6G3PTq5cBwnuQljpmsylqY ucsaeXKM1/AgKoaDBGZIk80tb09kUs8zDvkrpYMaPPfM52o6dbwXj3/x41MhEse4m5lC m/2Gz8Nd6TC8PcXorIPcfw00tDYxjsj0FT71SiimMlDi0ZY9qMHdqt912RtEBElc3i+s d99w== 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 e95-v6si12888893plb.239.2018.07.31.09.44.57; Tue, 31 Jul 2018 09:45:12 -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 S1729580AbeGaSXs (ORCPT + 99 others); Tue, 31 Jul 2018 14:23:48 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:43563 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727307AbeGaSXs (ORCPT ); Tue, 31 Jul 2018 14:23:48 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id DD80AF36558FB; Wed, 1 Aug 2018 00:42:30 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.399.0; Wed, 1 Aug 2018 00:42:30 +0800 From: zhong jiang To: , , CC: , Subject: [PATCH] lib/bpf/libbpf: Simplify the code by using PTR_ERR_OR_ZERO Date: Wed, 1 Aug 2018 00:30:56 +0800 Message-ID: <1533054656-36134-1-git-send-email-zhongjiang@huawei.com> X-Mailer: git-send-email 1.7.12.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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, -- 1.7.12.4