[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <DG5HFQ1JHRA1.QTLZFE4GDZT8@garyguo.net>
Date: Tue, 03 Feb 2026 16:54:35 +0000
From: "Gary Guo" <gary@...yguo.net>
To: Onur Özkan <work@...rozkan.dev>, "Gary Guo"
<gary@...yguo.net>
Cc: "Jkhall81" <jason.kei.hall@...il.com>, <dirk.behme@...bosch.com>,
<joe@...ches.com>, <ojeda@...nel.org>, <rust-for-linux@...r.kernel.org>,
<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v4] scripts: checkpatch: warn on Rust panicking methods
On Tue Feb 3, 2026 at 4:32 PM GMT, Onur Özkan wrote:
> On Tue, 03 Feb 2026 16:02:02 +0000
> "Gary Guo" <gary@...yguo.net> wrote:
>
>> On Tue Feb 3, 2026 at 3:49 PM GMT, Onur Özkan wrote:
>> > On Tue, 3 Feb 2026 08:25:41 -0700
>> > Jkhall81 <jason.kei.hall@...il.com> wrote:
>> >
>> >> Nice, emails sent from gmail get automatically rejected.
>> >>
>> >> So, Dirk. To satisfy your concerns the current 10ish line
>> >> code update is going to slowly, after many more emails
>> >> written in nano, mutate into a franken-regex-perl beast.
>> >> checkpatch.pl is already huge. I'm not a fan of this
>> >> approach.
>> >
>> > Me neither. I wonder why we are doing this instead of using the
>> > unwrap_used and expect_used linting rules from clippy. This would
>> > catch the problem much earlier than checkpath since many of us build
>> > the kernel with CLIPPY=1 flag.
>>
>> Because it's okay to `panic` or use `expect`. checkpatch will just
>> warn you once when the code is introduced, not continuously in each
>> build.
>
> That's interesting because it implies that it's okay for people to use
> them without "// PANIC..." comments. That sounds problematic since it
> means some instances will have that comment while others may not.
My personal view has always been it's okay to not have it. It's a burden to
developers to always have to write these. In many cases, `panic()` or `expect()`
calls are needed because you have something of `Option<>` and you know it's not
going to be `None`. The C equivalent would just be a pointer and you use it
without checking for NULL; we never ask people to justify why they feel it's
okay to dereference a pointer.
Sure, if people would like to justify why they think it won't panic, brilliant,
keeping doing it. But I don't want to make it harder for people to write Rust
code compared to C.
>
> In my opinion, adding a clippy rule and using "#[allow(...)]" in the
> places where it's acceptable to use them makes more sense. This is at
> least more consistent and doesn't bloat the checkpatch file.
`#[allow()]` looks quite verbose, and also you cannot apply it everywhere (just
blocks or items).
Best,
Gary
Powered by blists - more mailing lists