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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <58ac50d1-0c5e-4dc3-435a-bbd0d4183a4a@redhat.com>
Date:   Wed, 21 Dec 2016 22:33:32 -0500
From:   Doug Ledford <dledford@...hat.com>
To:     Geliang Tang <geliangtang@...il.com>,
        Santosh Shilimkar <santosh.shilimkar@...cle.com>,
        "David S. Miller" <davem@...emloft.net>
Cc:     netdev@...r.kernel.org, linux-rdma@...r.kernel.org,
        rds-devel@....oracle.com, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] RDS: use rb_entry()

On 12/20/2016 9:02 AM, 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>
> ---
>  net/rds/rdma.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/rds/rdma.c b/net/rds/rdma.c
> index 4c93bad..ea96114 100644
> --- a/net/rds/rdma.c
> +++ b/net/rds/rdma.c
> @@ -135,7 +135,7 @@ void rds_rdma_drop_keys(struct rds_sock *rs)
>  	/* Release any MRs associated with this socket */
>  	spin_lock_irqsave(&rs->rs_rdma_lock, flags);
>  	while ((node = rb_first(&rs->rs_rdma_keys))) {
> -		mr = container_of(node, struct rds_mr, r_rb_node);
> +		mr = rb_entry(node, struct rds_mr, r_rb_node);
>  		if (mr->r_trans == rs->rs_transport)
>  			mr->r_invalidate = 0;
>  		rb_erase(&mr->r_rb_node, &rs->rs_rdma_keys);
> 

Dave, I know you already took this, but am I the only one that thinks
these patches are a step backwards?  They claim to promote readability,
but I disagree that they actually do so.  The original code used the
container_of() API with three specific arguments that made sense in the
context of a function named container_of().  The new API uses the exact
same three arguments, but they no longer make the same sense just
comparing the arguments to the function name.  The relationship has been
lost.  And on top of that, if you do this for all of the standard things
in the kernel (rb_entry, list_item, etc.), then you've created a myriad
of APIs that all duplicate one functional API that made sense.  Is it
really an improvement to go from one generic function that makes sense
and works everywhere to multiple implementations of basically just name
wrappers that mean you now need to know many aliases for the same
function?  How do we justify API bloat like this as better or easier to
read when it requires useless API memorization?

-- 
Doug Ledford <dledford@...hat.com>
    GPG Key ID: B826A3330E572FDD
    Key fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD



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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ