On Mon, 20 Jan 2025 at 10:55, Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx> wrote: > > Excuse me if I am missing something, but clamp() has a warning inside it, correct? > Why do we need an additional warning on top of that? Note: the warning in clamp() only finds compile-time obvious wrong uses. It's really meant to notice the trivial case where you clam with constants and just got the order wrong, so you do something silly like res = clamp(in, 15, 1); but it does also end up catching slightly more complex things where the compiler can figure out the range of the clamping. The build problem then comes from the compiler doing various *other* code movem,ent and optimization too, and - like in this case - finds an error path where the clamping is done "wrong". I think the real issue in the i915 driver is that it does that WARN_ON(), but then it just happily continues anyway. So if the i915 driver instead did if (WARN_ON(..)) return invalid value; none of this would ever have happened. Linus