Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3110145pxv; Mon, 12 Jul 2021 09:30:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxb6uLQZ7aTlZKXMFLao/BsM/GCSSRzbXc/qs0Gf7dhT1eQRg6XcnnxUcQaAuhZmrw07oIJ X-Received: by 2002:a6b:5c07:: with SMTP id z7mr33663131ioh.26.1626107418925; Mon, 12 Jul 2021 09:30:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626107418; cv=none; d=google.com; s=arc-20160816; b=B+6wLUH8dNsW5BdszVc7oC6AJC3tjAeURGGG3Ub/s344zQS3s3MPi74CNhNhAyw5J/ QJBDxkCfBpGTzhH5+Od1yKeMY+8pb6ZJ3QxsHJMF/EHdOkMxNsIChqZBqlp5A2qDNZu3 jU+pPONfMHQl148f2jxK1x74NPVEIldziTj1LxeIgmSGfLcMbtorqerJogCTbPcsZXkH cEeP5vWMOXQVFOKRj8QoEfqTer45ngz6F4x6g7AHtJaWxceG6Gz862P6Amrg7ydO/ksp uquteMTwN07c5Rmm5gb9dBlFSGn0wLbZGtwrTuJRqRo5r0YsorAg19Hs013ijNGhtsGQ +8Lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:organization:dkim-signature; bh=5E7IshE9NLQ2Kj2GuNhx4kqMxjYIKwnvKCJI5uNcwyg=; b=xU0cevEn2/5LV6Kl3dEP6MJ8lwSBG1DdapLs9U+206KwIGONCyblUi2Aei6pfMSKuH gCj2v2bemTIyx9+plOc3lYbiO7CJma/IuVQkAdvxsAYR0OBLlP3YfTprSUn4K0uUbIfw Mlb3MBmHA//F0oqpOt8gIagz1RQdFI3rBUY1VMnbZs0TvN4RozfbXjpg3Szkz7u0VuVo R+PnSfBpV9WdD1Y/ZUAKCmv0Ry94m5hpIgU0ce5aI0GekSaDsoPvreviPiXr7LfusfU6 ROH5zH8ijcp77k02jgdGcFjdYS/dMfuGR/kOhevn6cCC9NJShQ210Jx+Pa/0XhpCvjRd aOqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=HLeEXmyl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i13si20347362ilm.45.2021.07.12.09.30.06; Mon, 12 Jul 2021 09:30:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=HLeEXmyl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233939AbhGLQbE (ORCPT + 99 others); Mon, 12 Jul 2021 12:31:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:31012 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233466AbhGLQbE (ORCPT ); Mon, 12 Jul 2021 12:31:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626107295; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5E7IshE9NLQ2Kj2GuNhx4kqMxjYIKwnvKCJI5uNcwyg=; b=HLeEXmylGFi/FQxY/TDcKxiiHsU870z6VNiVVeVULzc2qm/ZEYRcxNCyOsjhlHkAfatHFw YqeR3ChwnKHjo0rHvajPepk/ul1zdMk5RqacjbNGasU7dZmXZ6cUw/jXcRsCOlPA6kaX9W VW6Sxw8aL9bqgE8Y+oZk/5ohUr4DHUE= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-362-igQ4jQStPM6jHKiyjyH7YA-1; Mon, 12 Jul 2021 12:28:13 -0400 X-MC-Unique: igQ4jQStPM6jHKiyjyH7YA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 958C3800C78; Mon, 12 Jul 2021 16:28:12 +0000 (UTC) Received: from warthog.procyon.org.uk (ovpn-118-19.rdu2.redhat.com [10.10.118.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5523110023B5; Mon, 12 Jul 2021 16:28:11 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [PATCH v2 4/4] afs: Remove redundant assignment to ret From: David Howells To: linux-afs@lists.infradead.org Cc: Abaci Robot , Jiapeng Chong , Marc Dionne , dhowells@redhat.com, Marc Dionne , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Date: Mon, 12 Jul 2021 17:28:10 +0100 Message-ID: <162610729052.3408253.17364333638838151299.stgit@warthog.procyon.org.uk> In-Reply-To: <162610726011.3408253.2771348573083023654.stgit@warthog.procyon.org.uk> References: <162610726011.3408253.2771348573083023654.stgit@warthog.procyon.org.uk> User-Agent: StGit/0.23 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jiapeng Chong 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 Signed-off-by: Jiapeng Chong Signed-off-by: David Howells Reviewed-by: Marc Dionne cc: linux-afs@lists.infradead.org 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 --- 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;