Re: Rust kernel policy

David Laight
2025-02-23T16:42:06Z

On Fri, 21 Feb 2025 15:04:04 -0800
Linus Torvalds <torvalds@linux-foundation.org> wrote:

> On Fri, 21 Feb 2025 at 14:23, Steven Rostedt <rostedt@goodmis.org> wrote:
> >
> > If I could just get a warning for this stupid mistake:
> >
> > size_t ret;
> >
> > ret = func();
> > if (ret < 0)
> > error();
>
> Note that my main beef with the crazy compiler warning is that it
> literally triggers for *RANGE CHECKS*.
>
> IOW, it's literally the "if (a < 0 || a > XYZ)" thing that absolutely
> MUST NOT WARN. EVER. If it does, the compiler is broken.

The other one is where it already knows the code is being discarded.
I suspect it even warns for:
unsigned int x;
if (1 || x < 0) ...
You can't even escape with Generic (a switch statement based on the type
of a variable). All the options have to compile with all the types.

David