From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752732AbcFZLXA (ORCPT ); Sun, 26 Jun 2016 07:23:00 -0400 Received: from szxga04-in.huawei.com ([58.251.152.52]:22066 "EHLO szxga04-in.huawei.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752624AbcFZLWS (ORCPT ); Sun, 26 Jun 2016 07:22:18 -0400 From: He Kuang To: , , , , , , , , CC: Subject: [RFC PATCH v2 14/26] perf bpf: Add -Wextra to cflags for more warnings and fix them Date: Sun, 26 Jun 2016 11:21:06 +0000 Message-ID: <1466940078-65581-15-git-send-email-hekuang@huawei.com> X-Mailer: git-send-email 1.8.3.4 In-Reply-To: <1466940078-65581-1-git-send-email-hekuang@huawei.com> References: <1466940078-65581-1-git-send-email-hekuang@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.107.193.250] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090206.576FBAD5.005B,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 456a2263ca85eba1f4a712b356d56ec5 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since -Wextra is used in perf tools, this patch adopts this cflags into lib/bpf. It also fixes 'comparison between signed and unsigned integer' errors reported afterward. Signed-off-by: He Kuang --- tools/lib/bpf/Makefile | 2 +- tools/lib/bpf/libbpf.c | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/lib/bpf/Makefile b/tools/lib/bpf/Makefile index 1fb098d..65a64d8 100644 --- a/tools/lib/bpf/Makefile +++ b/tools/lib/bpf/Makefile @@ -126,7 +126,7 @@ endif # Append required CFLAGS override CFLAGS += $(EXTRA_WARNINGS) -override CFLAGS += -Werror -Wall +override CFLAGS += -Werror -Wall -Wextra override CFLAGS += -fPIC override CFLAGS += $(INCLUDES) diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index a53cb579..ddbba35 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c @@ -443,7 +443,7 @@ bpf_object__init_maps(struct bpf_object *obj, void *data, size_t size) { size_t nr_maps; - int i; + unsigned int i; nr_maps = size / sizeof(struct bpf_map_def); if (!data || !nr_maps) { @@ -480,7 +480,7 @@ bpf_object__init_maps(struct bpf_object *obj, void *data, static int bpf_object__init_maps_name(struct bpf_object *obj) { - int i; + unsigned int i; Elf_Data *symbols = obj->efile.symbols; if (!symbols || obj->efile.maps_shndx < 0) @@ -521,7 +521,8 @@ static int bpf_object__elf_collect(struct bpf_object *obj) Elf *elf = obj->efile.elf; GElf_Ehdr *ep = &obj->efile.ehdr; Elf_Scn *scn = NULL; - int idx = 0, err = 0; + unsigned int idx = 0; + int err = 0; /* Elf is corrupted/truncated, avoid calling elf_strptr. */ if (!elf_rawdata(elf_getscn(elf, ep->e_shstrndx), NULL)) { -- 1.8.5.2