public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 9/12] fs/btrfs: Correct redundant test
@ 2009-07-27 16:15 Julia Lawall
  2009-07-27 16:28 ` Chris Mason
  0 siblings, 1 reply; 2+ messages in thread
From: Julia Lawall @ 2009-07-27 16:15 UTC (permalink / raw)
  To: chris.mason, linux-btrfs, linux-kernel, kernel-janitors

From: Julia Lawall <julia@diku.dk>

dir has already been tested.  It seems that this test should be on the
recently returned value inode.

A simplified version of the semantic match that finds this problem is as
follows: (http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@r exists@
local idexpression x;
expression E;
position p1,p2;
@@

if (x == NULL || ...) { ... when forall
   return ...; }
... when != \(x=E\|x--\|x++\|--x\|++x\|x-=E\|x+=E\|x|=E\|x&=E\|&x\)
(
*x == NULL
|
*x != NULL
)
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>

---
 fs/btrfs/tree-log.c                 |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index c139222..d91b0de 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -797,7 +797,7 @@ static noinline int add_inode_ref(struct btrfs_trans_handle *trans,
 		return -ENOENT;
 
 	inode = read_one_inode(root, key->objectid);
-	BUG_ON(!dir);
+	BUG_ON(!inode);
 
 	ref_ptr = btrfs_item_ptr_offset(eb, slot);
 	ref_end = ref_ptr + btrfs_item_size_nr(eb, slot);

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 9/12] fs/btrfs: Correct redundant test
  2009-07-27 16:15 [PATCH 9/12] fs/btrfs: Correct redundant test Julia Lawall
@ 2009-07-27 16:28 ` Chris Mason
  0 siblings, 0 replies; 2+ messages in thread
From: Chris Mason @ 2009-07-27 16:28 UTC (permalink / raw)
  To: Julia Lawall; +Cc: linux-btrfs, linux-kernel, kernel-janitors

On Mon, Jul 27, 2009 at 06:15:05PM +0200, Julia Lawall wrote:
> From: Julia Lawall <julia@diku.dk>
> 
> dir has already been tested.  It seems that this test should be on the
> recently returned value inode.
> 
> A simplified version of the semantic match that finds this problem is as
> follows: (http://www.emn.fr/x-info/coccinelle/)

Thank you, this is queued up in my tree along with the
other btrfs patches you've sent.

-chris

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-07-27 16:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-27 16:15 [PATCH 9/12] fs/btrfs: Correct redundant test Julia Lawall
2009-07-27 16:28 ` Chris Mason

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox