From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f52.google.com (mail-pa0-f52.google.com [209.85.220.52]) by dpdk.org (Postfix) with ESMTP id BE0878D35 for ; Wed, 9 Sep 2015 20:47:20 +0200 (CEST) Received: by padhy16 with SMTP id hy16so17920549pad.1 for ; Wed, 09 Sep 2015 11:47:20 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=2CNHlzReyOG1vN/N39uVtiYAYvKRu13aJ+SnpWsfkwg=; b=MmhCbD4MPx0z5c5v8J4XecL70TypYUvXpRKRZKoLHKcFUn7JYnJGYfNF4qsPMYeUsB 0LNBF0WKXLMES/cVlmmTBpFW3Q5yZGefoL3LYqKuTOEeIZJ4SQV9LrThT6H2EU1gGjpb fYrI7vT48zUf/5chRGNlPQ9T6RBA+ZR0IHq1VyR1nNEKNXn7ZZhzpLgg2PxSXN7fKhqJ J1eQx0vcSQJtwCsPvgUFEYwSLozI3h4NzNEM6hpWL+XSWLlItsef5zka7ryLue1fDSzW HZsQOKEYqjPayoOgFC7+x6RnpVq9vZIogN67KzCQKVcuDI4I2Su3Kmy1IXd63P3mljsr Z6rA== X-Gm-Message-State: ALoCoQm2TP4RLGt7Roq3n/LHmt13xqLKW7DAHVO6AglSJON115OZ/12AH1k8ulZSDI9HL6s4dCnZ X-Received: by 10.68.173.165 with SMTP id bl5mr73736948pbc.157.1441824440055; Wed, 09 Sep 2015 11:47:20 -0700 (PDT) Received: from urahara (static-50-53-82-155.bvtn.or.frontiernet.net. [50.53.82.155]) by smtp.gmail.com with ESMTPSA id le8sm7818732pbc.24.2015.09.09.11.47.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 09 Sep 2015 11:47:19 -0700 (PDT) Date: Wed, 9 Sep 2015 11:47:30 -0700 From: Stephen Hemminger To: "Dumitrescu, Cristian" Message-ID: <20150909114730.200405c0@urahara> In-Reply-To: <3EB4FA525960D640B5BDFFD6A3D89126478B9547@IRSMSX108.ger.corp.intel.com> References: <1441072746-29174-1-git-send-email-stephen@networkplumber.org> <1441072746-29174-4-git-send-email-stephen@networkplumber.org> <3EB4FA525960D640B5BDFFD6A3D89126478B9547@IRSMSX108.ger.corp.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: "dev@dpdk.org" Subject: Re: [dpdk-dev] [PATCH 3/5] example_ip_pipeline: fix sizeof() on memcpy 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: , X-List-Received-Date: Wed, 09 Sep 2015 18:47:21 -0000 On Wed, 9 Sep 2015 18:25:53 +0000 "Dumitrescu, Cristian" wrote: > > diff --git a/examples/ip_pipeline/init.c b/examples/ip_pipeline/init.c > > index 3f9c68d..75e3767 100644 > > --- a/examples/ip_pipeline/init.c > > +++ b/examples/ip_pipeline/init.c > > @@ -1325,7 +1325,7 @@ app_pipeline_type_cmd_push(struct app_params > > *app, > > /* Push pipeline commands into the application */ > > memcpy(&app->cmds[app->n_cmds], > > cmds, > > - n_cmds * sizeof(cmdline_parse_ctx_t *)); > > + n_cmds * sizeof(cmdline_parse_ctx_t)); > > Actually no, as we are both the destination and the source of memcpy are array of pointers. > > The source is a pipeline type, which is a static global data structure, so no issues with the life time of the data pointed to by the pointers. In order to make tools happy, shouldn't the source and target be pointers to array of pointers. In the current code &app->cmd[app->n_cmds] is type cmdline_parse_ctx_t * cmds is type cmdline_parse_ctx_t * And type cmdline_parse_ctx_t is already a pointer. Copying a set of pointers to pointers vs set of pointers will be the same since both are the same size, but static checking tools see the problem. This is why kernel developers particularly despise typedefs which hide pointers like this one.