From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thomas Monjalon Subject: [PATCH v3 06/10] pmdinfogen: fix build warnings Date: Fri, 8 Jul 2016 16:42:20 +0200 Message-ID: <1467988944-25004-7-git-send-email-thomas.monjalon@6wind.com> References: <1467972855-21873-1-git-send-email-thomas.monjalon@6wind.com> <1467988944-25004-1-git-send-email-thomas.monjalon@6wind.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: dev@dpdk.org To: Neil Horman Return-path: Received: from mail-wm0-f50.google.com (mail-wm0-f50.google.com [74.125.82.50]) by dpdk.org (Postfix) with ESMTP id A7E0395DA for ; Fri, 8 Jul 2016 16:42:35 +0200 (CEST) Received: by mail-wm0-f50.google.com with SMTP id k123so14337619wme.0 for ; Fri, 08 Jul 2016 07:42:35 -0700 (PDT) In-Reply-To: <1467988944-25004-1-git-send-email-thomas.monjalon@6wind.com> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" When compiled with a standard clang, pmdinfogen can raise a warning: buildtools/pmdinfogen/pmdinfogen.c:365:1: warning: control reaches end of non-void function Actually there can be more warnings with stricter compilers. In order to catch them early and fix most of them, the DPDK standard flag= s WERROR_FLAGS are used. The warnings fixed are: no previous prototype for ... no return statement in function returning non-void variable =E2=80=98secstrings=E2=80=99 set but not used =E2=80=98sec_name=E2=80=99 defined but not used =E2=80=98get_symbol_index=E2=80=99 defined but not used pointer of type =E2=80=98void *=E2=80=99 used in arithmetic Fixes: 98b0fdb0ffc6 ("pmdinfogen: add buildtools and pmdinfogen utility") Signed-off-by: Thomas Monjalon --- buildtools/pmdinfogen/Makefile | 4 +-- buildtools/pmdinfogen/pmdinfogen.c | 58 ++++++++++++--------------------= ------ 2 files changed, 20 insertions(+), 42 deletions(-) diff --git a/buildtools/pmdinfogen/Makefile b/buildtools/pmdinfogen/Makef= ile index 125901b..3885d3b 100644 --- a/buildtools/pmdinfogen/Makefile +++ b/buildtools/pmdinfogen/Makefile @@ -41,9 +41,9 @@ HOSTAPP =3D pmdinfogen # SRCS-y +=3D pmdinfogen.c =20 -HOST_EXTRA_CFLAGS +=3D -g -I${RTE_OUTPUT}/include +HOST_CFLAGS +=3D $(WERROR_FLAGS) -g +HOST_CFLAGS +=3D -I$(RTE_OUTPUT)/include =20 DEPDIRS-y +=3D lib/librte_eal =20 include $(RTE_SDK)/mk/rte.hostapp.mk - diff --git a/buildtools/pmdinfogen/pmdinfogen.c b/buildtools/pmdinfogen/p= mdinfogen.c index 0947dc6..beb06f1 100644 --- a/buildtools/pmdinfogen/pmdinfogen.c +++ b/buildtools/pmdinfogen/pmdinfogen.c @@ -15,6 +15,7 @@ #include #include #include +#include #include "pmdinfogen.h" =20 #ifdef RTE_ARCH_64 @@ -32,7 +33,7 @@ static const char *sym_name(struct elf_info *elf, Elf_S= ym *sym) return "(unknown)"; } =20 -void *grab_file(const char *filename, unsigned long *size) +static void *grab_file(const char *filename, unsigned long *size) { struct stat st; void *map =3D MAP_FAILED; @@ -59,7 +60,7 @@ failed: * spaces in the beginning of the line is trimmed away. * Return a pointer to a static buffer. **/ -void release_file(void *file, unsigned long size) +static void release_file(void *file, unsigned long size) { munmap(file, size); } @@ -67,9 +68,8 @@ void release_file(void *file, unsigned long size) =20 static void *get_sym_value(struct elf_info *info, const Elf_Sym *sym) { - void *ptr =3D (void *)info->hdr + info->sechdrs[sym->st_shndx].sh_offse= t; - - return (void *)(ptr + sym->st_value); + return RTE_PTR_ADD(info->hdr, + info->sechdrs[sym->st_shndx].sh_offset + sym->st_value); } =20 static Elf_Sym *find_sym_in_symtab(struct elf_info *info, @@ -95,7 +95,6 @@ static int parse_elf(struct elf_info *info, const char = *filename) Elf_Ehdr *hdr; Elf_Shdr *sechdrs; Elf_Sym *sym; - const char *secstrings; int endian; unsigned int symtab_idx =3D ~0U, symtab_shndx_idx =3D ~0U; =20 @@ -140,7 +139,7 @@ static int parse_elf(struct elf_info *info, const cha= r *filename) hdr->e_shnum =3D TO_NATIVE(endian, 16, hdr->e_shnum); hdr->e_shstrndx =3D TO_NATIVE(endian, 16, hdr->e_shstrndx); =20 - sechdrs =3D (void *)hdr + hdr->e_shoff; + sechdrs =3D RTE_PTR_ADD(hdr, hdr->e_shoff); info->sechdrs =3D sechdrs; =20 /* Check if file offset is correct */ @@ -191,7 +190,6 @@ static int parse_elf(struct elf_info *info, const cha= r *filename) TO_NATIVE(endian, ADDR_SIZE, sechdrs[i].sh_entsize); } /* Find symbol table. */ - secstrings =3D (void *)hdr + sechdrs[info->secindex_strings].sh_offset; for (i =3D 1; i < info->num_sections; i++) { int nobits =3D sechdrs[i].sh_type =3D=3D SHT_NOBITS; =20 @@ -206,22 +204,22 @@ static int parse_elf(struct elf_info *info, const c= har *filename) if (sechdrs[i].sh_type =3D=3D SHT_SYMTAB) { unsigned int sh_link_idx; symtab_idx =3D i; - info->symtab_start =3D (void *)hdr + - sechdrs[i].sh_offset; - info->symtab_stop =3D (void *)hdr + - sechdrs[i].sh_offset + sechdrs[i].sh_size; + info->symtab_start =3D RTE_PTR_ADD(hdr, + sechdrs[i].sh_offset); + info->symtab_stop =3D RTE_PTR_ADD(hdr, + sechdrs[i].sh_offset + sechdrs[i].sh_size); sh_link_idx =3D sechdrs[i].sh_link; - info->strtab =3D (void *)hdr + - sechdrs[sh_link_idx].sh_offset; + info->strtab =3D RTE_PTR_ADD(hdr, + sechdrs[sh_link_idx].sh_offset); } =20 /* 32bit section no. table? ("more than 64k sections") */ if (sechdrs[i].sh_type =3D=3D SHT_SYMTAB_SHNDX) { symtab_shndx_idx =3D i; - info->symtab_shndx_start =3D (void *)hdr + - sechdrs[i].sh_offset; - info->symtab_shndx_stop =3D (void *)hdr + - sechdrs[i].sh_offset + sechdrs[i].sh_size; + info->symtab_shndx_start =3D RTE_PTR_ADD(hdr, + sechdrs[i].sh_offset); + info->symtab_shndx_stop =3D RTE_PTR_ADD(hdr, + sechdrs[i].sh_offset + sechdrs[i].sh_size); } } if (!info->symtab_start) @@ -262,28 +260,6 @@ static void parse_elf_finish(struct elf_info *info) } } =20 -static const char *sec_name(struct elf_info *elf, int secindex) -{ - Elf_Shdr *sechdrs =3D elf->sechdrs; - return (void *)elf->hdr + - elf->sechdrs[elf->secindex_strings].sh_offset + - sechdrs[secindex].sh_name; -} - -static int get_symbol_index(struct elf_info *info, Elf_Sym *sym) -{ - const char *name =3D sym_name(info, sym); - const char *idx; - - idx =3D name; - while (idx) { - if (isdigit(*idx)) - return atoi(idx); - idx++; - } - return -1; -} - struct opt_tag { const char *suffix; const char *json_id; @@ -362,6 +338,8 @@ static int locate_pmd_entries(struct elf_info *info) } } } while (last); + + return 0; } =20 static void output_pmd_info_string(struct elf_info *info, char *outfile) --=20 2.7.0