From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756031AbbKROXD (ORCPT ); Wed, 18 Nov 2015 09:23:03 -0500 Received: from mail-qg0-f41.google.com ([209.85.192.41]:33842 "EHLO mail-qg0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755713AbbKROXA (ORCPT ); Wed, 18 Nov 2015 09:23:00 -0500 Date: Wed, 18 Nov 2015 09:22:54 -0500 From: Jeff Layton To: Geliang Tang Cc: Alexander Viro , "J. Bruce Fields" , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] locks: use list_first_entry_or_null() Message-ID: <20151118092254.12975e73@synchrony.poochiereds.net> In-Reply-To: References: X-Mailer: Claws Mail 3.12.0 (GTK+ 2.24.28; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 18 Nov 2015 21:40:33 +0800 Geliang Tang wrote: > Simplify the code with list_first_entry_or_null(). > > Signed-off-by: Geliang Tang > --- > 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