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 1DD9930BF4F; Mon, 13 Oct 2025 14:48:27 +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=1760366908; cv=none; b=jYm3XMSp3K2gH+kgvrA0zsJSn9sLk32TwMf4k8p3Bg8pT/917y3Gz6DYXZSDRNSxyyBExRUgAUHLLMBf7UcM1r3vXOP0K1B+1pD2aM4hV56fcj+jTiVaah2Sc7eoRlbgLkQB94q+VZdBbYHDaS2cW+bwOlcQB/1h7TRCr1Sk0Dg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760366908; c=relaxed/simple; bh=n2cePzzRGa08Ocx08TpdrXQSvVZKpmtwCJQ7p6EyypM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Hb5Bmxz/HzzH56w1eTe0FTAhDMaVqVcCrhDvkM/wVp4YjHFd2MCuFOjyrRKiFSWgp8KWOxARBR9jSU4NtoPSjedGxlhsTAIbL1abG0Xuiu659M93S7ZkPlyJe7e2kRQjfZ1BHps9DcvRGpRgZnzyqwoocWBGPp+RlmJ/5jzK3pE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=UeOB1gue; 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="UeOB1gue" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 55AF6C116C6; Mon, 13 Oct 2025 14:48:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1760366907; bh=n2cePzzRGa08Ocx08TpdrXQSvVZKpmtwCJQ7p6EyypM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UeOB1gueJO5CO1XYklc8IWw7KDi4x0YQGQPhfharJDAQ7OYxcEPMP44vnEpX2sh38 wTsH9+CXO9qduSnF2pQ3LZf1iiO6QAMzQ78s4sL3Cdo/GxjY+P79H1txk0o42liZNa wrgWX/CNs4aMY1L0pBjSY9embVydSnFnpUEK8NHQ= 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.1 026/196] minmax.h: use BUILD_BUG_ON_MSG() for the lo < hi test in clamp() Date: Mon, 13 Oct 2025 16:43:19 +0200 Message-ID: <20251013144315.529780471@linuxfoundation.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251013144314.549284796@linuxfoundation.org> References: <20251013144314.549284796@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-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"); \