From: Marc Dionne <marc.c.dionne@gmail.com>
To: David Howells <dhowells@redhat.com>
Cc: linux-afs@lists.infradead.org,
Abaci Robot <abaci@linux.alibaba.com>,
Jiapeng Chong <jiapeng.chong@linux.alibaba.com>,
linux-fsdevel@vger.kernel.org,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 3/3] afs: Remove redundant assignment to ret
Date: Mon, 12 Jul 2021 11:04:06 -0300 [thread overview]
Message-ID: <CAB9dFdvV-gEfRY_bsF_hBDErWW=9WUCVsGSmkv6XLE=Y-Lh-Hw@mail.gmail.com> (raw)
In-Reply-To: <162609465444.3133237.7562832521724298900.stgit@warthog.procyon.org.uk>
On Mon, Jul 12, 2021 at 9:57 AM David Howells <dhowells@redhat.com> wrote:
>
> From: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
>
> 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: e49c7b2f6de7 ("afs: Build an abstraction around an "operation" concept")
> Reported-by: Abaci Robot <abaci@linux.alibaba.com>
> Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
> Signed-off-by: David Howells <dhowells@redhat.com>
> cc: linux-afs@lists.infradead.org
> Link: https://lore.kernel.org/r/1619691492-83866-1-git-send-email-jiapeng.chong@linux.alibaba.com
> ---
>
> fs/afs/dir.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/fs/afs/dir.c b/fs/afs/dir.c
> index 78719f2f567e..ac829e63c570 100644
> --- a/fs/afs/dir.c
> +++ b/fs/afs/dir.c
> @@ -656,7 +656,6 @@ static int afs_do_lookup_one(struct inode *dir, struct dentry *dentry,
> return ret;
> }
>
> - ret = -ENOENT;
> if (!cookie.found) {
> _leave(" = -ENOENT [not found]");
> return -ENOENT;
> @@ -2020,17 +2019,20 @@ static int afs_rename(struct user_namespace *mnt_userns, struct inode *old_dir,
>
> if (d_count(new_dentry) > 2) {
> /* copy the target dentry's name */
> - ret = -ENOMEM;
> op->rename.tmp = d_alloc(new_dentry->d_parent,
> &new_dentry->d_name);
> - if (!op->rename.tmp)
> + if (!op->rename.tmp) {
> + op->error = -ENOMEM;
> goto error;
> + }
>
> ret = afs_sillyrename(new_dvnode,
> AFS_FS_I(d_inode(new_dentry)),
> new_dentry, op->key);
> - if (ret)
> + if (ret) {
> + op->error = ret;
> goto error;
> + }
>
> op->dentry_2 = op->rename.tmp;
> op->rename.rehash = NULL;
>
>
>
> _______________________________________________
> linux-afs mailing list
> http://lists.infradead.org/mailman/listinfo/linux-afs
Reviewed-by: Marc Dionne <marc.dionne@auristor.com>
Marc
prev parent reply other threads:[~2021-07-12 14:04 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-12 12:57 [PATCH 0/3] afs: Miscellaneous fixes David Howells
2021-07-12 12:57 ` [PATCH 1/3] afs: Fix tracepoint string placement with built-in AFS David Howells
2021-07-12 12:57 ` [PATCH 2/3] afs: check function return David Howells
2021-07-12 14:20 ` Marc Dionne
2021-07-12 15:21 ` David Howells
2021-07-12 12:57 ` [PATCH 3/3] afs: Remove redundant assignment to ret David Howells
2021-07-12 14:04 ` Marc Dionne [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAB9dFdvV-gEfRY_bsF_hBDErWW=9WUCVsGSmkv6XLE=Y-Lh-Hw@mail.gmail.com' \
--to=marc.c.dionne@gmail.com \
--cc=abaci@linux.alibaba.com \
--cc=dhowells@redhat.com \
--cc=jiapeng.chong@linux.alibaba.com \
--cc=linux-afs@lists.infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).