Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1272184 > unrolled thread

[PATCH] locks: use list_first_entry_or_null()

Started byGeliang Tang <geliangtang@163.com>
First post2015-11-18 14:50 +0100
Last post2015-11-18 15:30 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] locks: use list_first_entry_or_null() Geliang Tang <geliangtang@163.com> - 2015-11-18 14:50 +0100
    Re: [PATCH] locks: use list_first_entry_or_null() Jeff Layton <jlayton@poochiereds.net> - 2015-11-18 15:30 +0100

#1272184 — [PATCH] locks: use list_first_entry_or_null()

FromGeliang Tang <geliangtang@163.com>
Date2015-11-18 14:50 +0100
Subject[PATCH] locks: use list_first_entry_or_null()
Message-ID<qwbhv-3zI-17@gated-at.bofh.it>
Simplify the code with list_first_entry_or_null().

Signed-off-by: Geliang Tang <geliangtang@163.com>
---
 fs/locks.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/fs/locks.c b/fs/locks.c
index 86c9467..d2ee8e3 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -1505,12 +1505,10 @@ void lease_get_mtime(struct inode *inode, struct timespec *time)
 	ctx = smp_load_acquire(&inode->i_flctx);
 	if (ctx && !list_empty_careful(&ctx->flc_lease)) {
 		spin_lock(&ctx->flc_lock);
-		if (!list_empty(&ctx->flc_lease)) {
-			fl = list_first_entry(&ctx->flc_lease,
-						struct file_lock, fl_list);
-			if (fl->fl_type == F_WRLCK)
-				has_lease = true;
-		}
+		fl = list_first_entry_or_null(&ctx->flc_lease,
+					      struct file_lock, fl_list);
+		if (fl && (fl->fl_type == F_WRLCK))
+			has_lease = true;
 		spin_unlock(&ctx->flc_lock);
 	}
 
-- 
2.5.0


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1272212

FromJeff Layton <jlayton@poochiereds.net>
Date2015-11-18 15:30 +0100
Message-ID<qwbUe-445-3@gated-at.bofh.it>
In reply to#1272184
On Wed, 18 Nov 2015 21:40:33 +0800
Geliang Tang <geliangtang@163.com> wrote:

> Simplify the code with list_first_entry_or_null().
> 
> Signed-off-by: Geliang Tang <geliangtang@163.com>
> ---
>  fs/locks.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/locks.c b/fs/locks.c
> index 86c9467..d2ee8e3 100644
> --- a/fs/locks.c
> +++ b/fs/locks.c
> @@ -1505,12 +1505,10 @@ void lease_get_mtime(struct inode *inode, struct timespec *time)
>  	ctx = smp_load_acquire(&inode->i_flctx);
>  	if (ctx && !list_empty_careful(&ctx->flc_lease)) {
>  		spin_lock(&ctx->flc_lock);
> -		if (!list_empty(&ctx->flc_lease)) {
> -			fl = list_first_entry(&ctx->flc_lease,
> -						struct file_lock, fl_list);
> -			if (fl->fl_type == F_WRLCK)
> -				has_lease = true;
> -		}
> +		fl = list_first_entry_or_null(&ctx->flc_lease,
> +					      struct file_lock, fl_list);
> +		if (fl && (fl->fl_type == F_WRLCK))
> +			has_lease = true;
>  		spin_unlock(&ctx->flc_lock);
>  	}
>  

Looks fine. I'll merge it for v4.5.

Thanks!
-- 
Jeff Layton <jlayton@poochiereds.net>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web