Skip to content

Commit b428081

Browse files
Jiapeng Chongdhowells
authored andcommitted
afs: Remove redundant assignment to ret
Variable ret is set to -ENOENT and -ENOMEM but this value is never read as it is overwritten or not used later on, hence it is a redundant assignment and can be removed. Cleans up the following clang-analyzer warning: fs/afs/dir.c:2014:4: warning: Value stored to 'ret' is never read [clang-analyzer-deadcode.DeadStores]. fs/afs/dir.c:659:2: warning: Value stored to 'ret' is never read [clang-analyzer-deadcode.DeadStores]. [DH made the following modifications: - In afs_rename(), -ENOMEM should be placed in op->error instead of ret, rather than the assignment being removed entirely. afs_put_operation() will pick it up from there and return it. - If afs_sillyrename() fails, its error code should be placed in op->error rather than in ret also. ] Fixes: e49c7b2 ("afs: Build an abstraction around an "operation" concept") Reported-by: Abaci Robot <[email protected]> Signed-off-by: Jiapeng Chong <[email protected]> Signed-off-by: David Howells <[email protected]> Reviewed-by: Marc Dionne <[email protected]> cc: [email protected] Link: https://lore.kernel.org/r/1619691492-83866-1-git-send-email-jiapeng.chong@linux.alibaba.com Link: https://lore.kernel.org/r/162609465444.3133237.7562832521724298900.stgit@warthog.procyon.org.uk/ # v1 Link: https://lore.kernel.org/r/162610729052.3408253.17364333638838151299.stgit@warthog.procyon.org.uk/ # v2
1 parent 5a97247 commit b428081

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

fs/afs/dir.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,6 @@ static int afs_do_lookup_one(struct inode *dir, struct dentry *dentry,
656656
return ret;
657657
}
658658

659-
ret = -ENOENT;
660659
if (!cookie.found) {
661660
_leave(" = -ENOENT [not found]");
662661
return -ENOENT;
@@ -2020,17 +2019,20 @@ static int afs_rename(struct user_namespace *mnt_userns, struct inode *old_dir,
20202019

20212020
if (d_count(new_dentry) > 2) {
20222021
/* copy the target dentry's name */
2023-
ret = -ENOMEM;
20242022
op->rename.tmp = d_alloc(new_dentry->d_parent,
20252023
&new_dentry->d_name);
2026-
if (!op->rename.tmp)
2024+
if (!op->rename.tmp) {
2025+
op->error = -ENOMEM;
20272026
goto error;
2027+
}
20282028

20292029
ret = afs_sillyrename(new_dvnode,
20302030
AFS_FS_I(d_inode(new_dentry)),
20312031
new_dentry, op->key);
2032-
if (ret)
2032+
if (ret) {
2033+
op->error = ret;
20332034
goto error;
2035+
}
20342036

20352037
op->dentry_2 = op->rename.tmp;
20362038
op->rename.rehash = NULL;

0 commit comments

Comments
 (0)