Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2949238pxv; Mon, 12 Jul 2021 06:00:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwMB62b81Kix/+GAil2NS8YJ/AfRZrRGqPYXUEUKknMt23dTmPqqNA+zMwIthsLzxYMRsbi X-Received: by 2002:a05:6638:2390:: with SMTP id q16mr36607135jat.59.1626094802144; Mon, 12 Jul 2021 06:00:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626094802; cv=none; d=google.com; s=arc-20160816; b=j6i9I3ls18XGDS1t4SGx9g7jqvRrxyEYiQ8BtIYXQme4D+zZ7T7F+uOiRMfyNLz5pY 85ryRV6NV1kRCb6h203z+u+179/HL8QGdz81iJzfpP9GI54PkNVGKW4sqOIp9IrwQnGb XqBaL7b1B0+CLnyUOLTVUvIIZmW1IgVpD/Due7TKKMnvCFvT4Q5/Q/bnbUQnCQDO9aLe ud57gWwn5nfUZcXDTQKZt+sWuk7idZFDnBH0grUVd3GDoZcgQ1yM3aLRPsRqIC41jsuR YBBTuxQCNSEvtZo149+VrAar+a1QKU9z+vo8CYBhPrUo0wNtToHKiTRQcCt7BNPUyNiC RUDw== 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=61t+gIjESYmgaXgLkp+R0buthxKeNg7bBJsRPr9kTTw=; b=r0kT3Yli8U5t6eQXWTrvek/KHG2mIX7/FCq+g2gAT2jurhkcBFaFMLzyjrctvQp2Eq 4Bz9A1W86JkLbQSd/+vUMPmSbci8wJVp/RCkG98gi0DBfPvcX79keqWG7opfbmUmlh1/ Y1mG0bONyQqGrMdUuZr554LWoMPLdpREdurHhSkyHFMj5OgQniMcU2ZyGKbz9EfmdjOv HIFk96VxyRKj1m97DPYGCZIspF/rZa+Ldl75PTeILY43rYIT0FsARR3EMsOTSfMfRkOZ 7f5gXdLpjr72pN1oLoWp25lin4zHeawMU6tb7fTnox8vZ+Kqly0UyRA9HugFnkpBAV5F YynA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eLkS4lGY; 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 j10si18800336ils.31.2021.07.12.05.59.50; Mon, 12 Jul 2021 06:00:02 -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=eLkS4lGY; 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 S234290AbhGLNA3 (ORCPT + 99 others); Mon, 12 Jul 2021 09:00:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:30951 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234293AbhGLNA1 (ORCPT ); Mon, 12 Jul 2021 09:00:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1626094659; 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=61t+gIjESYmgaXgLkp+R0buthxKeNg7bBJsRPr9kTTw=; b=eLkS4lGYF0MMuKeuhDCVyhkCiVOFlfo7PzMNk6nNrYuYPyQPgiXnEtYVXSf8pwGapikBDP fmTgjyJQUKmKYwyE7Mvax7jWhLdDUx9vlDsfLD8Dnq8gPvjnOWUFQF3fsj+e9lKVlEMf6M qy9F5kweNU6yilDRj9D2KmxErjdfajA= 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-216-bzPbo1d_PpmdhLNtvGW5EA-1; Mon, 12 Jul 2021 08:57:37 -0400 X-MC-Unique: bzPbo1d_PpmdhLNtvGW5EA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 84BD5801107; Mon, 12 Jul 2021 12:57:36 +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 3DCA85C1D1; Mon, 12 Jul 2021 12:57:35 +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 3/3] afs: Remove redundant assignment to ret From: David Howells To: linux-afs@lists.infradead.org Cc: Abaci Robot , Jiapeng Chong , dhowells@redhat.com, Marc Dionne , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Date: Mon, 12 Jul 2021 13:57:34 +0100 Message-ID: <162609465444.3133237.7562832521724298900.stgit@warthog.procyon.org.uk> In-Reply-To: <162609463116.3133237.11899334298425929820.stgit@warthog.procyon.org.uk> References: <162609463116.3133237.11899334298425929820.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.79 on 10.5.11.16 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 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;