From patchwork Thu Aug 22 13:39:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: lizetao X-Patchwork-Id: 13773410 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D11721CC8B8; Thu, 22 Aug 2024 13:31:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724333503; cv=none; b=PxKHHJtOVmdAcCD4TOQdQ2R2j9j3BZQFMe9A9YFSat/AsnBv2h6LiRwIC3UUfXGxOWpQqLnztR7guOQQxIyM4Dk5G1+RULeZ8M4xOIZ7iC98Kw1xWpdg4bgGu0EatuzI6Oc+V3f/KDpTaWnEkMwj3SP8Snat+UVrsx72Dz1hh+g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724333503; c=relaxed/simple; bh=MsepUvgicJgEAXMFRoMiH1n5u/4ICpNE6DF8goEDdWE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=n02eHzQhyqGz+Nca+2DCv7By9lJwD0cyz6Bkn/JeAfsqdr6jee2GNBSInEYoe0fDyCezhlLWF73mBts6ilo8yNEZHh7Q4bZ6aZhhCeiadfqiu3XgqUQLk64jyB+fHm1u3JCR4jl5VrEK5y5DCuz7mQanLJNLUTPhDul3xCDArTw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.48]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4WqPGp71xmzyQPx; Thu, 22 Aug 2024 21:30:58 +0800 (CST) Received: from kwepemd500012.china.huawei.com (unknown [7.221.188.25]) by mail.maildlp.com (Postfix) with ESMTPS id A6F98180087; Thu, 22 Aug 2024 21:31:39 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemd500012.china.huawei.com (7.221.188.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.34; Thu, 22 Aug 2024 21:31:38 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , Subject: [PATCH net-next 8/8] SUNRPC: use min() to simplify the code Date: Thu, 22 Aug 2024 21:39:08 +0800 Message-ID: <20240822133908.1042240-9-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240822133908.1042240-1-lizetao1@huawei.com> References: <20240822133908.1042240-1-lizetao1@huawei.com> Precedence: bulk X-Mailing-List: ceph-devel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemd500012.china.huawei.com (7.221.188.25) When reading pages in xdr_read_pages, the number of XDR encoded bytes should be less than the len of aligned pages, so using min() here is very semantic. Signed-off-by: Li Zetao Reviewed-by: Simon Horman Acked-by: Chuck Lever --- net/sunrpc/xdr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c index 62e07c330a66..6746e920dbbb 100644 --- a/net/sunrpc/xdr.c +++ b/net/sunrpc/xdr.c @@ -1602,7 +1602,7 @@ unsigned int xdr_read_pages(struct xdr_stream *xdr, unsigned int len) end = xdr_stream_remaining(xdr) - pglen; xdr_set_tail_base(xdr, base, end); - return len <= pglen ? len : pglen; + return min(len, pglen); } EXPORT_SYMBOL_GPL(xdr_read_pages);