From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754732AbZGNKeu (ORCPT ); Tue, 14 Jul 2009 06:34:50 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754627AbZGNKet (ORCPT ); Tue, 14 Jul 2009 06:34:49 -0400 Received: from relay3.sgi.com ([192.48.156.57]:47300 "EHLO relay.sgi.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754482AbZGNKes (ORCPT ); Tue, 14 Jul 2009 06:34:48 -0400 To: Julia Lawall Cc: felixb@sgi.com, xfs-masters@oss.sgi.com, xfs@oss.sgi.com, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH 1/2] fs/xfs: Drop unnecessary NULL test References: From: Olaf Weber Date: Tue, 14 Jul 2009 12:34:43 +0200 Message-ID: User-Agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.4.3 (irix) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Julia Lawall writes: > From: Julia Lawall > The result of container_of should not be NULL. In particular, in this case > the argument to the enclosing function has passed though INIT_DELAYED_WORK, > which dereferences it, implying that its container cannot be NULL. Given the defn of container_of() it seems clear that neither its input pointer nor its result should ever be NULL. In this particular case, there is a check for NULL and early exit in xfs_mru_cache_create(), the function that does the INIT_DELAYED_WORK(). Olaf > The semantic match that finds this problem is as follows: > (http://www.emn.fr/x-info/coccinelle/) > // > @@ > expression x,e; > @@ > x = container_of(...) > ... when != x = e > * x == NULL > // > Signed-off-by: Julia Lawall Acked-By: Olaf Weber > --- > fs/xfs/xfs_mru_cache.c | 4 ++-- > 1 files changed, 2 insertions(+), 2 deletions(-) > diff --git a/fs/xfs/xfs_mru_cache.c b/fs/xfs/xfs_mru_cache.c > index 4b0613d..0651ce7 100644 > --- a/fs/xfs/xfs_mru_cache.c > +++ b/fs/xfs/xfs_mru_cache.c > @@ -280,8 +280,8 @@ _xfs_mru_cache_reap( > xfs_mru_cache_t *mru = container_of(work, xfs_mru_cache_t, work.work); > unsigned long now, next; > - ASSERT(mru && mru->lists); > - if (!mru || !mru->lists) > + ASSERT(mru->lists); > + if (!mru->lists) > return; > spin_lock(&mru->lock); -- Olaf Weber SGI Phone: +31(0)30-6696752 Veldzigt 2b Fax: +31(0)30-6696799 Technical Lead 3454 PW de Meern Vnet: 955-7151 Storage Software The Netherlands Email: olaf@sgi.com