Skip to contentSkip to conversation

mm/shmem.c: Clean code by removing unnecessary assignment

PATCH Applied [email protected] 3 participants 3 messages Mar 1, 2020 – Mar 2, 2020

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

PATCH 1/1 mm/shmem.c: Clean code by removing unnecessary assignment

From: Mateusz Nosek <[email protected]>

Previously 0 was assigned to variable 'error'
but the variable was never read before reassignemnt later. So the assignment can be removed.

---
 mm/shmem.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
mm/shmem.c +3 -6
index 31b4bcc95f17..84eb14f5509c 100644
@@ -3116,12 +3116,9 @@ static int shmem_symlink(struct inode *dir, struct dentry *dentry, const char *s
 
 	error = security_inode_init_security(inode, dir, &dentry->d_name,
 					     shmem_initxattrs, NULL);
-	if (error) {
-		if (error != -EOPNOTSUPP) {
-			iput(inode);
-			return error;
-		}
-		error = 0;
+	if (error && error != -EOPNOTSUPP) {
+		iput(inode);
+		return error;
 	}
 
 	inode->i_size = len-1;
Signature · 1 line
2.17.1
Acked-by on v1 1/1
#2 lore raw
In reply to [email protected]
Quoted 32 lines

From: Mateusz Nosek <[email protected]>

Previously 0 was assigned to variable 'error'
but the variable was never read before reassignemnt later. So the assignment can be removed.

---
 mm/shmem.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
mm/shmem.c +3 -7
index 31b4bcc95f17..84eb14f5509c 100644
@@ -3116,12 +3116,9 @@ static int shmem_symlink(struct inode *dir, struct dentry *dentry, const char *s
 
        error = security_inode_init_security(inode, dir, &dentry->d_name,
                                             shmem_initxattrs, NULL);
-       if (error) {
-               if (error != -EOPNOTSUPP) {
-                       iput(inode);
-                       return error;
-               }
-               error = 0;
+       if (error && error != -EOPNOTSUPP) {
+               iput(inode);
+               return error;
        }
 
        inode->i_size = len-1;
--
Quoted 1 line

2.17.1

Quoted 2 lines