[dpdk-stable] [PATCH] app/test-compress-perf: fix reliance on integer endianness

Trahe, Fiona fiona.trahe at intel.com
Mon May 20 16:05:54 CEST 2019


HI Tomasz,

> -----Original Message-----
> From: Jozwiak, TomaszX
> Sent: Monday, May 20, 2019 2:26 PM
> To: dev at dpdk.org; Trahe, Fiona <fiona.trahe at intel.com>; Jozwiak, TomaszX
> <tomaszx.jozwiak at intel.com>; shallyv at marvell.com; stable at 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 at dpdk.org
> 
> Signed-off-by: Tomasz Jozwiak <tomaszx.jozwiak at intel.com>
> ---
>  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 = parse_uint16_t((uint16_t *)&test_data->window_sz, arg);
> +	uint16_t tmp;
> +	int ret = parse_uint16_t(&tmp, arg);
> 
>  	if (ret) {
>  		RTE_LOG(ERR, USER1, "Failed to parse window size\n");
>  		return -1;
>  	}
> 
> +	test_data->window_sz = (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?



More information about the stable mailing list