From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 078F7A05D3 for ; Tue, 21 May 2019 10:47:12 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3A49114EC; Tue, 21 May 2019 10:47:12 +0200 (CEST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id B61B210BD; Tue, 21 May 2019 10:47:09 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 May 2019 01:47:08 -0700 X-ExtLoop1: 1 Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga006.fm.intel.com with ESMTP; 21 May 2019 01:47:08 -0700 Received: from fmsmsx153.amr.corp.intel.com (10.18.125.6) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 21 May 2019 01:47:07 -0700 Received: from hasmsx112.ger.corp.intel.com (10.184.198.40) by FMSMSX153.amr.corp.intel.com (10.18.125.6) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 21 May 2019 01:47:07 -0700 Received: from hasmsx114.ger.corp.intel.com ([169.254.14.203]) by HASMSX112.ger.corp.intel.com ([169.254.11.66]) with mapi id 14.03.0415.000; Tue, 21 May 2019 11:47:04 +0300 From: "Jozwiak, TomaszX" To: Shally Verma , "Trahe, Fiona" , "dev@dpdk.org" , "stable@dpdk.org" CC: "Trybula, ArturX" Thread-Topic: [PATCH] app/test-compress-perf: fix reliance on integer endianness Thread-Index: AQHVDw+aaMHaQh/V2k+hP4D+ghNizqZz2d0AgAFJYZD//+PBAIAANiqw Date: Tue, 21 May 2019 08:47:03 +0000 Message-ID: References: <1558358764-32053-1-git-send-email-tomaszx.jozwiak@intel.com> <1558358764-32053-2-git-send-email-tomaszx.jozwiak@intel.com> <348A99DA5F5B7549AA880327E580B4358976C60C@IRSMSX101.ger.corp.intel.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.600.7 dlp-reaction: no-action x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNjBiMjk5Y2UtYTc2Yy00YzM5LTk1NmYtMzk3NzFjOTcwZDg0IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoibGx4aEV5Ym9oSWx1bmVZOU5paHJFU3NDeHpcLzE4SnpjRHJJOE1VT2QwOURabnhaTnU5MVNjenpNQ2dqVUJKR0MifQ== x-originating-ip: [10.184.70.10] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] app/test-compress-perf: fix reliance on integer endianness X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi Shally > -----Original Message----- > From: Shally Verma [mailto:shallyv@marvell.com] > Sent: Tuesday, May 21, 2019 10:04 AM > To: Jozwiak, TomaszX ; Trahe, Fiona > ; dev@dpdk.org; stable@dpdk.org > Cc: Trybula, ArturX > Subject: RE: [PATCH] app/test-compress-perf: fix reliance on integer > endianness >=20 > HI Tomasz >=20 > > -----Original Message----- > > From: Jozwiak, TomaszX > > Sent: Tuesday, May 21, 2019 12:18 PM > > To: Trahe, Fiona ; dev@dpdk.org; Shally Verma > > ; stable@dpdk.org > > Cc: Trybula, ArturX > > Subject: [EXT] RE: [PATCH] app/test-compress-perf: fix reliance on > > integer endianness > > > > External Email > > > > ---------------------------------------------------------------------- > > Hi Fiona, > > > > Outlook issue :D , so once again > > > > > -----Original Message----- > > > From: Trahe, Fiona > > > Sent: Monday, May 20, 2019 4:06 PM > > > To: Jozwiak, TomaszX ; dev@dpdk.org; > > > shallyv@marvell.com; stable@dpdk.org > > > Cc: Trahe, Fiona ; Trybula, ArturX > > > > > > Subject: RE: [PATCH] app/test-compress-perf: fix reliance on integer > > > endianness > > > > > > HI Tomasz, > > > > > > > -----Original Message----- > > > > From: Jozwiak, TomaszX > > > > Sent: Monday, May 20, 2019 2:26 PM > > > > To: dev@dpdk.org; Trahe, Fiona ; Jozwiak, > > > > TomaszX ; shallyv@marvell.com; > > > > stable@dpdk.org > > > > Subject: [PATCH] app/test-compress-perf: fix reliance on integer > > > > endianness > > > > > > > > This patch fixes coverity issue: > > > > Reliance on integer endianness (INCOMPATIBLE_CAST) in > > > parse_window_sz > > > > function. > > > > > > > > Coverity issue: 328524 > > > > Fixes: e0b6287c035d ("app/compress-perf: add parser") > > > > Cc: stable@dpdk.org > > > > > > > > Signed-off-by: Tomasz Jozwiak > > > > --- > > > > app/test-compress-perf/comp_perf_options_parse.c | 4 +++- > > > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > > > > > diff --git a/app/test-compress-perf/comp_perf_options_parse.c > > > > b/app/test-compress- perf/comp_perf_options_parse.c index > > > > 2fb6fb4..56ca580 100644 > > > > --- a/app/test-compress-perf/comp_perf_options_parse.c > > > > +++ b/app/test-compress-perf/comp_perf_options_parse.c > > > > @@ -364,13 +364,15 @@ parse_max_num_sgl_segs(struct > > > comp_test_data > > > > *test_data, const char *arg) static int parse_window_sz(struct > > > > comp_test_data *test_data, const char *arg) { > > > > - int ret =3D parse_uint16_t((uint16_t *)&test_data->window_sz, arg= ); > > > > + uint16_t tmp; > > > > + int ret =3D parse_uint16_t(&tmp, arg); > > > > > > > > if (ret) { > > > > RTE_LOG(ERR, USER1, "Failed to parse window size\n"); > > > > return -1; > > > > } > > > > > > > > + test_data->window_sz =3D (int)tmp; > > > > return 0; > > > > } > > > [Fiona] I expect this fixes this coverity issue - but will it result = in another > one? > > > window_sz on the xform is uint8_t - so this int will get truncated > > > later, and there's no cast done at that point. > > > Would it be better to add a new parse_uint8_t fn and change > > > test-data- > > > >window_sz to a unit8_t? > > > Or add that cast? > > [Tomek] I measn it's ok. There's a check inside > > comp_perf_check_capabilities function. > > If the value from test_data->window_sz > cap->window_size we have a > fail. > > Also during parsing there's a check is value from command line between > > 0 and UINT16_MAX, so in my opinion all cases are tested. The point is > > there's only one place where we're parsing uint8_t value. > > parse_uint8_t function will be especially for that. > [Shally] What is window_sz in test data ?is it base 2 log of (actual wind= ow > length) or actual window length in bytes? lib spec mention this as struct > rte_param_log2_range, so If test window size is actual window length in > bytes then I assume test perf should check for test_data->window_sz > 2 > pow cap->window_size but that doesn't look like the case. > So if it is log value, then coding wise typecasting here doesn't look rig= ht. > Though it add need for extra function to parse_uint8, but that looks like > cleaner approach to use. [Tomek] I mean it's log 2 (please take a look at help usage function in co= mp_perf_options_parse.c:37 " --window-sz N: base two log value of compression window size\n" " (e.g.: 15 =3D> 32k, default: max supported by PMD)\n" I mean it's ok, still. We have many types in command line and can be much m= ore in the future. The idea is to parse them into a sort of common range va= lue first ( it should be max range for all digital command line options - i= n our case there's uint16 or uint32_t) even if it's shorter like uint8_t or= etc. We store these values in comp_test_data structure first. Next we chec= k the ranges each of them. In case of window_sz this test is in comp_perf_c= heck_capabilities function. That approach reduce a set of parsing function= s we needed. Of course we can create separate parsing function for each of = command line type value, but is this really needed ? :D Please let me know your thoughts - if this new parsing function will clear = the code - I'll add this in v2