All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Simmons <jsimmons@infradead.org>
To: lustre-devel@lists.lustre.org
Subject: [lustre-devel] [PATCH 2/6] lustre: lnet/config: convert list_for_each to list_for_each_entry
Date: Thu, 2 Aug 2018 04:13:09 +0100 (BST)	[thread overview]
Message-ID: <alpine.LFD.2.21.1808020412580.5677@casper.infradead.org> (raw)
In-Reply-To: <153292233958.26104.10972399803477314475.stgit@noble>


> This conversion to list_for_each_entry isn't quite trivial
> as the 'tmp' loop variables are used elsewhere in the function.
> This means we cannot just delete them, and so must inspect the
> code to ensure the values aren't used elsewhere - they aren't.
> 
> Also we need to introduce new loop variables: ltb1 and ltb2 as
> the lnet_text_buf was the some for both the original (nested) loops.

Reviewed-by: James Simmons <jsimmons@infradead.org>
 
> Signed-off-by: NeilBrown <neilb@suse.com>
> ---
>  drivers/staging/lustre/lnet/lnet/config.c |   11 +++++------
>  1 file changed, 5 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/staging/lustre/lnet/lnet/config.c b/drivers/staging/lustre/lnet/lnet/config.c
> index 96336ecdacaf..091c4f714e84 100644
> --- a/drivers/staging/lustre/lnet/lnet/config.c
> +++ b/drivers/staging/lustre/lnet/lnet/config.c
> @@ -662,6 +662,7 @@ lnet_parse_route(char *str, int *im_a_router)
>  	__u32 net;
>  	lnet_nid_t nid;
>  	struct lnet_text_buf *ltb;
> +	struct lnet_text_buf *ltb1, *ltb2;
>  	int rc;
>  	char *sep;
>  	char *token = str;
> @@ -760,14 +761,12 @@ lnet_parse_route(char *str, int *im_a_router)
>  	LASSERT(!list_empty(&nets));
>  	LASSERT(!list_empty(&gateways));
>  
> -	list_for_each(tmp1, &nets) {
> -		ltb = list_entry(tmp1, struct lnet_text_buf, ltb_list);
> -		net = libcfs_str2net(ltb->ltb_text);
> +	list_for_each_entry(ltb1, &nets, ltb_list) {
> +		net = libcfs_str2net(ltb1->ltb_text);
>  		LASSERT(net != LNET_NIDNET(LNET_NID_ANY));
>  
> -		list_for_each(tmp2, &gateways) {
> -			ltb = list_entry(tmp2, struct lnet_text_buf, ltb_list);
> -			nid = libcfs_str2nid(ltb->ltb_text);
> +		list_for_each_entry(ltb2, &gateways, ltb_list) {
> +			nid = libcfs_str2nid(ltb2->ltb_text);
>  			LASSERT(nid != LNET_NID_ANY);
>  
>  			if (lnet_islocalnid(nid)) {
> 
> 
> 

  parent reply	other threads:[~2018-08-02  3:13 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-30  3:45 [lustre-devel] [PATCH 0/6] lustre: convert list_for_each() to list_for_each_entry() NeilBrown
2018-07-30  3:45 ` [lustre-devel] [PATCH 4/6] lustre: convert list_for_each in ksocknal_close_conn_locked() NeilBrown
2018-08-02  3:13   ` James Simmons
2018-07-30  3:45 ` [lustre-devel] [PATCH 1/6] lustre: convert list_for_each() to list_for_each_entry() NeilBrown
2018-07-30 20:49   ` Andreas Dilger
2018-08-02  3:12   ` James Simmons
2018-07-30  3:45 ` [lustre-devel] [PATCH 3/6] lustre: convert list_for_each in ksocknal_create_routes NeilBrown
2018-08-02  3:13   ` James Simmons
2018-07-30  3:45 ` [lustre-devel] [PATCH 2/6] lustre: lnet/config: convert list_for_each to list_for_each_entry NeilBrown
2018-07-30 20:42   ` Andreas Dilger
2018-08-02  3:13   ` James Simmons [this message]
2018-07-30  3:45 ` [lustre-devel] [PATCH 6/6] lustre: convert list_for_each() in ksocknal_debug_peerhash() NeilBrown
2018-07-30 21:09   ` Andreas Dilger
2018-08-02  3:14   ` James Simmons
2018-07-30  3:45 ` [lustre-devel] [PATCH 5/6] lustre: convert list_for_each() in ksocknal_push_peer() NeilBrown
2018-08-02  3:14   ` James Simmons
2018-08-02  3:16 ` [lustre-devel] [PATCH 0/6] lustre: convert list_for_each() to list_for_each_entry() James Simmons

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.LFD.2.21.1808020412580.5677@casper.infradead.org \
    --to=jsimmons@infradead.org \
    --cc=lustre-devel@lists.lustre.org \
    /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.