lkml.org 
[lkml]   [2022]   [Nov]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 1/2] RDMA/hfi1: Fix error return code in parse_platform_config()
On Fri, Nov 25, 2022 at 08:03:50PM +0800, Wang Yufen wrote:
> In the previous while loop, "ret" may be assigned zero. Therefore,
> "ret" needs to be assigned -EINVAL at the beginning of each loop.

...

> while (ptr < (u32 *)(dd->platform_config.data + file_length)) {
> + ret = -EINVAL;
> header1 = *ptr;
> header2 = *(ptr + 1);
> if (header1 != ~header2) {

You may do it differently and simplify even existing code, i.e.

// The following two lines to add
bali_with_einval:
ret = -EINVAL;
bail:
memset(pcfgcache, 0, sizeof(struct platform_config_cache));
return ret;

Then you convert all goto bail; to goto bail_with_einval; where it's
appropriate. And dropping some duplicative ret = -EINVAL; lines above.


--
With Best Regards,
Andy Shevchenko


\
 
 \ /
  Last update: 2022-11-25 15:31    [W:0.050 / U:0.292 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site