From patchwork Fri Jul 8 10:14:11 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Monjalon X-Patchwork-Id: 14669 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id B031E5A71; Fri, 8 Jul 2016 12:14:26 +0200 (CEST) Received: from mail-wm0-f41.google.com (mail-wm0-f41.google.com [74.125.82.41]) by dpdk.org (Postfix) with ESMTP id 2B97F5A64 for ; Fri, 8 Jul 2016 12:14:25 +0200 (CEST) Received: by mail-wm0-f41.google.com with SMTP id z126so10200969wme.0 for ; Fri, 08 Jul 2016 03:14:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=6wind-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rMRTL+XrRME+7VGRSxGwonKvfYmkLktM8G11UXehMY8=; b=j/0kDr2W3LppkbAvxpkeVRl7cCIPAsik0lLOI6cfTfCwkod2510xqI1TERksUO0gl3 zcnpH2soQIZY13JYRGY74eshqR6koAKMj3fLPVLcFzkXC5ag8A1b2D/UhGii6a4TNkYr gIRerku6Mq3/mQTHFI1hWGVyZ4cNdZ4+lV+uLc6jv80+82xYQo8Irf3uutz7EZxnnaIr 3XDjJJbfS5UTEF3gtT2vRtgkWgAfOiXenRjjx8qHpQPuLb4c2seK1RSyRkBr8aMXDuGD FC8C3yGRoCcTBPUwMRuGYg3ZJX1Szi6wlWqHwTB5PgxKLnN5hV5PesP8Lr6jftbjYKl1 /9bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rMRTL+XrRME+7VGRSxGwonKvfYmkLktM8G11UXehMY8=; b=TabyIvOOANG1sOEuRAc4jG4Gh1EnxfkCHcumbRKCjInrZBzBGTSusGmdInkL1yxNF5 KJKF2s3e/67uIN1tcH4iuc0dbFwwFkI+0yDrIFMiQ1FPtqLZfUZaFHvnj6zi6+84bfQI jJN0xmxn1Jo677JQSg5vxyDHOw+bOrFMcrsrSdw5ryN8AMaC31vfVjTkpNGkf/P4q/8r 21pDkQQLMCi6YosVveNUSrsyuRWMoUJsLiI9Itg7/OA+3k/PqL/9ptwiZJaZ+WND/xxX JDPtSP7o9F847MSQJ4u79sncCY8r44UTbPcvmWwyh7W+aYroXBtp4MIFwzu0JtrenO9Q FZ8A== X-Gm-Message-State: ALyK8tKsw2LIYyGrG/2Rer7WtGnFQemP9g4X7pAYcRFxzOJrIRd1B0wWhMMQYPkFCuC1hHyX X-Received: by 10.194.39.6 with SMTP id l6mr4485921wjk.139.1467972864892; Fri, 08 Jul 2016 03:14:24 -0700 (PDT) Received: from XPS13.localdomain (184.203.134.77.rev.sfr.net. [77.134.203.184]) by smtp.gmail.com with ESMTPSA id d4sm8146wjb.47.2016.07.08.03.14.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 08 Jul 2016 03:14:24 -0700 (PDT) From: Thomas Monjalon To: Neil Horman Cc: dev@dpdk.org Date: Fri, 8 Jul 2016 12:14:11 +0200 Message-Id: <1467972855-21873-7-git-send-email-thomas.monjalon@6wind.com> X-Mailer: git-send-email 2.7.0 In-Reply-To: <1467972855-21873-1-git-send-email-thomas.monjalon@6wind.com> References: <1467905790-10597-1-git-send-email-thomas.monjalon@6wind.com> <1467972855-21873-1-git-send-email-thomas.monjalon@6wind.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2 06/10] pmdinfogen: fix build warnings X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list 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 flags WERROR_FLAGS are used. The warnings fixed are: no previous prototype for ... no return statement in function returning non-void variable ‘secstrings’ set but not used ‘sec_name’ defined but not used ‘get_symbol_index’ defined but not used pointer of type ‘void *’ 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/Makefile index 125901b..3885d3b 100644 --- a/buildtools/pmdinfogen/Makefile +++ b/buildtools/pmdinfogen/Makefile @@ -41,9 +41,9 @@ HOSTAPP = pmdinfogen # SRCS-y += pmdinfogen.c -HOST_EXTRA_CFLAGS += -g -I${RTE_OUTPUT}/include +HOST_CFLAGS += $(WERROR_FLAGS) -g +HOST_CFLAGS += -I$(RTE_OUTPUT)/include DEPDIRS-y += lib/librte_eal include $(RTE_SDK)/mk/rte.hostapp.mk - diff --git a/buildtools/pmdinfogen/pmdinfogen.c b/buildtools/pmdinfogen/pmdinfogen.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" #ifdef RTE_ARCH_64 @@ -32,7 +33,7 @@ static const char *sym_name(struct elf_info *elf, Elf_Sym *sym) return "(unknown)"; } -void *grab_file(const char *filename, unsigned long *size) +static void *grab_file(const char *filename, unsigned long *size) { struct stat st; void *map = 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) static void *get_sym_value(struct elf_info *info, const Elf_Sym *sym) { - void *ptr = (void *)info->hdr + info->sechdrs[sym->st_shndx].sh_offset; - - return (void *)(ptr + sym->st_value); + return RTE_PTR_ADD(info->hdr, + info->sechdrs[sym->st_shndx].sh_offset + sym->st_value); } 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 = ~0U, symtab_shndx_idx = ~0U; @@ -140,7 +139,7 @@ static int parse_elf(struct elf_info *info, const char *filename) hdr->e_shnum = TO_NATIVE(endian, 16, hdr->e_shnum); hdr->e_shstrndx = TO_NATIVE(endian, 16, hdr->e_shstrndx); - sechdrs = (void *)hdr + hdr->e_shoff; + sechdrs = RTE_PTR_ADD(hdr, hdr->e_shoff); info->sechdrs = sechdrs; /* Check if file offset is correct */ @@ -191,7 +190,6 @@ static int parse_elf(struct elf_info *info, const char *filename) TO_NATIVE(endian, ADDR_SIZE, sechdrs[i].sh_entsize); } /* Find symbol table. */ - secstrings = (void *)hdr + sechdrs[info->secindex_strings].sh_offset; for (i = 1; i < info->num_sections; i++) { int nobits = sechdrs[i].sh_type == SHT_NOBITS; @@ -206,22 +204,22 @@ static int parse_elf(struct elf_info *info, const char *filename) if (sechdrs[i].sh_type == SHT_SYMTAB) { unsigned int sh_link_idx; symtab_idx = i; - info->symtab_start = (void *)hdr + - sechdrs[i].sh_offset; - info->symtab_stop = (void *)hdr + - sechdrs[i].sh_offset + sechdrs[i].sh_size; + info->symtab_start = RTE_PTR_ADD(hdr, + sechdrs[i].sh_offset); + info->symtab_stop = RTE_PTR_ADD(hdr, + sechdrs[i].sh_offset + sechdrs[i].sh_size); sh_link_idx = sechdrs[i].sh_link; - info->strtab = (void *)hdr + - sechdrs[sh_link_idx].sh_offset; + info->strtab = RTE_PTR_ADD(hdr, + sechdrs[sh_link_idx].sh_offset); } /* 32bit section no. table? ("more than 64k sections") */ if (sechdrs[i].sh_type == SHT_SYMTAB_SHNDX) { symtab_shndx_idx = i; - info->symtab_shndx_start = (void *)hdr + - sechdrs[i].sh_offset; - info->symtab_shndx_stop = (void *)hdr + - sechdrs[i].sh_offset + sechdrs[i].sh_size; + info->symtab_shndx_start = RTE_PTR_ADD(hdr, + sechdrs[i].sh_offset); + info->symtab_shndx_stop = 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) } } -static const char *sec_name(struct elf_info *elf, int secindex) -{ - Elf_Shdr *sechdrs = 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 = sym_name(info, sym); - const char *idx; - - idx = 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; } static void output_pmd_info_string(struct elf_info *info, char *outfile)