lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Fri, 20 Oct 2017 11:06:00 -0500
From:   "Gustavo A. R. Silva" <garsilva@...eddedor.com>
To:     walter harms <wharms@....de>
Cc:     Ralf Baechle <ralf@...ux-mips.org>,
        "David S. Miller" <davem@...emloft.net>,
        linux-hams@...r.kernel.org, netdev@...r.kernel.org
Subject: Re: [PATCH 2/2] net: netrom: refactor code in nr_add_node

Hi Walter,

Quoting walter harms <wharms@....de>:

> Am 19.10.2017 19:27, schrieb Gustavo A. R. Silva:
>> Code refactoring in order to make the code easier to read and maintain.
>>
>> Signed-off-by: Gustavo A. R. Silva <garsilva@...eddedor.com>
>> ---
>> This code was tested by compilation only (GCC 7.2.0 was used).
>>
>>  net/netrom/nr_route.c | 63  
>> ++++++++++++++++-----------------------------------
>>  1 file changed, 20 insertions(+), 43 deletions(-)
>>
>> diff --git a/net/netrom/nr_route.c b/net/netrom/nr_route.c
>> index fc9cadc..1e5165f 100644
>> --- a/net/netrom/nr_route.c
>> +++ b/net/netrom/nr_route.c
>> @@ -80,6 +80,23 @@ static struct nr_neigh  
>> *nr_neigh_get_dev(ax25_address *callsign,
>>
>>  static void nr_remove_neigh(struct nr_neigh *);
>>
>> +/*      re-sort the routes in quality order.    */
>> +static inline void re_sort_routes(struct nr_node *nr_node, int  
>> ix_x, int ix_y)
>> +{
>> +	struct nr_route nr_route;
>> +
>> +	if (nr_node->routes[ix_y].quality > nr_node->routes[ix_x].quality) {
>> +		if (nr_node->which == ix_x)
>> +			nr_node->which = ix_y;
>> +		else if (nr_node->which == ix_y)
>> +			nr_node->which = ix_x;
>> +
>> +		nr_route              = nr_node->routes[ix_x];
>> +		nr_node->routes[ix_x] = nr_node->routes[ix_y];
>> +		nr_node->routes[ix_y] = nr_route;
>> +	}
>> +}
>> +
>
>
> Good idea, a bit of nit picking ..
> does ix_ has a special meaning ? otherwise x,y would be sufficient.

ix typical stands for index, but I think just x and y are fine too.

> From the code below i can see: y=x+1 Perhaps that can be used.
>

So are you proposing to use two arguments instead of three?

re_sort_routes(nr_node, 0);


> kernel.h has a swap() macro. so you can  
> swap(nr_node->routes[x],nr_node->routes[y]);
>

Nice, I will use that macro.

> hope that helps,

Definitely. I appreciate your comments.

Thanks!
--
Gustavo A. R. Silva







Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ