linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] FS: nfs: removed goto statement
@ 2022-05-19 22:51 Javier Abrego
  2022-05-19 23:49 ` Frank van der Linden
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Javier Abrego @ 2022-05-19 22:51 UTC (permalink / raw)
  To: trond.myklebust, anna; +Cc: linux-nfs, linux-kernel, javier.abrego.lorente

In this function goto can be replaced. Avoiding goto will improve the
readability

Signed-off-by: Javier Abrego<javier.abrego.lorente@gmail.com>
---
 fs/nfs/nfs42xattr.c | 32 +++++++++++++-------------------
 1 file changed, 13 insertions(+), 19 deletions(-)

diff --git a/fs/nfs/nfs42xattr.c b/fs/nfs/nfs42xattr.c
index e7b34f7e0..2fc806454 100644
--- a/fs/nfs/nfs42xattr.c
+++ b/fs/nfs/nfs42xattr.c
@@ -743,25 +743,19 @@ void nfs4_xattr_cache_set_list(struct inode *inode, const char *buf,
 	struct nfs4_xattr_entry *entry;
 
 	cache = nfs4_xattr_get_cache(inode, 1);
-	if (cache == NULL)
-		return;
-
-	entry = nfs4_xattr_alloc_entry(NULL, buf, NULL, buflen);
-	if (entry == NULL)
-		goto out;
-
-	/*
-	 * This is just there to be able to get to bucket->cache,
-	 * which is obviously the same for all buckets, so just
-	 * use bucket 0.
-	 */
-	entry->bucket = &cache->buckets[0];
-
-	if (!nfs4_xattr_set_listcache(cache, entry))
-		kref_put(&entry->ref, nfs4_xattr_free_entry_cb);
-
-out:
-	kref_put(&cache->ref, nfs4_xattr_free_cache_cb);
+	if (cache == NULL) {
+		kref_put(&cache->ref, nfs4_xattr_free_cache_cb);
+	} else {
+	       /*
+		* This is just there to be able to get to bucket->cache,
+		* which is obviously the same for all buckets, so just
+		* use bucket 0.
+		*/
+		entry->bucket = &cache->buckets[0];
+
+		if (!nfs4_xattr_set_listcache(cache, entry))
+			kref_put(&entry->ref, nfs4_xattr_free_entry_cb);
+	}
 }
 
 /*
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread
* [PATCH] FS: nfs: removed goto statement
@ 2022-05-20  8:50 Javier Abrego
  0 siblings, 0 replies; 7+ messages in thread
From: Javier Abrego @ 2022-05-20  8:50 UTC (permalink / raw)
  To: trond.myklebust, anna; +Cc: linux-nfs, linux-kernel, javier.abrego.lorente

In this function goto can be replaced. Avoiding goto will improve the
readability

Signed-off-by: Javier Abrego<javier.abrego.lorente@gmail.com>
---
 fs/nfs/nfs42xattr.c | 28 +++++++++++++---------------
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/fs/nfs/nfs42xattr.c b/fs/nfs/nfs42xattr.c
index e7b34f7e0..9bf3a88fd 100644
--- a/fs/nfs/nfs42xattr.c
+++ b/fs/nfs/nfs42xattr.c
@@ -747,21 +747,19 @@ void nfs4_xattr_cache_set_list(struct inode *inode, const char *buf,
 		return;
 
 	entry = nfs4_xattr_alloc_entry(NULL, buf, NULL, buflen);
-	if (entry == NULL)
-		goto out;
-
-	/*
-	 * This is just there to be able to get to bucket->cache,
-	 * which is obviously the same for all buckets, so just
-	 * use bucket 0.
-	 */
-	entry->bucket = &cache->buckets[0];
-
-	if (!nfs4_xattr_set_listcache(cache, entry))
-		kref_put(&entry->ref, nfs4_xattr_free_entry_cb);
-
-out:
-	kref_put(&cache->ref, nfs4_xattr_free_cache_cb);
+	if (entry == NULL) {
+		kref_put(&cache->ref, nfs4_xattr_free_cache_cb);
+	} else {
+	       /*
+		* This is just there to be able to get to bucket->cache,
+		* which is obviously the same for all buckets, so just
+		* use bucket 0.
+		*/
+		entry->bucket = &cache->buckets[0];
+
+		if (!nfs4_xattr_set_listcache(cache, entry))
+			kref_put(&entry->ref, nfs4_xattr_free_entry_cb);
+	}
 }
 
 /*
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread
* [PATCH] FS: nfs: removed goto statement
@ 2022-05-20 11:57 Javier Abrego
  2022-05-20 12:00 ` Javier Abrego Lorente
  0 siblings, 1 reply; 7+ messages in thread
From: Javier Abrego @ 2022-05-20 11:57 UTC (permalink / raw)
  To: trond.myklebust, anna; +Cc: linux-nfs, linux-kernel, javier.abrego.lorente

In this function goto can be replaced. Avoiding goto will improve the
readability

Signed-off-by: Javier Abrego<javier.abrego.lorente@gmail.com>
---
 fs/nfs/nfs42xattr.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/fs/nfs/nfs42xattr.c b/fs/nfs/nfs42xattr.c
index e7b34f7e0..78130462c 100644
--- a/fs/nfs/nfs42xattr.c
+++ b/fs/nfs/nfs42xattr.c
@@ -747,20 +747,18 @@ void nfs4_xattr_cache_set_list(struct inode *inode, const char *buf,
 		return;
 
 	entry = nfs4_xattr_alloc_entry(NULL, buf, NULL, buflen);
-	if (entry == NULL)
-		goto out;
-
-	/*
-	 * This is just there to be able to get to bucket->cache,
-	 * which is obviously the same for all buckets, so just
-	 * use bucket 0.
-	 */
-	entry->bucket = &cache->buckets[0];
-
-	if (!nfs4_xattr_set_listcache(cache, entry))
-		kref_put(&entry->ref, nfs4_xattr_free_entry_cb);
+	if (entry != NULL) {
+	       /*
+		* This is just there to be able to get to bucket->cache,
+		* which is obviously the same for all buckets, so just
+		* use bucket 0.
+		*/
+		entry->bucket = &cache->buckets[0];
+
+		if (!nfs4_xattr_set_listcache(cache, entry))
+			kref_put(&entry->ref, nfs4_xattr_free_entry_cb);
+	}
 
-out:
 	kref_put(&cache->ref, nfs4_xattr_free_cache_cb);
 }
 
-- 
2.25.1


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

end of thread, other threads:[~2022-05-20 12:01 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-19 22:51 [PATCH] FS: nfs: removed goto statement Javier Abrego
2022-05-19 23:49 ` Frank van der Linden
2022-05-20  0:18 ` Trond Myklebust
2022-05-20  3:58 ` kernel test robot
  -- strict thread matches above, loose matches on Subject: below --
2022-05-20  8:50 Javier Abrego
2022-05-20 11:57 Javier Abrego
2022-05-20 12:00 ` Javier Abrego Lorente

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).