From nobody Tue Dec 2 02:31:03 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 31ECC336EFE for ; Wed, 19 Nov 2025 22:42:55 +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=1763592177; cv=none; b=Wa7DARpMHs93n/qpWvZqZpLOZ7/9jLc6qMuFJqUlrG7tYz0mtt/cRzt+XFVcFwcroGj3Y5zG0U5uHI9K6oYYq23UuADOjSpyz6TOHy6nDsqJwrspNgLZroRQC6CXqcgL+5SEqPQcj8erJW1HADf27dF4RR7Ywve2/U22fZcABdI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763592177; c=relaxed/simple; bh=WUjnT82624Zwb8w0p72N3iPJSTbGrnMixK+bCaEsFgY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=soebFnp6WtJAt0o6+PrGUCejr5htbvhd99/FHgK/Vp46F5SkmxxwqVPzGjhdp7X+mx47w78vJUSQ3t3yAhXECw0GHnWNBPi/r79XBfrRYuadTjhGmXua7LOUh1K958l2aZftfdu62M9MPBYKivkJ/iZWK0BKYH4WPVfZUO9t4ZE= 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=pKUZV73v; 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="pKUZV73v" Received: from mailtransmit03.runbox ([10.9.9.163] 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 1vLqt2-006kxx-GN for linux-kernel@vger.kernel.org; Wed, 19 Nov 2025 23:42:52 +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=T6H140WlxK80H7srwWZByYIW1P5L3lVvTAZfRz2mH6I=; b=pKUZV73vj4uviqRkfStiZuC8Qj un66Pk6jjjpcM15zBemO/HrioR4OBW5s/2dKVoXhzXUqHUWfIEtoi87O39cIHjDxVm3deEozpBVEt BdgdTTRPP/usaTx5Lq2ZlOzTnVlb0Tl9vkehiAOsxNaJ3Qef03B1NIigMLkYnyinrYJFcS5UK9kjC G/TbDRWNC8DaMrUZ/rJy01hZvYIbqzxjXO8TsTcQ0f/uDaJp14I1N4k6TNjypd7VvDzmxo5rjoFLp O1LLyE/Ow6fWKEO06tx42pSYRW5qP/L5KFWTjOjIVzEOFCE93eMXYv2SIrOeP4KlZhYQIIcw5jgTo XEfRr/Wg==; Received: from [10.9.9.74] (helo=submission03.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1vLqt2-0000E2-6s; Wed, 19 Nov 2025 23:42:52 +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 1vLqsk-00Fos6-2h; Wed, 19 Nov 2025 23:42:34 +0100 From: david.laight.linux@gmail.com To: linux-kernel@vger.kernel.org Cc: David Laight Subject: [PATCH 33/44] ipc: use min() instead of min_t() Date: Wed, 19 Nov 2025 22:41:29 +0000 Message-Id: <20251119224140.8616-34-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 --- ipc/mqueue.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ipc/mqueue.c b/ipc/mqueue.c index 093551fe66a7..9384eb444b83 100644 --- a/ipc/mqueue.c +++ b/ipc/mqueue.c @@ -363,7 +363,7 @@ static struct inode *mqueue_get_inode(struct super_bloc= k *sb, if (info->attr.mq_msgsize > ULONG_MAX/info->attr.mq_maxmsg) goto out_inode; mq_treesize =3D info->attr.mq_maxmsg * sizeof(struct msg_msg) + - min_t(unsigned int, info->attr.mq_maxmsg, MQ_PRIO_MAX) * + min(info->attr.mq_maxmsg, MQ_PRIO_MAX) * sizeof(struct posix_msg_tree_node); mq_bytes =3D info->attr.mq_maxmsg * info->attr.mq_msgsize; if (mq_bytes + mq_treesize < mq_bytes) @@ -540,7 +540,7 @@ static void mqueue_evict_inode(struct inode *inode) =20 /* Total amount of bytes accounted for the mqueue */ mq_treesize =3D info->attr.mq_maxmsg * sizeof(struct msg_msg) + - min_t(unsigned int, info->attr.mq_maxmsg, MQ_PRIO_MAX) * + min(info->attr.mq_maxmsg, MQ_PRIO_MAX) * sizeof(struct posix_msg_tree_node); =20 mq_bytes =3D mq_treesize + (info->attr.mq_maxmsg * --=20 2.39.5