2009-07-27 16:18:26

by Julia Lawall

[permalink] [raw]
Subject: [PATCH 9/12] fs/btrfs: Correct redundant test

From: Julia Lawall <[email protected]>

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 <[email protected]>

---
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);


2009-07-27 16:28:52

by Chris Mason

[permalink] [raw]
Subject: Re: [PATCH 9/12] fs/btrfs: Correct redundant test

On Mon, Jul 27, 2009 at 06:15:05PM +0200, Julia Lawall wrote:
> From: Julia Lawall <[email protected]>
>
> 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