From nobody Tue Dec 2 02:31:05 2025 Received: from mailtransmit05.runbox.com (mailtransmit05.runbox.com [185.226.149.38]) (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 65F75337B9F for ; Wed, 19 Nov 2025 22:42:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.38 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592178; cv=none; b=gCa1RrlVPJ0qSer6VSFuwN59rDzxpsKPKgsUzGBsyqQCFJvqTMqxlT2jqNcKtmnSbX8+KgKZ3lhHpQb98hAMsl8YRnAdfQa5MSNgbwJJUEVm/WH3ICfhsT0lEwRpUmK0Es6EUUQbVuNbcUpIMUCJvoi5IfZthBlLga3Kq8n4iws= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592178; c=relaxed/simple; bh=s5eG/ZkGuXk9LYMPeAxkm0dh52rV4sIH4WXC8/1L+B4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=RFYnz7YUSqRuUvPZzZt2ozWcItiv8HBB9YajkKGZJ3i2Rl3ZhjXBYc8pgElbn1DJ4PaoB06GG0JKQMtyRX4BQCMXExcgwPEgl0swb7X6fTXOwkP8aWUrXoCX9yOwBtaUwqfAYYEJG8xz378ONx9ACTvjY4GZxSKQYRusQ1upKwU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=yC8kwNa+; arc=none smtp.client-ip=185.226.149.38 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="yC8kwNa+" Received: from mailtransmit02.runbox ([10.9.9.162] helo=aibo.runbox.com) by mailtransmit05.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqt3-006kyQ-MU; Wed, 19 Nov 2025 23:42:53 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To :Message-Id:Date:Subject:Cc:To:From; bh=INS73H9fpfKpTzIXcq0TyWJMVVqIF72st9McdWRmVUY=; b=yC8kwNa+YVjK5AcjHJjwXb3Gvt uXqDA6KXj2213Be1u7D3HuvZ4X8Bds23OamTIfyV7fEylE8QAnQcsS+mOHwU9fWLlAr6u0OB4MZZj aBprvZBLOsh+3i3Ab8nBivV2nX1Zn5YfLKDOxZi5ZR7a0KAl7OUyRDD8XWfjP6BGhr7A0f9kJMCEm iWaY0rzLcN9hzhF4pPmjeldP842gJxTRxDACHKFKTCJRcjNc6EJqQwcgZ2cvnXs60Psl0X6PfsIih dMXTaKCM/8OK3aYf/RGYcOIJ8LzYUQBNHnGhI45L0ngkV3xNeAmJhj5yh/WU2ZTmgp+wzWT8XzEGS Wj/wmy3Q==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit02.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqt3-00086p-CJ; Wed, 19 Nov 2025 23:42:53 +0100 Received: by submission03.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.93) id 1vLqsf-00Fos6-Da; Wed, 19 Nov 2025 23:42:29 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org Cc: Christoph Hellwig , Jens Axboe , Keith Busch , Sagi Grimberg , David Laight Subject: [PATCH 22/44] drivers/nvme: use min() instead of min_t() Date: Wed, 19 Nov 2025 22:41:18 +0000 Message-Id: <20251119224140.8616-23-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20251119224140.8616-1-david.laight.linux@gmail.com> References: <20251119224140.8616-1-david.laight.linux@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: David Laight min_t(unsigned int, a, b) casts an 'unsigned long' to 'unsigned int'. Use min(a, b) instead as it promotes any 'unsigned int' to 'unsigned long' and so cannot discard significant bits. In this case the 'unsigned long' value is small enough that the result is ok. Detected by an extra check added to min_t(). Signed-off-by: David Laight --- drivers/nvme/host/pci.c | 3 +-- drivers/nvme/host/zns.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c index 72fb675a696f..c74be555a7e9 100644 --- a/drivers/nvme/host/pci.c +++ b/drivers/nvme/host/pci.c @@ -3412,8 +3412,7 @@ static struct nvme_dev *nvme_pci_alloc_dev(struct pci= _dev *pdev, * Limit the max command size to prevent iod->sg allocations going * over a single page. */ - dev->ctrl.max_hw_sectors =3D min_t(u32, - NVME_MAX_BYTES >> SECTOR_SHIFT, + dev->ctrl.max_hw_sectors =3D min(NVME_MAX_BYTES >> SECTOR_SHIFT, dma_opt_mapping_size(&pdev->dev) >> 9); dev->ctrl.max_segments =3D NVME_MAX_SEGS; dev->ctrl.max_integrity_segments =3D 1; diff --git a/drivers/nvme/host/zns.c b/drivers/nvme/host/zns.c index cce4c5b55aa9..c0b05a220f36 100644 --- a/drivers/nvme/host/zns.c +++ b/drivers/nvme/host/zns.c @@ -126,8 +126,7 @@ static void *nvme_zns_alloc_report_buffer(struct nvme_n= s *ns, const size_t min_bufsize =3D sizeof(struct nvme_zone_report) + sizeof(struct nvme_zone_descriptor); =20 - nr_zones =3D min_t(unsigned int, nr_zones, - get_capacity(ns->disk) >> ilog2(ns->head->zsze)); + nr_zones =3D min(nr_zones, get_capacity(ns->disk) >> ilog2(ns->head->zsze= )); =20 bufsize =3D sizeof(struct nvme_zone_report) + nr_zones * sizeof(struct nvme_zone_descriptor); --=20 2.39.5