Skip to contentSkip to conversation

xfs: tidy up xfs_attr_shortform_list

PATCH In review Mateusz Guzik 2 participants 2 messages Mar 2, 2016 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs: tidy up xfs_attr_shortform_list

Remove an unnecessary i == nsbuf test and replace a common label for error handling after sbuf is allocated.

---
 fs/xfs/xfs_attr_list.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)
fs/xfs/xfs_attr_list.c +7 -12
index 4fa1482..7129fbc 100644
@@ -74,7 +74,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
 	xfs_attr_sf_entry_t *sfe;
 	xfs_inode_t *dp;
 	int sbsize, nsbuf, count, i;
-	int error;
+	int error = 0;
 
 	ASSERT(context != NULL);
 	dp = context->dp;
@@ -146,8 +146,8 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
 			XFS_CORRUPTION_ERROR("xfs_attr_shortform_list",
 					     XFS_ERRLEVEL_LOW,
 					     context->dp->i_mount, sfe);
-			kmem_free(sbuf);
-			return -EFSCORRUPTED;
+			error = -EFSCORRUPTED;
+			goto out;
 		}
 
 		sbp->entno = i;
@@ -183,10 +183,6 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
 			break;
 		}
 	}
-	if (i == nsbuf) {
-		kmem_free(sbuf);
-		return 0;
-	}
 
 	/*
 	 * Loop putting entries into the user buffer.
@@ -202,17 +198,16 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
 					sbp->namelen,
 					sbp->valuelen,
 					&sbp->name[sbp->namelen]);
-		if (error) {
-			kmem_free(sbuf);
-			return error;
-		}
+		if (error)
+			break;
 		if (context->seen_enough)
 			break;
 		cursor->offset++;
 	}
 
+out:
 	kmem_free(sbuf);
-	return 0;
+	return error;
 }
 
 STATIC int
Signature · 6 lines
1.8.3.1

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs