Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp1055689pxv; Thu, 22 Jul 2021 21:06:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJIzKybNFmr3wCkZGubA6BSP7R5RY7iC5J9iC4/Stetih5BctZtg+hHhiazq/KkZjpxHp/ X-Received: by 2002:a05:6402:1c19:: with SMTP id ck25mr3382615edb.128.1627013163434; Thu, 22 Jul 2021 21:06:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627013163; cv=none; d=google.com; s=arc-20160816; b=ujhBpNYQ6razgaf3DKfqAd6P3CK9v7HLIJMaVBFnTLZXsPe0L2GVT6Y+7vTXg7BWVN vsFYsljV7yDYd31akzWYxc2yhZu64KE6JJ8qiyzyhNxis5bOm549dcUnbkEeDfiA1RbG jWFFk+dkJA61nhSZ7UoTt9/lKxoeKQKqn5Lc7f9+89+SUt2Z4o31LpjitEfSIivBT2KI fQ6PLBISrke3grVy+c5oDqxW6RadHQgg7AsM6Ewn5CVfQUhYVm8i/vH53Npk7agkxvxH VAuXB02pRkPcMhdu3ycLbApwUeWA57FriODeZtm4ussPznHZn94WuvRBDn3FH+wvP5Gw n6ig== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=jsLiQthZGREoAL7dQDqE/96d3qCrf4R4F+tBMK84gHg=; b=TubNWSGAelu7Mf6xMHSNdH08AmUrHpJuLA4MJy0OhVIVwHp31QGxaoeCAVKroi2dYo EusCTW2jBG6pYAwgZi2eWZus4ZE0Y79craSIEFVAH9wzKEhTBLNZhzBBz2tlKLWK6Qbk ndQSdV2PvfwPdxbOPm37MHjwsxL81Vs7DR98KyVmu929GmlVFls8sOZiKKjU5ABPWDMA 8ExMv5N6Zc6WzIs8YZsLyHu+aH1A5ecFCj5Bf70kRaZibd8/H9eXzgIUme5l2jmacfPZ 3rP4Gz9/h+7Qi2rMdADunjS1rifYB0XTeZq8s2jDTCxnjuQL9KnXWhuq4wFGgQ65PzOY uojA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IxLpHrh4; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z16si1853336edm.47.2021.07.22.21.05.40; Thu, 22 Jul 2021 21:06:03 -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=@kernel.org header.s=k20201202 header.b=IxLpHrh4; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233908AbhGWDV7 (ORCPT + 99 others); Thu, 22 Jul 2021 23:21:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:37168 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233858AbhGWDRM (ORCPT ); Thu, 22 Jul 2021 23:17:12 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8F09760C41; Fri, 23 Jul 2021 03:57:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627012666; bh=+tUf8UsEFsnhIbkN1zSKvp4omNtzqg1OVxJOYm4VOpw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IxLpHrh43oPPOI6xIj7CieJok+Q1+fyjOaLPOd61wH6L21I9YI9tCUE5lmll3LbIg r62UY6h0531Q03gE8yddJDVa6rwQU0kN51blqUIEZcv0GTm13U9s7SwF/tawVf1VPd 6XYc4KPncZ3WoqrkVp7X0CpeQvbBkzvzbUPOYJ9aTYrkMgxOIzaHLO/jmgUPT3O3XZ esx2x8qK6S+mg9VBWmLELtAmNnXBQpZINtF+NY/cXUlyOFOC9KGGtQMlJ7I7xtKs/o awfjyo1GTGxe7/DuzFWJCKFHsDznHRAiBUkpFEqNs+qIfRe3CJ+nazg+T+xD9h9BN6 Tq5lr0lIYsIlg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Christoph Hellwig , Leizhen , "Darrick J . Wong" , Matthew Wilcox , Sasha Levin , linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH AUTOSEL 5.13 18/19] iomap: remove the length variable in iomap_seek_hole Date: Thu, 22 Jul 2021 23:57:19 -0400 Message-Id: <20210723035721.531372-18-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210723035721.531372-1-sashal@kernel.org> References: <20210723035721.531372-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christoph Hellwig [ Upstream commit 49694d14ff68fa4b5f86019dbcfb44a8bd213e58 ] The length variable is rather pointless given that it can be trivially deduced from offset and size. Also the initial calculation can lead to KASAN warnings. Signed-off-by: Christoph Hellwig Reported-by: Leizhen (ThunderTown) Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Reviewed-by: Matthew Wilcox (Oracle) Signed-off-by: Sasha Levin --- fs/iomap/seek.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/fs/iomap/seek.c b/fs/iomap/seek.c index 50b8f1418f26..ce6fb810854f 100644 --- a/fs/iomap/seek.c +++ b/fs/iomap/seek.c @@ -35,23 +35,20 @@ loff_t iomap_seek_hole(struct inode *inode, loff_t offset, const struct iomap_ops *ops) { loff_t size = i_size_read(inode); - loff_t length = size - offset; loff_t ret; /* Nothing to be found before or beyond the end of the file. */ if (offset < 0 || offset >= size) return -ENXIO; - while (length > 0) { - ret = iomap_apply(inode, offset, length, IOMAP_REPORT, ops, - &offset, iomap_seek_hole_actor); + while (offset < size) { + ret = iomap_apply(inode, offset, size - offset, IOMAP_REPORT, + ops, &offset, iomap_seek_hole_actor); if (ret < 0) return ret; if (ret == 0) break; - offset += ret; - length -= ret; } return offset; -- 2.30.2