From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id B65A45A35 for ; Wed, 9 Sep 2015 20:30:16 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP; 09 Sep 2015 11:25:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,498,1437462000"; d="scan'208";a="558486459" Received: from irsmsx105.ger.corp.intel.com ([163.33.3.28]) by FMSMGA003.fm.intel.com with ESMTP; 09 Sep 2015 11:25:54 -0700 Received: from irsmsx108.ger.corp.intel.com ([169.254.11.12]) by irsmsx105.ger.corp.intel.com ([169.254.7.51]) with mapi id 14.03.0224.002; Wed, 9 Sep 2015 19:25:53 +0100 From: "Dumitrescu, Cristian" To: Stephen Hemminger Thread-Topic: [PATCH 3/5] example_ip_pipeline: fix sizeof() on memcpy Thread-Index: AQHQ5FnMaR3YxTB0UkiZBO9EyxcSPJ40j8PQ Date: Wed, 9 Sep 2015 18:25:53 +0000 Message-ID: <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> In-Reply-To: <1441072746-29174-4-git-send-email-stephen@networkplumber.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [163.33.239.181] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 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:30:17 -0000 > -----Original Message----- > From: Stephen Hemminger [mailto:stephen@networkplumber.org] > Sent: Tuesday, September 1, 2015 4:59 AM > To: Dumitrescu, Cristian > Cc: dev@dpdk.org; Stephen Hemminger > Subject: [PATCH 3/5] example_ip_pipeline: fix sizeof() on memcpy >=20 > Found by Coverity: > Sizeof not portable (SIZEOF_MISMATCH) > suspicious_sizeof: Passing argument &app->cmds[app->n_cmds] of type > cmdline_parse_ctx_t * and argument n_cmds * 8UL /* sizeof > (cmdline_parse_ctx_t *) */ > to function memcpy is suspicious. > In this case, sizeof (cmdline_parse_ctx_t *) is equal to sizeof > (cmdline_parse_ctx_t), > but this is not a portable assumption. >=20 > Signed-off-by: Stephen Hemminger > --- > examples/ip_pipeline/init.c | 2 +- > examples/ip_pipeline/pipeline/pipeline_common_fe.c | 2 +- > examples/ip_pipeline/pipeline/pipeline_flow_classification.c | 1 - > 3 files changed, 2 insertions(+), 3 deletions(-) >=20 > 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 ar= ray 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. >=20 > for (i =3D 0; i < n_cmds; i++) > app->cmds[app->n_cmds + i]->data =3D app; > diff --git a/examples/ip_pipeline/pipeline/pipeline_common_fe.c > b/examples/ip_pipeline/pipeline/pipeline_common_fe.c > index fcda0ce..4eec66b 100644 > --- a/examples/ip_pipeline/pipeline/pipeline_common_fe.c > +++ b/examples/ip_pipeline/pipeline/pipeline_common_fe.c > @@ -1321,7 +1321,7 @@ app_pipeline_common_cmd_push(struct > app_params *app) > /* Push pipeline commands into the application */ > memcpy(&app->cmds[app->n_cmds], > pipeline_common_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 ar= ray 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. >=20 > for (i =3D 0; i < n_cmds; i++) > app->cmds[app->n_cmds + i]->data =3D app; > diff --git a/examples/ip_pipeline/pipeline/pipeline_flow_classification.c > b/examples/ip_pipeline/pipeline/pipeline_flow_classification.c > index 24cf7dc..e5141b0 100644 > --- a/examples/ip_pipeline/pipeline/pipeline_flow_classification.c > +++ b/examples/ip_pipeline/pipeline/pipeline_flow_classification.c > @@ -126,7 +126,6 @@ app_pipeline_fc_key_convert(struct pipeline_fc_key > *key_in, > { > struct pkt_key_ipv6_5tuple *ipv6 =3D key_buffer; >=20 > - memset(ipv6, 0, 64); Agreed! > ipv6->payload_length =3D 0; > ipv6->proto =3D key_in->key.ipv6_5tuple.proto; > ipv6->hop_limit =3D 0; > -- > 2.1.4