lkml.org 
[lkml]   [2022]   [Jun]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v1 1/2] wireless: ray_cs: Utilize strnlen() in parse_addr()
From
Date
On Fri, 2022-06-03 at 19:44 +0300, Andy Shevchenko wrote:
> Instead of doing simple operations and using an additional variable on stack,
> utilize strnlen() and reuse len variable.
[]
> diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c
[]
> + while (len > 0) {
> + if ((k = hex_to_bin(in_str[len--])) != -1)
> out[i] = k;
> else
> return 0;

could be reversed and unindented

>
> - if (j == 0)
> + if (len == 0)
> break;
> - if ((k = hex_to_bin(in_str[j--])) != -1)
> + if ((k = hex_to_bin(in_str[len--])) != -1)
> out[i] += k << 4;
> else
> return 0;

and here


\
 
 \ /
  Last update: 2022-06-03 18:51    [W:0.066 / U:0.396 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site