[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1466940078-65581-15-git-send-email-hekuang@huawei.com>
Date: Sun, 26 Jun 2016 11:21:06 +0000
From: He Kuang <hekuang@...wei.com>
To: <acme@...nel.org>, <peterz@...radead.org>, <mingo@...hat.com>,
<jolsa@...hat.com>, <brendan.d.gregg@...il.com>, <ast@...nel.org>,
<alexander.shishkin@...ux.intel.com>, <wangnan0@...wei.com>,
<hekuang@...wei.com>
CC: <linux-kernel@...r.kernel.org>
Subject: [RFC PATCH v2 14/26] perf bpf: Add -Wextra to cflags for more warnings and fix them
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 <hekuang@...wei.com>
---
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
Powered by blists - more mailing lists