From nobody Tue Dec 2 02:31:02 2025 Received: from mailtransmit04.runbox.com (mailtransmit04.runbox.com [185.226.149.37]) (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 89D3B32F757 for ; Wed, 19 Nov 2025 22:42:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.37 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592170; cv=none; b=Tjst+LwXp7XasBgpxCiWXpKwKrq2+eSznKy67bgcLQwpgJbzx0Zd2XCaMDdhEC5BZth41DxRUdN3wK9j82K7FeeGhMtM9OFzWe3GOSVHMS+iVlOVX7kKf2Lcz8SiFOe3IRfvMOmibm0XzdoIjblhcj4v44OMpawkAulJNWDZ5/s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592170; c=relaxed/simple; bh=RMIqtmN/4RtL6p2LVa4RE3s9P+G0q/VqczqUzreyLgk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rE7BbMPUv3+s80GuaW7pJWDzR/QXk4bHp8e6RwUYiXsoR56pBl/8zT+lF33dOfJIGqCrFKalMgXCJP3vhf3noZC4JYfJVhPHtpRVX1tk9T4IPQN7JfiB5YrYsrTQkMODlxDx3kxeqUJh7CTWI+ECqM3ilR6T4ZfU7qrHGF3Z5V8= 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=Q5dkjt+f; arc=none smtp.client-ip=185.226.149.37 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="Q5dkjt+f" Received: from mailtransmit03.runbox ([10.9.9.163] helo=aibo.runbox.com) by mailtransmit04.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1vLqsu-006yqv-Uk; Wed, 19 Nov 2025 23:42:44 +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=sV4oS4H81Abb8E2Fnwq0jTIcGfJEaFUdtU0rGla/620=; b=Q5dkjt+fZOi7S4O0fj+VAf0h41 SOnGf+oNFSb35KGyPZ4czF2mWQxkrtckQX8hbn9bvD1vth6dV2SmS69FLyWEePH20TzlSMrDeQ/qD ziTJO/07EJh+YE0H5X7Lqht+Okn8IYJJSLam4DTu8TLtO3mk2+AO/zk7nGb8pWQrpxl3gy13l+h1K nXu2Jii4ZxojlEc/8TJc1ZJJl/zYlmje1HIz8KgH8SVLu4kZ5DMCgxoheqS8x0cwgXEG5M4xRIEyU L4R2TlzuqN2kpgrOZtW1fRYEVbUOim7DYyxy4tKodJEyExfWrEDUX+K1YjIg5zMbCyMYaBMnXMKwm MXgd5LPw==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqsu-0000Cn-0e; Wed, 19 Nov 2025 23:42:44 +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 1vLqsj-00Fos6-PO; Wed, 19 Nov 2025 23:42:33 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org Cc: Yury Norov , David Laight Subject: [PATCH 32/44] nodemask: use min() instead of min_t() Date: Wed, 19 Nov 2025 22:41:28 +0000 Message-Id: <20251119224140.8616-33-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 --- include/linux/nodemask.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/include/linux/nodemask.h b/include/linux/nodemask.h index 7ad1f5c7407e..bd38648c998d 100644 --- a/include/linux/nodemask.h +++ b/include/linux/nodemask.h @@ -245,18 +245,18 @@ static __always_inline int __nodes_weight(const nodem= ask_t *srcp, unsigned int n } =20 /* FIXME: better would be to fix all architectures to never return - > MAX_NUMNODES, then the silly min_ts could be dropped. */ + > MAX_NUMNODES, then the silly min()s could be dropped. */ =20 #define first_node(src) __first_node(&(src)) static __always_inline unsigned int __first_node(const nodemask_t *srcp) { - return min_t(unsigned int, MAX_NUMNODES, find_first_bit(srcp->bits, MAX_N= UMNODES)); + return min(MAX_NUMNODES, find_first_bit(srcp->bits, MAX_NUMNODES)); } =20 #define next_node(n, src) __next_node((n), &(src)) static __always_inline unsigned int __next_node(int n, const nodemask_t *s= rcp) { - return min_t(unsigned int, MAX_NUMNODES, find_next_bit(srcp->bits, MAX_NU= MNODES, n+1)); + return min(MAX_NUMNODES, find_next_bit(srcp->bits, MAX_NUMNODES, n+1)); } =20 /* @@ -293,8 +293,7 @@ static __always_inline void init_nodemask_of_node(nodem= ask_t *mask, int node) #define first_unset_node(mask) __first_unset_node(&(mask)) static __always_inline unsigned int __first_unset_node(const nodemask_t *m= askp) { - return min_t(unsigned int, MAX_NUMNODES, - find_first_zero_bit(maskp->bits, MAX_NUMNODES)); + return min(MAX_NUMNODES, find_first_zero_bit(maskp->bits, MAX_NUMNODES)); } =20 #define NODE_MASK_LAST_WORD BITMAP_LAST_WORD_MASK(MAX_NUMNODES) --=20 2.39.5