[Linux-cachefs] [PATCH 9/16] fs/fscache: Remove unnecessary error code assignment

Julia Lawall julia at diku.dk
Mon Aug 16 16:27:14 UTC 2010


From: Julia Lawall <julia at diku.dk>

In each case, the value of ret is not used.  If an error occurs, -ENOBUFS
is returned explicitly.

The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@r@
local idexpression x;
constant C;
@@

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

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

---
 fs/fscache/page.c |    2 --
 1 file changed, 2 deletions(-)

diff --git a/fs/fscache/page.c b/fs/fscache/page.c
index 41c441c..33538ed 100644
--- a/fs/fscache/page.c
+++ b/fs/fscache/page.c
@@ -784,7 +784,6 @@ int __fscache_write_page(struct fscache_cookie *cookie,
 	if (ret < 0)
 		goto nomem_free;
 
-	ret = -ENOBUFS;
 	spin_lock(&cookie->lock);
 
 	if (hlist_empty(&cookie->backing_objects))
@@ -854,7 +853,6 @@ submit_failed:
 	radix_tree_delete(&cookie->stores, page->index);
 	spin_unlock(&cookie->stores_lock);
 	page_cache_release(page);
-	ret = -ENOBUFS;
 	goto nobufs;
 
 nobufs_unlock_obj:




More information about the Linux-cachefs mailing list