From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 43A5E1C862F; Tue, 30 Sep 2025 15:25:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759245942; cv=none; b=VmNCoYT9uFcHsk/AEsHma7idEmXuZvDmVLIcf0q5q0ovCUFJN51QyQF4CirfPPKmx3J5W87NHvKNa22Ckkyc02QHqQSti2en4lVddHbfnb3l1WUKyuL0U7v6l0m5rLHRHXc0TxkI8dmQrzAx/2Xk+b/2qEWDjjBmtoqrMRYAox4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759245942; c=relaxed/simple; bh=7dstz4ewV5obOB/ppIEYjCJSTriOy6e6E7sruKyKw5Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eSG2mk8WI2gjSm1pmKumB4snMUslbndFBvwtpYYdPN7+wv4vdYtdtDfRpIT2dBSuijQVP944vyAcSpGwzPTbUDJK3zmgysv334PkmLcJQbRQ8rNdW/94maGmBkttgWDOFJPuCARMq5NsqdAjsFj/uxZxF/MOrwkV8Uqg0sev5bQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=F9sLS8hD; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="F9sLS8hD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7CB27C4CEF0; Tue, 30 Sep 2025 15:25:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1759245942; bh=7dstz4ewV5obOB/ppIEYjCJSTriOy6e6E7sruKyKw5Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F9sLS8hDbscOrgsQ1dtGE7y8tlNeL2fwc3GqoiRItwvmolnd87nLYNK2vGJZn8DUw bcbTtL6zPF2Gs87gBX9Ks6ienBEizUw1v47uVEgpdfctmuLhryO9AR5HD9+UF7xP3B BXtwz8Si6M79IviM8GfZYqETZ9kZduhxzNzMlACU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, David Laight , Andy Shevchenko , Arnd Bergmann , Christoph Hellwig , Dan Carpenter , "Jason A. Donenfeld" , Jens Axboe , Lorenzo Stoakes , Mateusz Guzik , Matthew Wilcox , Pedro Falcato , Andrew Morton , Eliav Farber Subject: [PATCH 6.6 88/91] minmax.h: use BUILD_BUG_ON_MSG() for the lo < hi test in clamp() Date: Tue, 30 Sep 2025 16:48:27 +0200 Message-ID: <20250930143824.833291589@linuxfoundation.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250930143821.118938523@linuxfoundation.org> References: <20250930143821.118938523@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: David Laight [ Upstream commit a5743f32baec4728711bbc01d6ac2b33d4c67040 ] Use BUILD_BUG_ON_MSG(statically_true(ulo > uhi), ...) for the sanity check of the bounds in clamp(). Gives better error coverage and one less expansion of the arguments. Link: https://lkml.kernel.org/r/34d53778977747f19cce2abb287bb3e6@AcuMS.aculab.com Signed-off-by: David Laight Cc: Andy Shevchenko Cc: Arnd Bergmann Cc: Christoph Hellwig Cc: Dan Carpenter Cc: Jason A. Donenfeld Cc: Jens Axboe Cc: Lorenzo Stoakes Cc: Mateusz Guzik Cc: Matthew Wilcox Cc: Pedro Falcato Signed-off-by: Andrew Morton Signed-off-by: Eliav Farber Signed-off-by: Greg Kroah-Hartman --- include/linux/minmax.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/include/linux/minmax.h +++ b/include/linux/minmax.h @@ -106,8 +106,7 @@ __auto_type uval = (val); \ __auto_type ulo = (lo); \ __auto_type uhi = (hi); \ - static_assert(__builtin_choose_expr(__is_constexpr((lo) > (hi)), \ - (lo) <= (hi), true), \ + BUILD_BUG_ON_MSG(statically_true(ulo > uhi), \ "clamp() low limit " #lo " greater than high limit " #hi); \ BUILD_BUG_ON_MSG(!__types_ok3(uval, ulo, uhi), \ "clamp("#val", "#lo", "#hi") signedness error"); \