All of lore.kernel.org
 help / color / mirror / Atom feed
From: Julia Lawall <julia.lawall@lip6.fr>
To: Haneen Mohammed <hamohammed.sa@gmail.com>
Cc: outreachy-kernel <outreachy-kernel@googlegroups.com>,
	 Oleg Drokin <oleg.drokin@intel.com>,
	 Andreas Dilger <andreas.dilger@intel.com>,
	 James Simmons <jsimmons@infradead.org>,
	 Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Subject: Re: [Outreachy kernel] [PATCH] staging: lustre: lnet: replace list_for_each with list_for_each_entry
Date: Sat, 23 Sep 2017 07:49:30 +0200 (CEST)	[thread overview]
Message-ID: <alpine.DEB.2.20.1709230749160.2139@hadrien> (raw)
In-Reply-To: <20170923022239.GA10771@Haneen>



On Fri, 22 Sep 2017, Haneen Mohammed wrote:

> Replace use of the combination of list_for_each() and list_entry() with
> list_for_each_entry() to simplify the code and remove variables that are
> used only in list_for_each().
> Issue found and corrected using Coccinelle script:
>
> @r@
> expression head, member, e;
> type T1, T2, T3;
> iterator name list_for_each, list_for_each_entry;
> identifier pos, var;
> @@
>
> -T1 *pos;
> ...when!=pos
>
> -list_for_each(pos, head)
> +list_for_each_entry(var, head, member)
> {
> ...when!=pos
>    when!=T3 *var;
> -var = list_entry(pos, T2, member);
> ...when!=pos
> }
> ...when!=pos
>
> Signed-off-by: Haneen Mohammed <hamohammed.sa@gmail.com>

Acked-by: Julia Lawall <julia.lawall@lip6.fr>


> ---
>  drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c | 14 +++-----------
>  1 file changed, 3 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
> index fbbd8a5..d0ee58d 100644
> --- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
> +++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
> @@ -176,12 +176,9 @@ struct ksock_peer *
>  ksocknal_find_peer_locked(struct lnet_ni *ni, struct lnet_process_id id)
>  {
>  	struct list_head *peer_list = ksocknal_nid2peerlist(id.nid);
> -	struct list_head *tmp;
>  	struct ksock_peer *peer;
>
> -	list_for_each(tmp, peer_list) {
> -		peer = list_entry(tmp, struct ksock_peer, ksnp_list);
> -
> +	list_for_each_entry(peer, peer_list, ksnp_list) {
>  		LASSERT(!peer->ksnp_closing);
>
>  		if (peer->ksnp_ni != ni)
> @@ -453,7 +450,6 @@ int
>  ksocknal_add_peer(struct lnet_ni *ni, struct lnet_process_id id, __u32 ipaddr,
>  		  int port)
>  {
> -	struct list_head *tmp;
>  	struct ksock_peer *peer;
>  	struct ksock_peer *peer2;
>  	struct ksock_route *route;
> @@ -491,9 +487,7 @@ ksocknal_add_peer(struct lnet_ni *ni, struct lnet_process_id id, __u32 ipaddr,
>  	}
>
>  	route2 = NULL;
> -	list_for_each(tmp, &peer->ksnp_routes) {
> -		route2 = list_entry(tmp, struct ksock_route, ksnr_list);
> -
> +	list_for_each_entry(route2, &peer->ksnp_routes, ksnr_list) {
>  		if (route2->ksnr_ipaddr == ipaddr)
>  			break;
>
> @@ -1854,12 +1848,10 @@ ksocknal_query(struct lnet_ni *ni, lnet_nid_t nid, unsigned long *when)
>
>  	peer = ksocknal_find_peer_locked(ni, id);
>  	if (peer) {
> -		struct list_head *tmp;
>  		struct ksock_conn *conn;
>  		int bufnob;
>
> -		list_for_each(tmp, &peer->ksnp_conns) {
> -			conn = list_entry(tmp, struct ksock_conn, ksnc_list);
> +		list_for_each_entry(conn, &peer->ksnp_conns, ksnc_list) {
>  			bufnob = conn->ksnc_sock->sk->sk_wmem_queued;
>
>  			if (bufnob < conn->ksnc_tx_bufnob) {
> --
> 2.7.4
>
> --
> You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20170923022239.GA10771%40Haneen.
> For more options, visit https://groups.google.com/d/optout.
>


  reply	other threads:[~2017-09-23  5:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-23  2:22 [PATCH] staging: lustre: lnet: replace list_for_each with list_for_each_entry Haneen Mohammed
2017-09-23  5:49 ` Julia Lawall [this message]
  -- strict thread matches above, loose matches on Subject: below --
2017-09-16  0:41 [PATCH] staging: lustre: lnet: Replace " Haneen Mohammed
2017-09-16 11:23 ` [Outreachy kernel] " Julia Lawall
2017-09-16 16:10   ` Haneen Mohammed
2017-09-16 16:14     ` Julia Lawall
2017-09-16 16:21       ` Haneen Mohammed
2017-09-16 17:04         ` Julia Lawall

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.20.1709230749160.2139@hadrien \
    --to=julia.lawall@lip6.fr \
    --cc=andreas.dilger@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hamohammed.sa@gmail.com \
    --cc=jsimmons@infradead.org \
    --cc=oleg.drokin@intel.com \
    --cc=outreachy-kernel@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.