[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YuOUp+7gam0UUu1+@kroah.com>
Date: Fri, 29 Jul 2022 10:04:55 +0200
From: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
To: Olliver Schinagl <oliver+list@...inagl.nl>
Cc: Gary Guo <gary@...yguo.net>,
Miguel Ojeda <miguel.ojeda.sandonis@...il.com>,
Miguel Ojeda <ojeda@...nel.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
rust-for-linux <rust-for-linux@...r.kernel.org>,
Linux Kbuild mailing list <linux-kbuild@...r.kernel.org>,
Linux Doc Mailing List <linux-doc@...r.kernel.org>,
linux-kernel <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 00/13] [RFC] Rust support
On Thu, Jul 28, 2022 at 10:45:08PM +0200, Olliver Schinagl wrote:
> Hey Greg,
>
> On 28-07-2022 14:09, Greg Kroah-Hartman wrote:
> > On Thu, Jul 28, 2022 at 11:21:14AM +0100, Gary Guo wrote:
> > > Rust requires braces around branches of if expression, and C doesn't.
> > > So in kernel coding style you often have:
> > >
> > > if (condition) do_something();
> >
> > That is not a valid kernel coding style, and our tools should catch this
> > and prevent it from being added to the kernel tree.
> Are you sure? I'm not sure if this isn't true today, but I've certainly seen
> old code where this definitely was done. Was all of this cleaned up in the
> last 2+ years?
Given that I wrote about this back in 2002, and it was true then:
https://www.linuxjournal.com/article/5780
and:
https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.2.8887&rep=rep1&type=pdf
that is not anything new at all.
Yes, old code still survives that might not be correct, and some
subsystems might have added code over time without the proper style, but
our tools check that the above is not correct, you can check it
yourself:
$ cat foo.c
// SPDX-License-Identifier: GPL-2.0
int foo(int baz)
{
if (baz == 1) do_something();
}
$ ./scripts/checkpatch.pl --file --terse foo.c
foo.c:4: ERROR: trailing statements should be on next line
total: 1 errors, 0 warnings, 6 lines checked
thanks,
greg k-h
Powered by blists - more mailing lists