From: David Laight <David.Laight@ACULAB.COM>
To: 'Alexey Dobriyan' <adobriyan@gmail.com>,
Linus Torvalds <torvalds@linux-foundation.org>
Cc: "akpm@linux-foundation.org" <akpm@linux-foundation.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"catalin.marinas@arm.com" <catalin.marinas@arm.com>,
"will@kernel.org" <will@kernel.org>,
"rafael.j.wysocki@intel.com" <rafael.j.wysocki@intel.com>,
"masahiroy@kernel.org" <masahiroy@kernel.org>
Subject: RE: [PATCH] kbuild: drop -Wdeclaration-after-statement
Date: Sat, 29 Oct 2022 11:47:31 +0000 [thread overview]
Message-ID: <45b92f4e5794439fb8057611ef0096d3@AcuMS.aculab.com> (raw)
In-Reply-To: <Y1xBwRCHoQtMyPf8@p183>
From: Alexey Dobriyan
> Sent: 28 October 2022 21:55
>
> On Fri, Oct 28, 2022 at 01:29:08PM -0700, Linus Torvalds wrote:
> > On Fri, Oct 28, 2022 at 1:00 PM Alexey Dobriyan <adobriyan@gmail.com> wrote:
> > >
> > > Putting declarations in the beginning of the block is an afterfact from
> > > single pass compiler era. Compiler would parse all declarations, layout
> > > stack frame and proceed to generate code.
> >
> > No, putting declarations at the beginning is still kernel syntax.
> >
> > Don't declare variables in multiple places. It gets really confusing.
>
> It is not. Somehow millions of programmers manage to find their
> variables just fine in C and other programming languages.
Have you ever tried it when -Wshadow isn't enabled and variables
with the same name are redefined in the middle of blocks?
C++ has to allow it (and it is annoying to find definitions)
because the initialiser has to be called.
But you can't use a 'goto' to jump past a declaration.
> > Put all declarations at the top of the block they are contained in.
Or better, either at the top of the function or in a small block
(where the limited scope is absolutely obvious).
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
prev parent reply other threads:[~2022-10-29 11:47 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-28 20:00 [PATCH] kbuild: drop -Wdeclaration-after-statement Alexey Dobriyan
2022-10-28 20:29 ` Linus Torvalds
2022-10-28 20:55 ` Alexey Dobriyan
2022-10-28 21:11 ` Linus Torvalds
2022-10-29 11:47 ` David Laight [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=45b92f4e5794439fb8057611ef0096d3@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=catalin.marinas@arm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=masahiroy@kernel.org \
--cc=rafael.j.wysocki@intel.com \
--cc=torvalds@linux-foundation.org \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox