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]
Message-ID: <20170122074839.GD28570@mtr-leonro.local>
Date:   Sun, 22 Jan 2017 09:48:39 +0200
From:   Leon Romanovsky <leon@...nel.org>
To:     Geliang Tang <geliangtang@...il.com>
Cc:     Yishai Hadas <yishaih@...lanox.com>, netdev@...r.kernel.org,
        linux-rdma@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] net/mlx4: use rb_entry()

On Fri, Jan 20, 2017 at 10:36:57PM +0800, Geliang Tang wrote:
> To make the code clearer, use rb_entry() instead of container_of() to
> deal with rbtree.
>
> Signed-off-by: Geliang Tang <geliangtang@...il.com>
> ---
>  drivers/net/ethernet/mellanox/mlx4/resource_tracker.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)

I don't understand completely the rationale behind this conversion.
rb_entry == container_of, why do we need another name for it?

>
> diff --git a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
> index 1822382..6da6e01 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
> @@ -236,8 +236,8 @@ static void *res_tracker_lookup(struct rb_root *root, u64 res_id)
>  	struct rb_node *node = root->rb_node;
>
>  	while (node) {
> -		struct res_common *res = container_of(node, struct res_common,
> -						      node);
> +		struct res_common *res = rb_entry(node, struct res_common,
> +						  node);
>
>  		if (res_id < res->res_id)
>  			node = node->rb_left;
> @@ -255,8 +255,8 @@ static int res_tracker_insert(struct rb_root *root, struct res_common *res)
>
>  	/* Figure out where to put new node */
>  	while (*new) {
> -		struct res_common *this = container_of(*new, struct res_common,
> -						       node);
> +		struct res_common *this = rb_entry(*new, struct res_common,
> +						   node);
>
>  		parent = *new;
>  		if (res->res_id < this->res_id)
> --
> 2.9.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
> the body of a message to majordomo@...r.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ