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: <20161220164703.GL10069@char.us.oracle.com>
Date:   Tue, 20 Dec 2016 11:47:03 -0500
From:   Konrad Rzeszutek Wilk <konrad.wilk@...cle.com>
To:     Geliang Tang <geliangtang@...il.com>, roger.pau@...rix.com
Cc:     Roger Pau Monné <roger.pau@...rix.com>,
        xen-devel@...ts.xenproject.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] xen/blkback: use rb_entry()

On Tue, Dec 20, 2016 at 10:02:19PM +0800, Geliang Tang wrote:
> To make the code clearer, use rb_entry() instead of container_of() to
> deal with rbtree.

That is OK but I think 'container_of' is more clear.

Roger, thoughts?

> 
> Signed-off-by: Geliang Tang <geliangtang@...il.com>
> ---
>  drivers/block/xen-blkback/blkback.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c
> index 726c32e..7e59fae 100644
> --- a/drivers/block/xen-blkback/blkback.c
> +++ b/drivers/block/xen-blkback/blkback.c
> @@ -191,10 +191,10 @@ static void make_response(struct xen_blkif_ring *ring, u64 id,
>  			  unsigned short op, int st);
>  
>  #define foreach_grant_safe(pos, n, rbtree, node) \
> -	for ((pos) = container_of(rb_first((rbtree)), typeof(*(pos)), node), \
> +	for ((pos) = rb_entry(rb_first((rbtree)), typeof(*(pos)), node), \
>  	     (n) = (&(pos)->node != NULL) ? rb_next(&(pos)->node) : NULL; \
>  	     &(pos)->node != NULL; \
> -	     (pos) = container_of(n, typeof(*(pos)), node), \
> +	     (pos) = rb_entry(n, typeof(*(pos)), node), \
>  	     (n) = (&(pos)->node != NULL) ? rb_next(&(pos)->node) : NULL)
>  
>  
> @@ -223,7 +223,7 @@ static int add_persistent_gnt(struct xen_blkif_ring *ring,
>  	/* Figure out where to put new node */
>  	new = &ring->persistent_gnts.rb_node;
>  	while (*new) {
> -		this = container_of(*new, struct persistent_gnt, node);
> +		this = rb_entry(*new, struct persistent_gnt, node);
>  
>  		parent = *new;
>  		if (persistent_gnt->gnt < this->gnt)
> @@ -254,7 +254,7 @@ static struct persistent_gnt *get_persistent_gnt(struct xen_blkif_ring *ring,
>  
>  	node = ring->persistent_gnts.rb_node;
>  	while (node) {
> -		data = container_of(node, struct persistent_gnt, node);
> +		data = rb_entry(node, struct persistent_gnt, node);
>  
>  		if (gref < data->gnt)
>  			node = node->rb_left;
> -- 
> 2.9.3
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ