Skip to contentSkip to conversation

mm/hugetlbfs: Remove the redundant -ENIVAL return from hugetlbfs_setattr()

PATCH Applied Anshuman Khandual 2 participants 2 messages Sep 29, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm/hugetlbfs: Remove the redundant -ENIVAL return from hugetlbfs_setattr()

There is no need to have a local return code set with -EINVAL when both the conditions following it return error codes appropriately. Just remove the redundant one.

---
 fs/hugetlbfs/inode.c | 1 -
 1 file changed, 1 deletion(-)
fs/hugetlbfs/inode.c +0 -1
index 59073e9..cff3939 100644
@@ -668,7 +668,6 @@ static int hugetlbfs_setattr(struct dentry *dentry, struct iattr *attr)
 		return error;
 
 	if (ia_valid & ATTR_SIZE) {
-		error = -EINVAL;
 		if (attr->ia_size & ~huge_page_mask(h))
 			return -EINVAL;
 		error = hugetlb_vmtruncate(inode, attr->ia_size);
Signature · 7 lines
1.8.5.2

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Reviewed-by on v1 1/1
#1 lore raw

Adding akpm on Cc:

Quoted 15 lines · Anshuman Khandual

There is no need to have a local return code set with -EINVAL when both the conditions following it return error codes appropriately. Just remove the redundant one.

---
 fs/hugetlbfs/inode.c | 1 -
 1 file changed, 1 deletion(-)
fs/hugetlbfs/inode.c +0 -0
index 59073e9..cff3939 100644

fs/hugetlbfs/inode.c static int hugetlbfs_setattr(struct dentry *dentry, struct iattr *attr) · line 673

Quoted 7 lines
fs/hugetlbfs/inode.c +0 -1
@@ -668,7 +668,6 @@ static int hugetlbfs_setattr(struct dentry *dentry, struct iattr *attr)
 		return error;
 
 	if (ia_valid & ATTR_SIZE) {
-		error = -EINVAL;
 		if (attr->ia_size & ~huge_page_mask(h))
 			return -EINVAL;
 		error = hugetlb_vmtruncate(inode, attr->ia_size);

Thanks for noticing.
I would hope the compiler is smarter than the code and optimize this away.

Signature · 7 lines
Mike Kravetz

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>