From patchwork Mon May 23 12:19:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Piotr Azarewicz X-Patchwork-Id: 12939 X-Patchwork-Delegate: thomas@monjalon.net 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 06D845937; Mon, 23 May 2016 14:18:53 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 5662E591F for ; Mon, 23 May 2016 14:18:51 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP; 23 May 2016 05:18:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,355,1459839600"; d="scan'208";a="972660151" Received: from gklab-246-018.igk.intel.com (HELO stargo) ([10.217.246.18]) by fmsmga001.fm.intel.com with SMTP; 23 May 2016 05:18:48 -0700 Received: by stargo (sSMTP sendmail emulation); Mon, 23 May 2016 14:20:03 +0200 From: Piotr Azarewicz To: dev@dpdk.org Cc: Piotr Azarewicz Date: Mon, 23 May 2016 14:19:56 +0200 Message-Id: <1464005996-9463-1-git-send-email-piotrx.t.azarewicz@intel.com> X-Mailer: git-send-email 1.9.1 Subject: [dpdk-dev] [PATCH v1 1/1] examples/quota_watermark: fix low_watermark variable placement 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" qw app at its init stage reserve 2*sizeof(int) memory space for quota and low_watermark shared variables, but both apps (qw and qwctl) assign wrong address for low_watermark pointer (out of reserved memzone space) due to wrong pointer arithmetic. CID 30709 : Extra sizeof expression (SIZEOF_MISMATCH) suspicious_pointer_arithmetic: Adding 4UL /* sizeof (int) */ to pointer (unsigned int *)(*qw_memzone).addr of type unsigned int * is suspicious because adding an integral value to this pointer automatically scales that value by the size, 4 bytes, of the pointed-to type, unsigned int. Most likely, sizeof (int) is extraneous and should be replaced with 1. Coverity issue: 30709 Fixes: 1d6c3ee3321a ("examples/quota_watermark: initial import") Signed-off-by: Piotr Azarewicz --- examples/quota_watermark/qw/init.c | 2 +- examples/quota_watermark/qwctl/qwctl.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/quota_watermark/qw/init.c b/examples/quota_watermark/qw/init.c index afc1366..c208721 100644 --- a/examples/quota_watermark/qw/init.c +++ b/examples/quota_watermark/qw/init.c @@ -170,5 +170,5 @@ setup_shared_variables(void) rte_exit(EXIT_FAILURE, "%s\n", rte_strerror(rte_errno)); quota = qw_memzone->addr; - low_watermark = (unsigned int *) qw_memzone->addr + sizeof(int); + low_watermark = (unsigned int *) qw_memzone->addr + 1; } diff --git a/examples/quota_watermark/qwctl/qwctl.c b/examples/quota_watermark/qwctl/qwctl.c index eb2f618..4961089 100644 --- a/examples/quota_watermark/qwctl/qwctl.c +++ b/examples/quota_watermark/qwctl/qwctl.c @@ -68,7 +68,7 @@ setup_shared_variables(void) rte_exit(EXIT_FAILURE, "Couldn't find memzone\n"); quota = qw_memzone->addr; - low_watermark = (unsigned int *) qw_memzone->addr + sizeof(int); + low_watermark = (unsigned int *) qw_memzone->addr + 1; } int main(int argc, char **argv)